Skip to content

Commit ca817b6

Browse files
authored
Merge pull request #6969 from mcanouil/fix/mono-color-options
fix: header html tag for `monobackgroundcolor` + `monoforegroundcolor` option
2 parents 982ba6e + 93cd278 commit ca817b6

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

src/format/html/format-html-scss.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ function pandocVariablesToThemeDefaults(
481481
add(explicitVars, "font-family-base", metadata["mainfont"], asCssFont);
482482
add(explicitVars, "font-family-code", metadata["monofont"], asCssFont);
483483
add(explicitVars, "mono-background-color", metadata["monobackgroundcolor"]);
484+
add(explicitVars, "mono-foreground-color", metadata["monoforegroundcolor"]);
484485

485486
// Deal with sizes
486487
const explicitSizes = [

src/format/reveal/format-reveal-theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function pandocVariablesToRevealDefaults(
278278
asCssNumber,
279279
);
280280
add(explicitVars, "code-block-bg", metadata["monobackgroundcolor"]);
281-
281+
add(explicitVars, "code-block-color", metadata["monoforegroundcolor"]);
282282
// Non-pandoc options from front matter
283283
add(explicitVars, "code-block-height", metadata[kCodeBlockHeight]);
284284
return explicitVars;

src/resources/formats/html/bootstrap/_bootstrap-rules.scss

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -919,16 +919,6 @@ pre {
919919

920920
// Maps the pandoc 'monobackgroundcolor' to bootstrap
921921
// Note this only targets code outside of sourceCode blocks
922-
@if variable-exists(mono-background-color) {
923-
p code:not(.sourceCode),
924-
li code:not(.sourceCode),
925-
kbd,
926-
pre:not(.sourceCode),
927-
samp {
928-
background-color: $mono-background-color;
929-
padding: 0.2em;
930-
}
931-
}
932922

933923
p pre code:not(.sourceCode),
934924
li pre code:not(.sourceCode),
@@ -937,21 +927,38 @@ pre code:not(.sourceCode) {
937927
}
938928

939929
// Default padding if background is set
930+
h1 code:not(.sourceCode),
931+
h2 code:not(.sourceCode),
932+
h3 code:not(.sourceCode),
933+
h4 code:not(.sourceCode),
934+
h5 code:not(.sourceCode),
935+
h6 code:not(.sourceCode),
940936
p code:not(.sourceCode),
941937
li code:not(.sourceCode),
942-
td code:not(.sourceCode) {
938+
td code:not(.sourceCode),
939+
kbd,
940+
pre:not(.sourceCode),
941+
samp {
943942
@if variable-exists(mono-background-color) {
944943
background-color: $mono-background-color;
945944
} @else if variable-exists(code-bg) {
946945
background-color: $code-bg;
947946
}
948947

948+
@if variable-exists(mono-foreground-color) {
949+
color: $mono-foreground-color;
950+
} @else if variable-exists(code-color) {
951+
color: $code-color;
952+
}
953+
949954
@if variable-exists(code-padding) {
950955
padding: $code-padding;
951956
} @else if variable-exists(code-bg) {
952957
padding: 0.2em;
953958
} @else if variable-exists(mono-background-color) {
954959
padding: 0.2em;
960+
} @else if variable-exists(mono-foreground-color) {
961+
padding: 0.2em;
955962
}
956963
}
957964

src/resources/formats/html/pandoc/html.styles

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ code {
107107
$if(monobackgroundcolor)$
108108
background-color: $monobackgroundcolor$;
109109
padding: .2em .4em;
110+
$endif$
111+
$if(monoforegroundcolor)$
112+
color: $monoforegroundcolor$;
110113
$endif$
111114
font-size: 85%;
112115
margin: 0;
@@ -117,6 +120,9 @@ pre {
117120
$if(monobackgroundcolor)$
118121
background-color: $monobackgroundcolor$;
119122
padding: 1em;
123+
$endif$
124+
$if(monoforegroundcolor)$
125+
color: $monoforegroundcolor$;
120126
$endif$
121127
overflow: auto;
122128
}

src/resources/formats/html/pandoc/styles.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@
119119
$if(monobackgroundcolor)$
120120
background-color: $monobackgroundcolor$;
121121
padding: .2em .4em;
122+
$endif$
123+
$if(monoforegroundcolor)$
124+
color: $monoforegroundcolor$;
122125
$endif$
123126
font-size: 85%;
124127
margin: 0;
@@ -129,6 +132,9 @@
129132
$if(monobackgroundcolor)$
130133
background-color: $monobackgroundcolor$;
131134
padding: 1em;
135+
$endif$
136+
$if(monoforegroundcolor)$
137+
color: $monoforegroundcolor$;
132138
$endif$
133139
overflow: auto;
134140
}

src/resources/schema/document-colors.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
formats: [html, html4, html5, slidy, slideous, s5, dzslides]
2727
description: Sets the CSS `background-color` property on code elements and adds extra padding.
2828

29+
- name: monoforegroundcolor
30+
schema: string
31+
tags:
32+
formats: [html, html4, html5, slidy, slideous, s5, dzslides]
33+
description: Sets the CSS `color` property on code elements and adds extra padding.
34+
2935
- name: backgroundcolor
3036
schema: string
3137
tags:

0 commit comments

Comments
 (0)