From 22e082e9c3f97d7f56a57fe93c3dbe8ae9df8b7c Mon Sep 17 00:00:00 2001 From: Chris Campbell Date: Thu, 8 Jun 2023 15:29:17 -0700 Subject: [PATCH 1/3] fix: include CF4 in list of automatically subscripted chemicals --- packages/docs-builder/src/gen-html.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/docs-builder/src/gen-html.ts b/packages/docs-builder/src/gen-html.ts index 2ec9ea8..d1ea138 100644 --- a/packages/docs-builder/src/gen-html.ts +++ b/packages/docs-builder/src/gen-html.ts @@ -547,6 +547,7 @@ export function writeErrorHtmlFile(context: Context, mdRelPath: string, error: E const subscriptMap = new Map([ ['CO2', 'CO2'], + ['CF4', 'CF4'], ['CH4', 'CH4'], ['N2O', 'N2O'], ['NF3', 'NF3'], @@ -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 "CO2". This only handles - * the following common forms: + * the following common forms (defined in the map above): * CO2 + * CF4 * CH4 * N2O * NF3 From 8c7b704e667e0b81510b72b738c6f3642ab90a3f Mon Sep 17 00:00:00 2001 From: Chris Campbell Date: Thu, 8 Jun 2023 15:34:17 -0700 Subject: [PATCH 2/3] fix: include CF4 in regex --- packages/docs-builder/src/gen-html.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docs-builder/src/gen-html.ts b/packages/docs-builder/src/gen-html.ts index d1ea138..d5d5a39 100644 --- a/packages/docs-builder/src/gen-html.ts +++ b/packages/docs-builder/src/gen-html.ts @@ -572,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 { From 062b2d6278297148491cd1d41f4ea8e1261678c1 Mon Sep 17 00:00:00 2001 From: Chris Campbell Date: Thu, 8 Jun 2023 15:34:36 -0700 Subject: [PATCH 3/3] fix: add auto-subscript example --- .../sample-docs/projects/sample-guide/content/appendix.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/sample-docs/projects/sample-guide/content/appendix.md b/examples/sample-docs/projects/sample-guide/content/appendix.md index 29b5efc..bd1f187 100644 --- a/examples/sample-docs/projects/sample-guide/content/appendix.md +++ b/examples/sample-docs/projects/sample-guide/content/appendix.md @@ -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