Skip to content

Commit

Permalink
added settings for controlling CSS precedence; document CSS now has p…
Browse files Browse the repository at this point in the history
…recedence by default (#14)
  • Loading branch information
gpoore committed Dec 4, 2022
1 parent 9f212fe commit 56938e9
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 6 deletions.
13 changes: 13 additions & 0 deletions 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
Expand Down
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion package.json
Expand Up @@ -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)",
Expand Down Expand Up @@ -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",
Expand Down
21 changes: 18 additions & 3 deletions src/preview_panel.ts
Expand Up @@ -99,6 +99,7 @@ export default class PreviewPanel implements vscode.Disposable {
// Subprocess
// ----------
pandocPreviewArgs: Array<string>;
pandocCssArgs: Array<string>;
pandocShowRawArgs: Array<string>;
pandocWithCodebraidOutputArgs: Array<string>;
pandocExportArgs: Array<string>;
Expand Down Expand Up @@ -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}"`,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 56938e9

Please sign in to comment.