Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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 src/format/html/format-html-scss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ function pandocVariablesToThemeDefaults(
add(explicitVars, "font-family-base", metadata["mainfont"], asCssFont);
add(explicitVars, "font-family-code", metadata["monofont"], asCssFont);
add(explicitVars, "mono-background-color", metadata["monobackgroundcolor"]);
add(explicitVars, "mono-foreground-color", metadata["monoforegroundcolor"]);

// Deal with sizes
const explicitSizes = [
Expand Down
1 change: 1 addition & 0 deletions src/format/reveal/format-reveal-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ function pandocVariablesToRevealDefaults(
asCssNumber,
);
add(explicitVars, "code-block-bg", metadata["monobackgroundcolor"]);
add(explicitVars, "code-block-color", metadata["monoforegroundcolor"]);
return explicitVars;
}

Expand Down
29 changes: 18 additions & 11 deletions src/resources/formats/html/bootstrap/_bootstrap-rules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -916,33 +916,40 @@ pre {

// Maps the pandoc 'monobackgroundcolor' to bootstrap
// Note this only targets code outside of sourceCode blocks
@if variable-exists(mono-background-color) {
p code:not(.sourceCode),
li code:not(.sourceCode),
kbd,
pre:not(.sourceCode),
samp {
background-color: $mono-background-color;
padding: 0.2em;
}
}

// Default padding if background is set
h1 code:not(.sourceCode),
h2 code:not(.sourceCode),
h3 code:not(.sourceCode),
h4 code:not(.sourceCode),
h5 code:not(.sourceCode),
h6 code:not(.sourceCode),
p code:not(.sourceCode),
li code:not(.sourceCode),
td code:not(.sourceCode) {
td code:not(.sourceCode),
kbd,
pre:not(.sourceCode),
samp {
@if variable-exists(mono-background-color) {
background-color: $mono-background-color;
} @else if variable-exists(code-bg) {
background-color: $code-bg;
}

@if variable-exists(mono-foreground-color) {
color: $mono-foreground-color;
} @else if variable-exists(code-color) {
color: $code-color;
}

@if variable-exists(code-padding) {
padding: $code-padding;
} @else if variable-exists(code-bg) {
padding: 0.2em;
} @else if variable-exists(mono-background-color) {
padding: 0.2em;
} @else if variable-exists(mono-foreground-color) {
padding: 0.2em;
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/resources/formats/html/pandoc/html.styles
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This files is directly from Pandoc templates (https://github.com/jgm/pandoc/blob/49e64c1451b9933a025d059f7dae287788c7d1cc/data/templates/styles.html), and monobackgroundcolor is one of Pandoc's variable for HTML (https://pandoc.org/MANUAL.html#variables-for-html)

monoforegroundcolor is not. So it will require to patch the file at each update.

Also this part of the style file is used only when document-css variables is activated. I believe this is only with theme: pandoc in Quarto.

Do we really want to add this monoforegroundcolor support for non bootstrap document ?

If we think this is desired, I think we should do a PR or feature request in Pandoc to add it there for future version (so that no patch is needed on our side)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this was why at first it was two PRs to get reviews.
This PRs mostly serves as a discussion point for this.

Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ code {
$if(monobackgroundcolor)$
background-color: $monobackgroundcolor$;
padding: .2em .4em;
$endif$
$if(monoforegroundcolor)$
color: $monoforegroundcolor$;
$endif$
font-size: 85%;
margin: 0;
Expand All @@ -117,6 +120,9 @@ pre {
$if(monobackgroundcolor)$
background-color: $monobackgroundcolor$;
padding: 1em;
$endif$
$if(monoforegroundcolor)$
color: $monoforegroundcolor$;
$endif$
overflow: auto;
}
Expand Down
6 changes: 6 additions & 0 deletions src/resources/formats/html/pandoc/styles.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
$if(monobackgroundcolor)$
background-color: $monobackgroundcolor$;
padding: .2em .4em;
$endif$
$if(monoforegroundcolor)$
color: $monoforegroundcolor$;
$endif$
font-size: 85%;
margin: 0;
Expand All @@ -129,6 +132,9 @@
$if(monobackgroundcolor)$
background-color: $monobackgroundcolor$;
padding: 1em;
$endif$
$if(monoforegroundcolor)$
color: $monoforegroundcolor$;
$endif$
overflow: auto;
}
Expand Down
6 changes: 6 additions & 0 deletions src/resources/schema/document-colors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
formats: [html, html4, html5, slidy, slideous, s5, dzslides]
description: Sets the CSS `background-color` property on code elements and adds extra padding.

- name: monoforegroundcolor
schema: string
tags:
formats: [html, html4, html5, slidy, slideous, s5, dzslides]
description: Sets the CSS `color` property on code elements and adds extra padding.

- name: backgroundcolor
schema: string
tags:
Expand Down