Skip to content

Commit

Permalink
Merge branch 'release/1.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
yzane committed Feb 16, 2020
2 parents 4815dcc + b987129 commit 138420f
Show file tree
Hide file tree
Showing 10 changed files with 452 additions and 336 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## 1.4.2 (2020/02/16)
* Add: Support [gray-matter](https://github.com/jonschlinkert/gray-matter) (preview)
* Avoid to display front matter [#157](https://github.com/yzane/vscode-markdown-pdf/pull/157)
* Currently, only some settings can be specified.
* Fix: Improve the configuration schema of package.json
* Some settings can now be set from the settings editor.
* Fix: Specifying custom style sheets with a relative path does not work [#170](https://github.com/yzane/vscode-markdown-pdf/pull/170)
* Fix: Pass language to markdown-pdf puppeteer [#172](https://github.com/yzane/vscode-markdown-pdf/pull/172)
* Date Format [#95](https://github.com/yzane/vscode-markdown-pdf/issues/95)
* Improve: Reduce Regex strictness of markdown-it-include [#174](https://github.com/yzane/vscode-markdown-pdf/pull/174)

## 1.4.1 (2019/10/28)
* Fix: "ReferenceError: MarkdownPdf is not defined" on auto create PDF on save in VSCodium [#156](https://github.com/yzane/vscode-markdown-pdf/issues/156)

Expand Down
17 changes: 11 additions & 6 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,16 @@ Visual Studio Code の `files.autoGuessEncoding` オプションを使うと、

## [Release Notes](CHANGELOG.md)

### 1.4.1 (2019/10/28)
* Fix: "ReferenceError: MarkdownPdf is not defined" on auto create PDF on save in VSCodium [#156](https://github.com/yzane/vscode-markdown-pdf/issues/156)

### 1.4.0 (2019/10/27)
* Add: Support [mermaid](https://github.com/knsv/mermaid)
* Added mermaid support. [#144](https://github.com/yzane/vscode-markdown-pdf/pull/144)
### 1.4.2 (2020/02/16)
* Add: Support [gray-matter](https://github.com/jonschlinkert/gray-matter) (preview)
* Avoid to display front matter [#157](https://github.com/yzane/vscode-markdown-pdf/pull/157)
* Currently, only some settings can be specified.
* Fix: Improve the configuration schema of package.json
* Some settings can now be set from the settings editor.
* Fix: Specifying custom style sheets with a relative path does not work [#170](https://github.com/yzane/vscode-markdown-pdf/pull/170)
* Fix: Pass language to markdown-pdf puppeteer [#172](https://github.com/yzane/vscode-markdown-pdf/pull/172)
* Date Format [#95](https://github.com/yzane/vscode-markdown-pdf/issues/95)
* Improve: Reduce Regex strictness of markdown-it-include [#174](https://github.com/yzane/vscode-markdown-pdf/pull/174)


## License
Expand All @@ -587,6 +591,7 @@ MIT
* [gmunguia/markdown-it-plantuml](https://github.com/gmunguia/markdown-it-plantuml)
* [camelaissani/markdown-it-include](https://github.com/camelaissani/markdown-it-include)
* [knsv/mermaid](https://github.com/knsv/mermaid)
* [jonschlinkert/gray-matter](https://github.com/jonschlinkert/gray-matter)

and

Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,16 @@ Please use the following to insert a page break.

## [Release Notes](CHANGELOG.md)

### 1.4.1 (2019/10/28)
* Fix: "ReferenceError: MarkdownPdf is not defined" on auto create PDF on save in VSCodium [#156](https://github.com/yzane/vscode-markdown-pdf/issues/156)

### 1.4.0 (2019/10/27)
* Add: Support [mermaid](https://github.com/knsv/mermaid)
* Added mermaid support. [#144](https://github.com/yzane/vscode-markdown-pdf/pull/144)
### 1.4.2 (2020/02/16)
* Add: Support [gray-matter](https://github.com/jonschlinkert/gray-matter) (preview)
* Avoid to display front matter [#157](https://github.com/yzane/vscode-markdown-pdf/pull/157)
* Currently, only some settings can be specified.
* Fix: Improve the configuration schema of package.json
* Some settings can now be set from the settings editor.
* Fix: Specifying custom style sheets with a relative path does not work [#170](https://github.com/yzane/vscode-markdown-pdf/pull/170)
* Fix: Pass language to markdown-pdf puppeteer [#172](https://github.com/yzane/vscode-markdown-pdf/pull/172)
* Date Format [#95](https://github.com/yzane/vscode-markdown-pdf/issues/95)
* Improve: Reduce Regex strictness of markdown-it-include [#174](https://github.com/yzane/vscode-markdown-pdf/pull/174)


## License
Expand All @@ -593,6 +597,7 @@ MIT
* [gmunguia/markdown-it-plantuml](https://github.com/gmunguia/markdown-it-plantuml)
* [camelaissani/markdown-it-include](https://github.com/camelaissani/markdown-it-include)
* [knsv/mermaid](https://github.com/knsv/mermaid)
* [jonschlinkert/gray-matter](https://github.com/jonschlinkert/gray-matter)

and

Expand Down
38 changes: 25 additions & 13 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,14 @@ function isMarkdownPdfOnSaveExclude() {
* convert markdown to html (markdown-it)
*/
function convertMarkdownToHtml(filename, type, text) {
var grayMatter = require("gray-matter");
var matterParts = grayMatter(text);

try {
try {
var statusbarmessage = vscode.window.setStatusBarMessage('$(markdown) Converting (convertMarkdownToHtml) ...');
var hljs = require('highlight.js');
var breaks = vscode.workspace.getConfiguration('markdown-pdf')['breaks'];
var breaks = setBooleanValue(matterParts.data.breaks, vscode.workspace.getConfiguration('markdown-pdf')['breaks']);
var md = require('markdown-it')({
html: true,
breaks: breaks,
Expand Down Expand Up @@ -217,8 +220,8 @@ function convertMarkdownToHtml(filename, type, text) {
md.use(require('markdown-it-checkbox'));

// emoji
var f = vscode.workspace.getConfiguration('markdown-pdf')['emoji'];
if (f) {
var emoji_f = setBooleanValue(matterParts.data.emoji, vscode.workspace.getConfiguration('markdown-pdf')['emoji']);
if (emoji_f) {
var emojies_defs = require(path.join(__dirname, 'data', 'emoji.json'));
try {
var options = {
Expand Down Expand Up @@ -266,8 +269,8 @@ function convertMarkdownToHtml(filename, type, text) {
// PlantUML
// https://github.com/gmunguia/markdown-it-plantuml
var plantumlOptions = {
openMarker: vscode.workspace.getConfiguration('markdown-pdf')['plantumlOpenMarker'] || '@startuml',
closeMarker: vscode.workspace.getConfiguration('markdown-pdf')['plantumlCloseMarker'] || '@enduml'
openMarker: matterParts.data.plantumlOpenMarker || vscode.workspace.getConfiguration('markdown-pdf')['plantumlOpenMarker'] || '@startuml',
closeMarker: matterParts.data.plantumlCloseMarker || vscode.workspace.getConfiguration('markdown-pdf')['plantumlCloseMarker'] || '@enduml'
}
md.use(require('markdown-it-plantuml'), plantumlOptions);

Expand All @@ -278,12 +281,12 @@ function convertMarkdownToHtml(filename, type, text) {
if (vscode.workspace.getConfiguration('markdown-pdf')['markdown-it-include']['enable']) {
md.use(require("markdown-it-include"), {
root: path.dirname(filename),
includeRe: /\:(?:\[[^\]]*\])?\(([^)]+\.md)\)/i
includeRe: /\:(?:\[[^\]]*\])?\(([^)]+\.*)\)/i
});
}

statusbarmessage.dispose();
return md.render(text);
return md.render(matterParts.content);

} catch (error) {
statusbarmessage.dispose();
Expand Down Expand Up @@ -391,7 +394,8 @@ function exportPdf(data, filename, type, uri) {
var tmpfilename = path.join(f.dir, f.name + '_tmp.html');
exportHtml(data, tmpfilename);
var options = {
executablePath: vscode.workspace.getConfiguration('markdown-pdf')['executablePath'] || puppeteer.executablePath()
executablePath: vscode.workspace.getConfiguration('markdown-pdf')['executablePath'] || puppeteer.executablePath(),
args: ['--lang='+vscode.env.langauage]
};
const browser = await puppeteer.launch(options);
const page = await browser.newPage();
Expand Down Expand Up @@ -448,10 +452,10 @@ function exportPdf(data, filename, type, uri) {
}

// screenshot size
var clip_x_option = vscode.workspace.getConfiguration('markdown-pdf')['clip']['x'];
var clip_y_option = vscode.workspace.getConfiguration('markdown-pdf')['clip']['y'];
var clip_width_option = vscode.workspace.getConfiguration('markdown-pdf')['clip']['width'];
var clip_height_option = vscode.workspace.getConfiguration('markdown-pdf')['clip']['height'];
var clip_x_option = vscode.workspace.getConfiguration('markdown-pdf')['clip']['x'] || null;
var clip_y_option = vscode.workspace.getConfiguration('markdown-pdf')['clip']['y'] || null;
var clip_width_option = vscode.workspace.getConfiguration('markdown-pdf')['clip']['width'] || null;
var clip_height_option = vscode.workspace.getConfiguration('markdown-pdf')['clip']['height'] || null;
var options;
if (clip_x_option !== null && clip_y_option !== null && clip_width_option !== null && clip_height_option !== null) {
options = {
Expand Down Expand Up @@ -735,7 +739,7 @@ function fixHref(resource, href) {
}

// Use href as file URI if it is absolute
if (path.isAbsolute(href) || hrefUri.scheme === 'file') {
if (path.isAbsolute(href)) {
return vscode.Uri.file(href).toString();
}

Expand Down Expand Up @@ -848,6 +852,14 @@ function setProxy() {
}
}

function setBooleanValue(a, b) {
if (a === false) {
return false
} else {
return a || b
}
}

function init() {
try {
if (checkPuppeteerBinary()) {
Expand Down
Loading

0 comments on commit 138420f

Please sign in to comment.