diff --git a/CHANGELOG.md b/CHANGELOG.md index a9ab020..25d0f62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,19 @@ # Change Log + +## v0.10.0 (dev) + +* Added new settings `codebraid.preview.css.useDefault` and + `codebraid.preview.css.overrideDefault` for controlling whether the default + preview CSS is loaded and whether it is overridden by document CSS. + Document CSS now has precedence by default (#14). + +* A Codebraid Preview defaults file now has precedence over the extension's + Pandoc settings. + + + ## v0.9.0 (2022-07-29) * The preview Pandoc AST is now preprocessed before any user filters are diff --git a/README.md b/README.md index 745fb60..9198f17 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,12 @@ example, in a Lua filter these nodes can be detected by checking ## Extension settings +* `codebraid.preview.css.overrideDefault` [`true`]: Whether document CSS + overrides the preview's default CSS (determines which is loaded last). + +* `codebraid.preview.css.useDefault` [`true`]: Whether the preview's default + CSS is used. + * `codebraid.preview.minBuildInterval` [`1000`]: Minimum interval between document builds in milliseconds. Builds only occur when there are changes. diff --git a/package-lock.json b/package-lock.json index 4a59547..0c51b02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codebraid-preview", - "version": "0.9.0", + "version": "0.10.0-dev1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "codebraid-preview", - "version": "0.9.0", + "version": "0.10.0-dev1", "license": "See license in LICENSE.txt (BSD 3-Clause except as noted otherwise)", "dependencies": { "@types/js-yaml": "^4.0.5", diff --git a/package.json b/package.json index 8312ef9..2e5a900 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "codebraid-preview", "displayName": "Codebraid Preview", "description": "Preview Markdown documents with Pandoc. Optionally execute code blocks and inline code with Codebraid, using Jupyter kernels or its built-in code execution system.", - "version": "0.9.0", + "version": "0.10.0-dev1", "publisher": "gpoore", "homepage": "https://github.com/gpoore/codebraid-preview-vscode", "license": "See license in LICENSE.txt (BSD 3-Clause except as noted otherwise)", @@ -76,6 +76,16 @@ "default": true, "description": "Scroll editor to sync with preview" }, + "codebraid.preview.css.useDefault": { + "type": "boolean", + "default": true, + "description": "Whether the preview's default CSS is used" + }, + "codebraid.preview.css.overrideDefault": { + "type": "boolean", + "default": true, + "description": "Whether document CSS overrides the preview's default CSS (determines which is loaded last)" + }, "codebraid.preview.pandoc.fromFormat": { "type": "string", "default": "commonmark_x", diff --git a/src/preview_panel.ts b/src/preview_panel.ts index 81cc455..91dc3e8 100644 --- a/src/preview_panel.ts +++ b/src/preview_panel.ts @@ -99,6 +99,7 @@ export default class PreviewPanel implements vscode.Disposable { // Subprocess // ---------- pandocPreviewArgs: Array; + pandocCssArgs: Array; pandocShowRawArgs: Array; pandocWithCodebraidOutputArgs: Array; pandocExportArgs: Array; @@ -226,10 +227,12 @@ export default class PreviewPanel implements vscode.Disposable { this.pandocPreviewArgs = [ `--standalone`, `--lua-filter="${this.resourcePaths.pandocSourcePosSyncFilter}"`, + `--katex=${this.resourceWebviewUris.katex}/`, + ]; + this.pandocCssArgs = [ `--css=${this.resourceWebviewUris.vscodeCss}`, `--css=${this.resourceWebviewUris.vscodeCodicon}`, `--css=${this.resourceWebviewUris.codebraidCss}`, - `--katex=${this.resourceWebviewUris.katex}/`, ]; this.pandocShowRawArgs = [ `--lua-filter="${this.resourcePaths.pandocShowRawFilter}"`, @@ -929,10 +932,16 @@ ${message} if (fromFormatIsCommonmark && (defaultsFileName || normalizedConfigPandocOptions.length > 0)) { args.push(...['--lua-filter', `"${this.resourcePaths.pandocSourcePosPreprocFilter}"`]); } + if (this.extension.config.css.useDefault && this.extension.config.css.overrideDefault) { + args.push(...this.pandocCssArgs); + } + args.push(...normalizedConfigPandocOptions); if (defaultsFileName) { args.push(...['--defaults', `"${defaultsFileName}"`]); } - args.push(...normalizedConfigPandocOptions); + if (this.extension.config.css.useDefault && !this.extension.config.css.overrideDefault) { + args.push(...this.pandocCssArgs); + } args.push(...this.pandocPreviewArgs); if (this.extension.config.pandoc.showRaw) { args.push(...this.pandocShowRawArgs); @@ -1273,10 +1282,16 @@ ${message} if (noExecute) { args.push('--no-execute'); } + if (this.extension.config.css.useDefault && this.extension.config.css.overrideDefault) { + args.push(...this.pandocCssArgs); + } + args.push(...normalizedConfigPandocOptions); if (defaultsFileName) { args.push(...['--defaults', `"${defaultsFileName}"`]); } - args.push(...normalizedConfigPandocOptions); + if (this.extension.config.css.useDefault && !this.extension.config.css.overrideDefault) { + args.push(...this.pandocCssArgs); + } // If Codebraid adds a --pre-filter or similar option, that would need // to be handled here. args.push(...this.pandocPreviewArgs);