Skip to content

Commit

Permalink
Add: Configuration scope
Browse files Browse the repository at this point in the history
  • Loading branch information
yzane committed Mar 16, 2020
1 parent 744f2a1 commit 8b95d76
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 103 deletions.
76 changes: 38 additions & 38 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,44 +180,44 @@ Markdown PDF をインストールして、Visual Studio Code で Markdownファ

### List

|Category| Option name|
|:---|:---|
|[Save options](#save-options)|[markdown-pdf.type](#markdown-pdftype)|
||[markdown-pdf.convertOnSave](#markdown-pdfconvertonsave)|
||[markdown-pdf.convertOnSaveExclude](#markdown-pdfconvertonsaveexclude)|
||[markdown-pdf.outputDirectory](#markdown-pdfoutputdirectory)|
||[markdown-pdf.outputDirectoryRelativePathFile](#markdown-pdfoutputdirectoryrelativepathfile)|
|[Styles options](#styles-options)|[markdown-pdf.styles](#markdown-pdfstyles)|
||[markdown-pdf.stylesRelativePathFile](#markdown-pdfstylesrelativepathfile)|
||[markdown-pdf.includeDefaultStyles](#markdown-pdfincludedefaultstyles)|
|[Syntax highlight options](#syntax-highlight-options)|[markdown-pdf.highlight](#markdown-pdfhighlight)|
||[markdown-pdf.highlightStyle](#markdown-pdfhighlightstyle)|
|[Markdown options](#markdown-options)|[markdown-pdf.breaks](#markdown-pdfbreaks)|
|[Emoji options](#emoji-options)|[markdown-pdf.emoji](#markdown-pdfemoji)|
|[Configuration options](#configuration-options)|[markdown-pdf.executablePath](#markdown-pdfexecutablepath)|
|[Common Options](#common-options)|[markdown-pdf.scale](#markdown-pdfscale)|
|[PDF options](#pdf-options)|[markdown-pdf.displayHeaderFooter](#markdown-pdfdisplayheaderfooter)|
||[markdown-pdf.headerTemplate](#markdown-pdfheadertemplate)|
||[markdown-pdf.footerTemplate](#markdown-pdffootertemplate)|
||[markdown-pdf.printBackground](#markdown-pdfprintbackground)|
||[markdown-pdf.orientation](#markdown-pdforientation)|
||[markdown-pdf.pageRanges](#markdown-pdfpageranges)|
||[markdown-pdf.format](#markdown-pdfformat)|
||[markdown-pdf.width](#markdown-pdfwidth)|
||[markdown-pdf.height](#markdown-pdfheight)|
||[markdown-pdf.margin.top](#markdown-pdfmargintop)|
||[markdown-pdf.margin.bottom](#markdown-pdfmarginbottom)|
||[markdown-pdf.margin.right](#markdown-pdfmarginright)|
||[markdown-pdf.margin.left](#markdown-pdfmarginleft)|
|[PNG JPEG options](#png-jpeg-options)|[markdown-pdf.quality](#markdown-pdfquality)|
||[markdown-pdf.clip.x](#markdown-pdfclipx)|
||[markdown-pdf.clip.y](#markdown-pdfclipy)|
||[markdown-pdf.clip.width](#markdown-pdfclipwidth)|
||[markdown-pdf.clip.height](#markdown-pdfclipheight)|
||[markdown-pdf.omitBackground](#markdown-pdfomitbackground)|
|[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)|
|Category|Option name|[Configuration scope](https://code.visualstudio.com/api/references/contribution-points#Configuration-property-schema)|
|:---|:---|:---|
|[Save options](#save-options)|[markdown-pdf.type](#markdown-pdftype)| |
||[markdown-pdf.convertOnSave](#markdown-pdfconvertonsave)| |
||[markdown-pdf.convertOnSaveExclude](#markdown-pdfconvertonsaveexclude)| |
||[markdown-pdf.outputDirectory](#markdown-pdfoutputdirectory)| |
||[markdown-pdf.outputDirectoryRelativePathFile](#markdown-pdfoutputdirectoryrelativepathfile)| |
|[Styles options](#styles-options)|[markdown-pdf.styles](#markdown-pdfstyles)| |
||[markdown-pdf.stylesRelativePathFile](#markdown-pdfstylesrelativepathfile)| |
||[markdown-pdf.includeDefaultStyles](#markdown-pdfincludedefaultstyles)| |
|[Syntax highlight options](#syntax-highlight-options)|[markdown-pdf.highlight](#markdown-pdfhighlight)| |
||[markdown-pdf.highlightStyle](#markdown-pdfhighlightstyle)| |
|[Markdown options](#markdown-options)|[markdown-pdf.breaks](#markdown-pdfbreaks)| |
|[Emoji options](#emoji-options)|[markdown-pdf.emoji](#markdown-pdfemoji)| |
|[Configuration options](#configuration-options)|[markdown-pdf.executablePath](#markdown-pdfexecutablepath)| |
|[Common Options](#common-options)|[markdown-pdf.scale](#markdown-pdfscale)| |
|[PDF options](#pdf-options)|[markdown-pdf.displayHeaderFooter](#markdown-pdfdisplayheaderfooter)|resource|
||[markdown-pdf.headerTemplate](#markdown-pdfheadertemplate)|resource|
||[markdown-pdf.footerTemplate](#markdown-pdffootertemplate)|resource|
||[markdown-pdf.printBackground](#markdown-pdfprintbackground)|resource|
||[markdown-pdf.orientation](#markdown-pdforientation)|resource|
||[markdown-pdf.pageRanges](#markdown-pdfpageranges)|resource|
||[markdown-pdf.format](#markdown-pdfformat)|resource|
||[markdown-pdf.width](#markdown-pdfwidth)|resource|
||[markdown-pdf.height](#markdown-pdfheight)|resource|
||[markdown-pdf.margin.top](#markdown-pdfmargintop)|resource|
||[markdown-pdf.margin.bottom](#markdown-pdfmarginbottom)|resource|
||[markdown-pdf.margin.right](#markdown-pdfmarginright)|resource|
||[markdown-pdf.margin.left](#markdown-pdfmarginleft)|resource|
|[PNG JPEG options](#png-jpeg-options)|[markdown-pdf.quality](#markdown-pdfquality)| |
||[markdown-pdf.clip.x](#markdown-pdfclipx)| |
||[markdown-pdf.clip.y](#markdown-pdfclipy)| |
||[markdown-pdf.clip.width](#markdown-pdfclipwidth)| |
||[markdown-pdf.clip.height](#markdown-pdfclipheight)| |
||[markdown-pdf.omitBackground](#markdown-pdfomitbackground)| |
|[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)| |

### Save options

Expand Down
76 changes: 38 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,44 +183,44 @@ If the download is not successful or you want to avoid downloading every time yo

### List

|Category| Option name|
|:---|:---|
|[Save options](#save-options)|[markdown-pdf.type](#markdown-pdftype)|
||[markdown-pdf.convertOnSave](#markdown-pdfconvertonsave)|
||[markdown-pdf.convertOnSaveExclude](#markdown-pdfconvertonsaveexclude)|
||[markdown-pdf.outputDirectory](#markdown-pdfoutputdirectory)|
||[markdown-pdf.outputDirectoryRelativePathFile](#markdown-pdfoutputdirectoryrelativepathfile)|
|[Styles options](#styles-options)|[markdown-pdf.styles](#markdown-pdfstyles)|
||[markdown-pdf.stylesRelativePathFile](#markdown-pdfstylesrelativepathfile)|
||[markdown-pdf.includeDefaultStyles](#markdown-pdfincludedefaultstyles)|
|[Syntax highlight options](#syntax-highlight-options)|[markdown-pdf.highlight](#markdown-pdfhighlight)|
||[markdown-pdf.highlightStyle](#markdown-pdfhighlightstyle)|
|[Markdown options](#markdown-options)|[markdown-pdf.breaks](#markdown-pdfbreaks)|
|[Emoji options](#emoji-options)|[markdown-pdf.emoji](#markdown-pdfemoji)|
|[Configuration options](#configuration-options)|[markdown-pdf.executablePath](#markdown-pdfexecutablepath)|
|[Common Options](#common-options)|[markdown-pdf.scale](#markdown-pdfscale)|
|[PDF options](#pdf-options)|[markdown-pdf.displayHeaderFooter](#markdown-pdfdisplayheaderfooter)|
||[markdown-pdf.headerTemplate](#markdown-pdfheadertemplate)|
||[markdown-pdf.footerTemplate](#markdown-pdffootertemplate)|
||[markdown-pdf.printBackground](#markdown-pdfprintbackground)|
||[markdown-pdf.orientation](#markdown-pdforientation)|
||[markdown-pdf.pageRanges](#markdown-pdfpageranges)|
||[markdown-pdf.format](#markdown-pdfformat)|
||[markdown-pdf.width](#markdown-pdfwidth)|
||[markdown-pdf.height](#markdown-pdfheight)|
||[markdown-pdf.margin.top](#markdown-pdfmargintop)|
||[markdown-pdf.margin.bottom](#markdown-pdfmarginbottom)|
||[markdown-pdf.margin.right](#markdown-pdfmarginright)|
||[markdown-pdf.margin.left](#markdown-pdfmarginleft)|
|[PNG JPEG options](#png-jpeg-options)|[markdown-pdf.quality](#markdown-pdfquality)|
||[markdown-pdf.clip.x](#markdown-pdfclipx)|
||[markdown-pdf.clip.y](#markdown-pdfclipy)|
||[markdown-pdf.clip.width](#markdown-pdfclipwidth)|
||[markdown-pdf.clip.height](#markdown-pdfclipheight)|
||[markdown-pdf.omitBackground](#markdown-pdfomitbackground)|
|[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)|
|Category|Option name|[Configuration scope](https://code.visualstudio.com/api/references/contribution-points#Configuration-property-schema)|
|:---|:---|:---|
|[Save options](#save-options)|[markdown-pdf.type](#markdown-pdftype)| |
||[markdown-pdf.convertOnSave](#markdown-pdfconvertonsave)| |
||[markdown-pdf.convertOnSaveExclude](#markdown-pdfconvertonsaveexclude)| |
||[markdown-pdf.outputDirectory](#markdown-pdfoutputdirectory)| |
||[markdown-pdf.outputDirectoryRelativePathFile](#markdown-pdfoutputdirectoryrelativepathfile)| |
|[Styles options](#styles-options)|[markdown-pdf.styles](#markdown-pdfstyles)| |
||[markdown-pdf.stylesRelativePathFile](#markdown-pdfstylesrelativepathfile)| |
||[markdown-pdf.includeDefaultStyles](#markdown-pdfincludedefaultstyles)| |
|[Syntax highlight options](#syntax-highlight-options)|[markdown-pdf.highlight](#markdown-pdfhighlight)| |
||[markdown-pdf.highlightStyle](#markdown-pdfhighlightstyle)| |
|[Markdown options](#markdown-options)|[markdown-pdf.breaks](#markdown-pdfbreaks)| |
|[Emoji options](#emoji-options)|[markdown-pdf.emoji](#markdown-pdfemoji)| |
|[Configuration options](#configuration-options)|[markdown-pdf.executablePath](#markdown-pdfexecutablepath)| |
|[Common Options](#common-options)|[markdown-pdf.scale](#markdown-pdfscale)| |
|[PDF options](#pdf-options)|[markdown-pdf.displayHeaderFooter](#markdown-pdfdisplayheaderfooter)|resource|
||[markdown-pdf.headerTemplate](#markdown-pdfheadertemplate)|resource|
||[markdown-pdf.footerTemplate](#markdown-pdffootertemplate)|resource|
||[markdown-pdf.printBackground](#markdown-pdfprintbackground)|resource|
||[markdown-pdf.orientation](#markdown-pdforientation)|resource|
||[markdown-pdf.pageRanges](#markdown-pdfpageranges)|resource|
||[markdown-pdf.format](#markdown-pdfformat)|resource|
||[markdown-pdf.width](#markdown-pdfwidth)|resource|
||[markdown-pdf.height](#markdown-pdfheight)|resource|
||[markdown-pdf.margin.top](#markdown-pdfmargintop)|resource|
||[markdown-pdf.margin.bottom](#markdown-pdfmarginbottom)|resource|
||[markdown-pdf.margin.right](#markdown-pdfmarginright)|resource|
||[markdown-pdf.margin.left](#markdown-pdfmarginleft)|resource|
|[PNG JPEG options](#png-jpeg-options)|[markdown-pdf.quality](#markdown-pdfquality)| |
||[markdown-pdf.clip.x](#markdown-pdfclipx)| |
||[markdown-pdf.clip.y](#markdown-pdfclipy)| |
||[markdown-pdf.clip.width](#markdown-pdfclipwidth)| |
||[markdown-pdf.clip.height](#markdown-pdfclipheight)| |
||[markdown-pdf.omitBackground](#markdown-pdfomitbackground)| |
|[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)| |

### Save options

Expand Down
30 changes: 15 additions & 15 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,35 +407,35 @@ function exportPdf(data, filename, type, uri) {
if (type == 'pdf') {
// If width or height option is set, it overrides the format option.
// In order to set the default value of page size to A4, we changed it from the specification of puppeteer.
var width_option = vscode.workspace.getConfiguration('markdown-pdf')['width'] || '';
var height_option = vscode.workspace.getConfiguration('markdown-pdf')['height'] || '';
var width_option = vscode.workspace.getConfiguration('markdown-pdf', uri)['width'] || '';
var height_option = vscode.workspace.getConfiguration('markdown-pdf', uri)['height'] || '';
var format_option = '';
if (!width_option && !height_option) {
format_option = vscode.workspace.getConfiguration('markdown-pdf')['format'] || 'A4';
format_option = vscode.workspace.getConfiguration('markdown-pdf', uri)['format'] || 'A4';
}
var landscape_option;
if (vscode.workspace.getConfiguration('markdown-pdf')['orientation'] == 'landscape') {
if (vscode.workspace.getConfiguration('markdown-pdf', uri)['orientation'] == 'landscape') {
landscape_option = true;
} else {
landscape_option = false;
}
var options = {
path: exportFilename,
scale: vscode.workspace.getConfiguration('markdown-pdf')['scale'],
displayHeaderFooter: vscode.workspace.getConfiguration('markdown-pdf')['displayHeaderFooter'],
scale: vscode.workspace.getConfiguration('markdown-pdf', uri)['scale'],
displayHeaderFooter: vscode.workspace.getConfiguration('markdown-pdf', uri)['displayHeaderFooter'],
headerTemplate: vscode.workspace.getConfiguration('markdown-pdf', uri)['headerTemplate'] || '',
footerTemplate: vscode.workspace.getConfiguration('markdown-pdf')['footerTemplate'] || '',
printBackground: vscode.workspace.getConfiguration('markdown-pdf')['printBackground'],
footerTemplate: vscode.workspace.getConfiguration('markdown-pdf', uri)['footerTemplate'] || '',
printBackground: vscode.workspace.getConfiguration('markdown-pdf', uri)['printBackground'],
landscape: landscape_option,
pageRanges: vscode.workspace.getConfiguration('markdown-pdf')['pageRanges'] || '',
pageRanges: vscode.workspace.getConfiguration('markdown-pdf', uri)['pageRanges'] || '',
format: format_option,
width: vscode.workspace.getConfiguration('markdown-pdf')['width'] || '',
height: vscode.workspace.getConfiguration('markdown-pdf')['height'] || '',
width: vscode.workspace.getConfiguration('markdown-pdf', uri)['width'] || '',
height: vscode.workspace.getConfiguration('markdown-pdf', uri)['height'] || '',
margin: {
top: vscode.workspace.getConfiguration('markdown-pdf')['margin']['top'] || '',
right: vscode.workspace.getConfiguration('markdown-pdf')['margin']['right'] || '',
bottom: vscode.workspace.getConfiguration('markdown-pdf')['margin']['bottom'] || '',
left: vscode.workspace.getConfiguration('markdown-pdf')['margin']['left'] || ''
top: vscode.workspace.getConfiguration('markdown-pdf', uri)['margin']['top'] || '',
right: vscode.workspace.getConfiguration('markdown-pdf', uri)['margin']['right'] || '',
bottom: vscode.workspace.getConfiguration('markdown-pdf', uri)['margin']['bottom'] || '',
left: vscode.workspace.getConfiguration('markdown-pdf', uri)['margin']['left'] || ''
}
}
await page.pdf(options);
Expand Down
36 changes: 24 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@
"markdown-pdf.displayHeaderFooter": {
"type": "boolean",
"default": true,
"description": "pdf only. Display header and footer."
"description": "pdf only. Display header and footer.",
"scope": "resource"
},
"markdown-pdf.headerTemplate": {
"type": "string",
Expand All @@ -308,12 +309,14 @@
"markdown-pdf.footerTemplate": {
"type": "string",
"default": "<div style=\"font-size: 9px; margin: 0 auto;\"> <span class='pageNumber'></span> / <span class='totalPages'></span></div>",
"description": "pdf only. HTML template for the print footer."
"description": "pdf only. HTML template for the print footer.",
"scope": "resource"
},
"markdown-pdf.printBackground": {
"type": "boolean",
"default": true,
"description": "pdf only. Print background graphics."
"description": "pdf only. Print background graphics.",
"scope": "resource"
},
"markdown-pdf.orientation": {
"type": "string",
Expand All @@ -322,12 +325,14 @@
"landscape"
],
"default": "portrait",
"description": "pdf only. Paper orientation. portrait or landscape."
"description": "pdf only. Paper orientation. portrait or landscape.",
"scope": "resource"
},
"markdown-pdf.pageRanges": {
"type": "string",
"default": "",
"description": "pdf only. Paper ranges to print, e.g., '1-5, 8, 11-13'."
"description": "pdf only. Paper ranges to print, e.g., '1-5, 8, 11-13'.",
"scope": "resource"
},
"markdown-pdf.format": {
"type": "string",
Expand All @@ -345,37 +350,44 @@
"A6"
],
"default": "A4",
"description": "pdf only. Paper format [Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6]."
"description": "pdf only. Paper format [Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6].",
"scope": "resource"
},
"markdown-pdf.width": {
"type": "string",
"default": "",
"description": "pdf only. Paper width, accepts values labeled with units(mm, cm, in, px). If it is set, it overrides the markdown-pdf.format option."
"description": "pdf only. Paper width, accepts values labeled with units(mm, cm, in, px). If it is set, it overrides the markdown-pdf.format option.",
"scope": "resource"
},
"markdown-pdf.height": {
"type": "string",
"default": "",
"description": "pdf only. Paper height, accepts values labeled with units(mm, cm, in, px). If it is set, it overrides the markdown-pdf.format option."
"description": "pdf only. Paper height, accepts values labeled with units(mm, cm, in, px). If it is set, it overrides the markdown-pdf.format option.",
"scope": "resource"
},
"markdown-pdf.margin.top": {
"type": "string",
"default": "1.5cm",
"description": "Page Option. Border Top. units: mm, cm, in, px"
"description": "Page Option. Border Top. units: mm, cm, in, px",
"scope": "resource"
},
"markdown-pdf.margin.bottom": {
"type": "string",
"default": "1cm",
"description": "Page Option. Border bottom. units: mm, cm, in, px"
"description": "Page Option. Border bottom. units: mm, cm, in, px",
"scope": "resource"
},
"markdown-pdf.margin.right": {
"type": "string",
"default": "1cm",
"description": "Page Option. Border right. units: mm, cm, in, px"
"description": "Page Option. Border right. units: mm, cm, in, px",
"scope": "resource"
},
"markdown-pdf.margin.left": {
"type": "string",
"default": "1cm",
"description": "Page Option. Border left. units: mm, cm, in, px"
"description": "Page Option. Border left. units: mm, cm, in, px",
"scope": "resource"
},
"markdown-pdf.quality": {
"type": "number",
Expand Down

0 comments on commit 8b95d76

Please sign in to comment.