diff --git a/README.md b/README.md index 80a7b21..132efb3 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Below is a demo of the Atom version. * `Markdown Preview Enhanced: Create TOC` * `Markdown Preview Enhanced: Open Mermaid Config` * `Markdown Preview Enhanced: Open MathJax Config` +* `Markdown Preview Enhanced: Open PhantomJS Config` * `Markdown Preview Enhanced: Insert New Slide` * `Markdown Preview Enhanced: Insert Table` * `Markdown Preview Enhanced: Insert Page Break` @@ -30,9 +31,14 @@ Below is a demo of the Atom version. For more features that will be supported in the future, check [Markdown Preview Enhanced for atom](https://shd101wyy.github.io/markdown-preview-enhanced/#/). -### Progress so far +### Progress so far +#### July 4, 2017 +*Basically finished porting.* +* Done [PhantomJS export](./docs/phantomjs.md). +* Done [pandoc parser](https://shd101wyy.github.io/markdown-preview-enhanced/#/pandoc?id=pandoc-parser) support. +* Added `Gothic`, `Newsprint`, and `Night` preview themes. + #### June 20, 2017 -Basically finished. * Done [Pandoc export](https://shd101wyy.github.io/markdown-preview-enhanced/#/pandoc-pdf). (Not tested). * Done Markdown(GFM) export. (Not tested) * Done [TOC](https://shd101wyy.github.io/markdown-preview-enhanced/#/toc) implementation. diff --git a/docs/phantomjs.md b/docs/phantomjs.md new file mode 100644 index 0000000..e88a5df --- /dev/null +++ b/docs/phantomjs.md @@ -0,0 +1,54 @@ +# PhantomJS Export + +**PhantomJS** supports `pdf`, `jpeg`, and `png` file export. +You need to download and install [phantomjs](http://phantomjs.org/download.html) first. + +## Usage +Right click at the preview, then click `PhantomJS`. Choose the file type you want to export. + +## Configuration +You can edit phantomjs configuration by running `Markdown Preview Enhanced: Open PhantomJS Config` command. + +The `phantomjs_header_footer_config.js` file should look like this: + + +```javascript +'use strict' +/* +configure header and footer (and other options) +more information can be found here: + https://github.com/marcbachmann/node-html-pdf +Attention: this config will override your config in exporter panel. + +eg: + + let config = { + "header": { + "height": "45mm", + "contents": '
Author: Marc Bachmann
' + }, + "footer": { + "height": "28mm", + "contents": '{{page}}/{{pages}}' + } + } +*/ +// you can edit the 'config' variable below +let config = { +} + +module.exports = config || {} +``` + +--- + +You can also write configuration for individual markdown file by front-matter. +For example: + +```markdown +--- +phantomjs: + orientation: "landscape" +--- + +``` diff --git a/src/extension.ts b/src/extension.ts index 6deed7b..553f652 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -245,11 +245,12 @@ export function activate(context: vscode.ExtensionContext) { function clickTagA(uri, href) { const sourceUri = vscode.Uri.parse(decodeURIComponent(uri)); + href = decodeURIComponent(href) if (['.pdf', '.xls', '.xlsx', '.doc', '.ppt', '.docx', '.pptx'].indexOf(path.extname(href)) >= 0) { utility.openFile(href) } else if (href.match(/^file\:\/\/\//)) { // openFilePath = href.slice(8) # remove protocal - let openFilePath = href.replace(/(\s*)[\#\?](.+)$/, '') // remove #anchor and ?params... + let openFilePath = utility.addFileProtocol(href.replace(/(\s*)[\#\?](.+)$/, '')) // remove #anchor and ?params... openFilePath = decodeURI(openFilePath) vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(openFilePath), vscode.ViewColumn.One) } else { diff --git a/src/markdown-preview-enhanced-webview.ts b/src/markdown-preview-enhanced-webview.ts index 63f8af8..381c631 100644 --- a/src/markdown-preview-enhanced-webview.ts +++ b/src/markdown-preview-enhanced-webview.ts @@ -720,7 +720,7 @@ function bindTagAClickEvent() { window.parent.postMessage({ command: 'did-click-link', // <= this has to be `did-click-link` to post message - data: `command:_markdown-preview-enhanced.clickTagA?${JSON.stringify([sourceUri, href])}` + data: `command:_markdown-preview-enhanced.clickTagA?${JSON.stringify([sourceUri, encodeURIComponent(href)])}` }, 'file://') } }