Skip to content

Commit

Permalink
Change: mermaid javascript reads from URL instead of from local file #…
Browse files Browse the repository at this point in the history
…175

add markdown-pdf.mermaidServer option
  • Loading branch information
yzane committed Mar 17, 2020
1 parent fe1eea6 commit 86ac3c0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Markdown PDF をインストールして、Visual Studio Code で Markdownファ
|[PlantUML options](#plantuml-options)|[markdown-pdf.plantumlOpenMarker](#markdown-pdfplantumlopenmarker)| |
||[markdown-pdf.plantumlCloseMarker](#markdown-pdfplantumlclosemarker)| |
|[markdown-it-include options](#markdown-it-include-options)|[markdown-pdf.markdown-it-include.enable](#markdown-pdfmarkdown-it-includeenable)| |
|[mermaid options](#mermaid-options)|[markdown-pdf.mermaidServer](#markdown-pdfmermaidserver)||

### Save options

Expand Down Expand Up @@ -509,6 +510,12 @@ Markdown PDF をインストールして、Visual Studio Code で Markdownファ
- markdown-it-include を有効にします
- boolean. Default: true

### mermaid options

#### `markdown-pdf.mermaidServer`
- mermaid server
- Default: https://unpkg.com/mermaid/dist/mermaid.min.js

<div class="page"/>

## FAQ
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ If the download is not successful or you want to avoid downloading every time yo
|[PlantUML options](#plantuml-options)|[markdown-pdf.plantumlOpenMarker](#markdown-pdfplantumlopenmarker)| |
||[markdown-pdf.plantumlCloseMarker](#markdown-pdfplantumlclosemarker)| |
|[markdown-it-include options](#markdown-it-include-options)|[markdown-pdf.markdown-it-include.enable](#markdown-pdfmarkdown-it-includeenable)| |
|[mermaid options](#mermaid-options)|[markdown-pdf.mermaidServer](#markdown-pdfmermaidserver)||

### Save options

Expand Down Expand Up @@ -515,6 +516,12 @@ If the download is not successful or you want to avoid downloading every time yo
- Enable markdown-it-include.
- boolean. Default: true

### mermaid options

#### `markdown-pdf.mermaidServer`
- mermaid server
- Default: https://unpkg.com/mermaid/dist/mermaid.min.js

<div class="page"/>

## FAQ
Expand Down
5 changes: 3 additions & 2 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,9 @@ function makeHtml(data, uri) {
var filename = path.join(__dirname, 'template', 'template.html');
var template = readFile(filename);

// read mermaid javascripts
var mermaid = readFile(path.join(__dirname, 'node_modules', 'mermaid', 'dist', 'mermaid.min.js'));
// read mermaid javascripts
var mermaidServer = vscode.workspace.getConfiguration('markdown-pdf')['mermaidServer'] || '';
var mermaid = '<script src=\"' + mermaidServer + '\"></script>';

// compile template
var mustache = require('mustache');
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,11 @@
"type": "boolean",
"default": true,
"description": "Enable markdown-it-include. "
},
"markdown-pdf.mermaidServer": {
"type": "string",
"default": "https://unpkg.com/mermaid/dist/mermaid.min.js",
"description": "mermaid server."
}
}
}
Expand Down Expand Up @@ -477,7 +482,6 @@
"markdown-it-include": "^1.1.0",
"markdown-it-named-headers": "0.0.4",
"markdown-it-plantuml": "^1.4.1",
"mermaid": "^8.4.0",
"mkdirp": "^0.5.1",
"mustache": "^3.1.0",
"puppeteer-core": "^2.1.1",
Expand Down
4 changes: 1 addition & 3 deletions template/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
<title>{{{title}}}</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
{{{style}}}
<script>
{{{mermaid}}}
</script>
{{{mermaid}}}
</head>
<body>
<script>
Expand Down

0 comments on commit 86ac3c0

Please sign in to comment.