Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
This is the appendix. The text is pink because of a project- and page-specific CSS override.

(This is an example of a page that is only in English and not made available for translation.)

The following chemical formulas should be subscripted automatically:
* CO2
* CF4
* CH4
* N2O
* NF3
* SF6
6 changes: 4 additions & 2 deletions packages/docs-builder/src/gen-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ export function writeErrorHtmlFile(context: Context, mdRelPath: string, error: E

const subscriptMap = new Map([
['CO2', 'CO<sub>2</sub>'],
['CF4', 'CF<sub>4</sub>'],
['CH4', 'CH<sub>4</sub>'],
['N2O', 'N<sub>2</sub>O'],
['NF3', 'NF<sub>3</sub>'],
Expand All @@ -556,8 +557,9 @@ const subscriptMap = new Map([
/**
* Replace non-subscript forms of common chemicals with their subscripted equivalent.
* For example, "CO2" will be converted to "CO<sub>2</sub>". This only handles
* the following common forms:
* the following common forms (defined in the map above):
* CO2
* CF4
* CH4
* N2O
* NF3
Expand All @@ -570,7 +572,7 @@ function subscriptify(s: string): string {
// XXX: Some historical graph images in the En-ROADS User Guide have
// {CO2,CH4,N2O} in the file name, so this regex is set up to avoid
// converting those filenames
return s.replace(/(Hist_)?(CO2|CH4|N2O|NF3|SF6)/g, (m, m1, m2) => {
return s.replace(/(Hist_)?(CO2|CF4|CH4|N2O|NF3|SF6)/g, (m, m1, m2) => {
if (m1) {
return m
} else {
Expand Down