Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add print.enableCheckBoxes config option #962

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ Tip: also support the option `completion.root`
| `markdown.extension.print.onFileSave` | `false` | Print to HTML on file save |
| `markdown.extension.print.theme` | `light` | Theme of the exported HTML |
| `markdown.extension.print.validateUrls` | `true` | Enable/disable URL validation when printing |
| `markdown.extension.print.enableCheckBoxes` | `false` | Enable/disable The checkboxes of task lists |
| `markdown.extension.syntax.decorations` | `true` | Add decorations to ~~strikethrough~~ and `code span` |
| `markdown.extension.syntax.decorationFileSizeLimit` | 50000 | Don't render syntax decorations if a file is larger than this size (in byte/B) |
| `markdown.extension.syntax.plainTheme` | `false` | A distraction-free theme |
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@
"default": true,
"description": "%config.print.includeVscodeStylesheets%"
},
"markdown.extension.print.enableCheckBoxes": {
"type": "boolean",
"default": false,
"description": "%config.print.enableCheckBoxes%"
},
"markdown.extension.print.onFileSave": {
"type": "boolean",
"default": false,
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"config.print.absoluteImgPath.description": "Convert image path to absolute path.",
"config.print.imgToBase64.description": "Convert images to base64 when printing to HTML.",
"config.print.includeVscodeStylesheets": "Include VS Code's basic Markdown styles so that the exported HTML looks similar as inside VS Code.",
"config.print.enableCheckBoxes": "Enable checkboxes in the exported HTML.",
"config.print.onFileSave.description": "Print current document to HTML when file is saved.",
"config.print.theme": "Theme of the exported HTML. Only affects code blocks.",
"config.print.validateUrls.description": "Enable/disable URL validation when printing.",
Expand Down
1 change: 1 addition & 0 deletions src/configuration/KnownKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type KnownKey =
| "print.absoluteImgPath"
| "print.imgToBase64"
| "print.includeVscodeStylesheets"
| "print.enableCheckBoxes"
| "print.onFileSave"
| "print.theme"
| "print.validateUrls"
Expand Down
6 changes: 5 additions & 1 deletion src/markdownEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ class MarkdownEngine implements IDynamicMarkdownEngine {
katexOptions['macros'] = userMacros;
}

let taskListOptions = {
enabled: vscode.workspace.getConfiguration('markdown.extension.print').get<boolean>('enableCheckBoxes', false)
};

md = new MarkdownIt({
html: true,
highlight: (str: string, lang?: string) => {
Expand All @@ -238,7 +242,7 @@ class MarkdownEngine implements IDynamicMarkdownEngine {

// contributions provided by this extension must be processed specially,
// since this extension may not finish activing when a engine is needed to be created.
md.use(mdtl).use(mdkt, katexOptions);
md.use(mdtl, taskListOptions).use(mdkt, katexOptions);

if (!vscode.workspace.getConfiguration('markdown.extension.print').get<boolean>('validateUrls', true)) {
md.validateLink = () => true;
Expand Down