From 9b9f2f7a8b864f2824ea306d658a4051dc357854 Mon Sep 17 00:00:00 2001 From: David Straka Date: Sun, 13 Mar 2022 21:01:26 +0100 Subject: [PATCH] Publish v0.7.0 [#55] --- CHANGELOG.md | 31 +++++ README.md | 1 + lib/core/navigation/navigation-subscriber.js | 5 +- lib/core/preview/preview-subscriber.js | 5 +- lib/template/all-renderers.js | 28 ++++- .../renderers/document-object/algorithm.d.ts | 13 ++ .../renderers/document-object/algorithm.js | 19 +++ .../document-object/basic-object.d.ts | 26 ++++ .../renderers/document-object/basic-object.js | 41 ++++++ .../renderers/document-object/corollary.d.ts | 16 ++- .../renderers/document-object/corollary.js | 24 ++-- .../renderers/document-object/default.d.ts | 1 + .../renderers/document-object/default.js | 1 + .../renderers/document-object/definition.d.ts | 16 ++- .../renderers/document-object/definition.js | 24 ++-- .../renderers/document-object/example.d.ts | 17 ++- .../renderers/document-object/example.js | 32 +++-- .../renderers/document-object/lemma.d.ts | 16 ++- .../renderers/document-object/lemma.js | 24 ++-- .../document-object/observation.d.ts | 13 ++ .../renderers/document-object/observation.js | 19 +++ .../renderers/document-object/proof.d.ts | 13 +- .../renderers/document-object/proof.js | 21 ++-- .../document-object/proposition.d.ts | 13 ++ .../renderers/document-object/proposition.js | 19 +++ .../renderers/document-object/question.d.ts | 3 + .../renderers/document-object/question.js | 32 ++++- .../renderers/document-object/remark.d.ts | 16 ++- .../renderers/document-object/remark.js | 24 ++-- .../renderers/document-object/solution.d.ts | 10 ++ .../renderers/document-object/solution.js | 16 +++ .../renderers/document-object/table.d.ts | 13 +- .../renderers/document-object/table.js | 21 ++-- .../renderers/document-object/theorem.d.ts | 16 ++- .../renderers/document-object/theorem.js | 24 ++-- .../renderers/document-object/warning.d.ts | 13 ++ .../renderers/document-object/warning.js | 19 +++ lib/template/renderers/inner-env/small.d.ts | 10 ++ lib/template/renderers/inner-env/small.js | 16 +++ lib/template/renderers/inner-env/u.d.ts | 10 ++ lib/template/renderers/inner-env/u.js | 16 +++ .../outer-env/{align.d.ts => align-math.d.ts} | 0 .../outer-env/{align.js => align-math.js} | 0 .../renderers/outer-env/enumerate.d.ts | 9 ++ lib/template/renderers/outer-env/enumerate.js | 15 +++ .../renderers/outer-env/gather-math.d.ts | 10 ++ .../renderers/outer-env/gather-math.js | 18 +++ .../outer-env/{solution.d.ts => item.d.ts} | 4 +- lib/template/renderers/outer-env/item.js | 15 +++ lib/template/renderers/outer-env/itemize.d.ts | 9 ++ lib/template/renderers/outer-env/itemize.js | 15 +++ lib/template/renderers/outer-env/solution.js | 17 --- lib/template/variants.js | 14 ++- lib/util/html-components/info-block.d.ts | 3 +- lib/util/html-components/info-block.js | 6 +- lib/util/lists/styles.d.ts | 6 + lib/util/lists/styles.js | 10 ++ lib/wootom.d.ts | 6 + lib/wootom.js | 8 ++ package.json | 3 +- snippets/woo.cson | 93 ++++++++++++-- styles/general/blocks.less | 33 +++++ styles/general/caption.less | 5 + styles/general/error-details.less | 23 ++++ styles/general/error-inline.less | 10 ++ styles/general/figure.less | 15 +++ styles/general/footnote.less | 25 ++++ styles/general/tikz.less | 11 ++ styles/main.less | 119 +++--------------- styles/navigation/lists.less | 9 ++ styles/navigation/search.less | 12 ++ 71 files changed, 916 insertions(+), 304 deletions(-) create mode 100644 lib/template/renderers/document-object/algorithm.d.ts create mode 100644 lib/template/renderers/document-object/algorithm.js create mode 100644 lib/template/renderers/document-object/basic-object.d.ts create mode 100644 lib/template/renderers/document-object/basic-object.js create mode 100644 lib/template/renderers/document-object/observation.d.ts create mode 100644 lib/template/renderers/document-object/observation.js create mode 100644 lib/template/renderers/document-object/proposition.d.ts create mode 100644 lib/template/renderers/document-object/proposition.js create mode 100644 lib/template/renderers/document-object/solution.d.ts create mode 100644 lib/template/renderers/document-object/solution.js create mode 100644 lib/template/renderers/document-object/warning.d.ts create mode 100644 lib/template/renderers/document-object/warning.js create mode 100644 lib/template/renderers/inner-env/small.d.ts create mode 100644 lib/template/renderers/inner-env/small.js create mode 100644 lib/template/renderers/inner-env/u.d.ts create mode 100644 lib/template/renderers/inner-env/u.js rename lib/template/renderers/outer-env/{align.d.ts => align-math.d.ts} (100%) rename lib/template/renderers/outer-env/{align.js => align-math.js} (100%) create mode 100644 lib/template/renderers/outer-env/enumerate.d.ts create mode 100644 lib/template/renderers/outer-env/enumerate.js create mode 100644 lib/template/renderers/outer-env/gather-math.d.ts create mode 100644 lib/template/renderers/outer-env/gather-math.js rename lib/template/renderers/outer-env/{solution.d.ts => item.d.ts} (76%) create mode 100644 lib/template/renderers/outer-env/item.js create mode 100644 lib/template/renderers/outer-env/itemize.d.ts create mode 100644 lib/template/renderers/outer-env/itemize.js delete mode 100644 lib/template/renderers/outer-env/solution.js create mode 100644 lib/util/lists/styles.d.ts create mode 100644 lib/util/lists/styles.js create mode 100644 styles/general/blocks.less create mode 100644 styles/general/caption.less create mode 100644 styles/general/error-details.less create mode 100644 styles/general/error-inline.less create mode 100644 styles/general/figure.less create mode 100644 styles/general/footnote.less create mode 100644 styles/general/tikz.less create mode 100644 styles/navigation/lists.less create mode 100644 styles/navigation/search.less diff --git a/CHANGELOG.md b/CHANGELOG.md index 845cef2..417ea13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,29 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.7.0] (2022-03-13) + +### Added + +- New document objects: `.Algorithm`, `.Observation`, `.Proposition`, `.Solution`, and `.Warning` [[#51]] +- New inner environments: `.item`, `.small`, and `.underline` [[#46], [#50], [#52]] +- New outer environments: `.enumerate`, `.gather`, and `.itemize` [[#46], [#50], [#52]] +- Optionally update HTML preview and navigation only upon saving the file (not upon type) [[#45]] +- Rendering of the `star` metablock item on the `.Example` document object [[#51]] + +### Changed + +- Replaced the deprecated `.solution` outer environment with the new `solution` metablock item (newly available on the `.Question` document object) [[#51]] +- Tweaked and refactored stylesheets (most notable tweaks: colored document object titles, more subtle footnotes) [[#48], [#53]] + +### Removed + +- Support for the `title` metablock item on the `.Question` document object [[#51]] + +### Chores + +- Added the `clean` script [[#49]] + ## [0.6.1] (2021-06-24) ### Changed @@ -126,6 +149,7 @@ and this project adheres to - Set up linting with ESLint (and typescript-eslint/eslint-plugin) [[#10]] - Set up CI using GitHub Actions [[#6], [#7], [#9], [#11]] +[0.7.0]: https://github.com/davidstraka2/wootom/compare/v0.6.1-src...v0.7.0-src [0.6.1]: https://github.com/davidstraka2/wootom/compare/v0.6.0-src...v0.6.1-src [0.6.0]: https://github.com/davidstraka2/wootom/compare/v0.5.0-src...v0.6.0-src [0.5.0]: https://github.com/davidstraka2/wootom/compare/v0.4.0-src...v0.5.0-src @@ -133,6 +157,13 @@ and this project adheres to [0.3.0]: https://github.com/davidstraka2/wootom/compare/v0.2.0-src...v0.3.0-src [0.2.0]: https://github.com/davidstraka2/wootom/compare/v0.1.0-src...v0.2.0-src [0.1.0]: https://github.com/davidstraka2/wootom/releases/tag/v0.1.0-src +[#53]: https://github.com/davidstraka2/wootom/issues/53 +[#52]: https://github.com/davidstraka2/wootom/pull/52 +[#51]: https://github.com/davidstraka2/wootom/issues/51 +[#50]: https://github.com/davidstraka2/wootom/issues/50 +[#49]: https://github.com/davidstraka2/wootom/issues/49 +[#46]: https://github.com/davidstraka2/wootom/issues/46 +[#45]: https://github.com/davidstraka2/wootom/issues/45 [#42]: https://github.com/davidstraka2/wootom/issues/42 [#41]: https://github.com/davidstraka2/wootom/issues/41 [#39]: https://github.com/davidstraka2/wootom/issues/39 diff --git a/README.md b/README.md index becd9a7..917642d 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ mentioned dependencies. - `npm test` - Run package tests - `npm run build` - Build +- `npm run clean` - Clean up build output - `npm run format:check` - Check formatting - `npm run format:fix` - Fix formatting - `npm run lint:check` - Lint diff --git a/lib/core/navigation/navigation-subscriber.js b/lib/core/navigation/navigation-subscriber.js index 07b4cae..3dd7d8d 100644 --- a/lib/core/navigation/navigation-subscriber.js +++ b/lib/core/navigation/navigation-subscriber.js @@ -68,7 +68,10 @@ class NavigationSubscriber { return; } console.log('Wootom: Subscribing to new editor.'); - this.editorSubscriptions.add(editor.onDidSave(this.updateContent.bind(this)), editor.onDidStopChanging(this.updateContent.bind(this))); + this.editorSubscriptions.add(editor.onDidSave(this.updateContent.bind(this)), editor.onDidStopChanging(() => { + if (atom.config.get('wootom.updateOnType')) + this.updateContent(); + })); this.updateContent(); } } diff --git a/lib/core/preview/preview-subscriber.js b/lib/core/preview/preview-subscriber.js index a389e14..0674cfc 100644 --- a/lib/core/preview/preview-subscriber.js +++ b/lib/core/preview/preview-subscriber.js @@ -68,7 +68,10 @@ class PreviewSubscriber { return; } console.log('Wootom: Subscribing to new editor.'); - this.editorSubscriptions.add(editor.onDidSave(this.updateContent.bind(this)), editor.onDidStopChanging(this.updateContent.bind(this))); + this.editorSubscriptions.add(editor.onDidSave(this.updateContent.bind(this)), editor.onDidStopChanging(() => { + if (atom.config.get('wootom.updateOnType')) + this.updateContent(); + })); this.updateContent(); } } diff --git a/lib/template/all-renderers.js b/lib/template/all-renderers.js index 695cafe..51fed16 100644 --- a/lib/template/all-renderers.js +++ b/lib/template/all-renderers.js @@ -2,17 +2,22 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.registerTemplateRenderers = void 0; const core_1 = require("../core"); +const algorithm_1 = require("./renderers/document-object/algorithm"); const corollary_1 = require("./renderers/document-object/corollary"); const default_1 = require("./renderers/document-object/default"); const definition_1 = require("./renderers/document-object/definition"); const example_1 = require("./renderers/document-object/example"); const figure_1 = require("./renderers/document-object/figure"); const lemma_1 = require("./renderers/document-object/lemma"); +const observation_1 = require("./renderers/document-object/observation"); const proof_1 = require("./renderers/document-object/proof"); +const proposition_1 = require("./renderers/document-object/proposition"); const question_1 = require("./renderers/document-object/question"); const remark_1 = require("./renderers/document-object/remark"); +const solution_1 = require("./renderers/document-object/solution"); const table_1 = require("./renderers/document-object/table"); const theorem_1 = require("./renderers/document-object/theorem"); +const warning_1 = require("./renderers/document-object/warning"); const default_2 = require("./renderers/document-part/default"); const h1_1 = require("./renderers/document-part/h1"); const h2_1 = require("./renderers/document-part/h2"); @@ -27,6 +32,8 @@ const i_1 = require("./renderers/inner-env/i"); const inline_math_1 = require("./renderers/inner-env/inline-math"); const quoted_1 = require("./renderers/inner-env/quoted"); const reference_1 = require("./renderers/inner-env/reference"); +const small_1 = require("./renderers/inner-env/small"); +const u_1 = require("./renderers/inner-env/u"); const _index_1 = require("./renderers/inner-env/_index"); const _reference_1 = require("./renderers/inner-env/_reference"); const document_root_1 = require("./renderers/other/document-root"); @@ -34,16 +41,19 @@ const indented_block_1 = require("./renderers/other/indented-block"); const inline_math_2 = require("./renderers/other/inline-math"); const text_block_1 = require("./renderers/other/text-block"); const text_node_1 = require("./renderers/other/text-node"); -const align_1 = require("./renderers/outer-env/align"); +const align_math_1 = require("./renderers/outer-env/align-math"); const block_math_1 = require("./renderers/outer-env/block-math"); const caption_1 = require("./renderers/outer-env/caption"); const codeblock_1 = require("./renderers/outer-env/codeblock"); const default_4 = require("./renderers/outer-env/default"); +const enumerate_1 = require("./renderers/outer-env/enumerate"); +const gather_math_1 = require("./renderers/outer-env/gather-math"); const quote_1 = require("./renderers/outer-env/quote"); const sage_1 = require("./renderers/outer-env/sage"); -const solution_1 = require("./renderers/outer-env/solution"); const tabular_1 = require("./renderers/outer-env/tabular"); const tikz_1 = require("./renderers/outer-env/tikz"); +const item_1 = require("./renderers/outer-env/item"); +const itemize_1 = require("./renderers/outer-env/itemize"); function registerTemplateRenderers() { core_1.rendererRegistry.setRenderer(new document_root_1.DocumentRootRenderer()); core_1.rendererRegistry.setRenderer(new indented_block_1.IndentedBlockRenderer()); @@ -55,26 +65,34 @@ function registerTemplateRenderers() { core_1.rendererRegistry.setRenderer(new h2_1.DocumentPartH2Renderer()); core_1.rendererRegistry.setRenderer(new h3_1.DocumentPartH3Renderer()); core_1.rendererRegistry.setRenderer(new default_1.DefaultDocumentObjectRenderer()); + core_1.rendererRegistry.setRenderer(new algorithm_1.DocumentObjectAlgorithmRenderer()); core_1.rendererRegistry.setRenderer(new definition_1.DocumentObjectDefinitionRenderer()); core_1.rendererRegistry.setRenderer(new corollary_1.DocumentObjectCorollaryRenderer()); core_1.rendererRegistry.setRenderer(new lemma_1.DocumentObjectLemmaRenderer()); + core_1.rendererRegistry.setRenderer(new observation_1.DocumentObjectObservationRenderer()); + core_1.rendererRegistry.setRenderer(new proposition_1.DocumentObjectPropositionRenderer()); core_1.rendererRegistry.setRenderer(new theorem_1.DocumentObjectTheoremRenderer()); core_1.rendererRegistry.setRenderer(new proof_1.DocumentObjectProofRenderer()); core_1.rendererRegistry.setRenderer(new remark_1.DocumentObjectRemarkRenderer()); core_1.rendererRegistry.setRenderer(new example_1.DocumentObjectExampleRenderer()); core_1.rendererRegistry.setRenderer(new figure_1.DocumentObjectFigureRenderer()); core_1.rendererRegistry.setRenderer(new question_1.DocumentObjectQuestionRenderer()); + core_1.rendererRegistry.setRenderer(new solution_1.DocumentObjectSolutionRenderer()); core_1.rendererRegistry.setRenderer(new table_1.DocumentObjectTableRenderer()); + core_1.rendererRegistry.setRenderer(new warning_1.DocumentObjectWarningRenderer()); core_1.rendererRegistry.setRenderer(new default_4.DefaultOuterEnvRenderer()); - core_1.rendererRegistry.setRenderer(new align_1.OuterEnvAlignMathRenderer()); + core_1.rendererRegistry.setRenderer(new align_math_1.OuterEnvAlignMathRenderer()); core_1.rendererRegistry.setRenderer(new caption_1.OuterEnvCaptionRenderer()); core_1.rendererRegistry.setRenderer(new codeblock_1.OuterEnvCodeblockRenderer()); core_1.rendererRegistry.setRenderer(new block_math_1.OuterEnvBlockMathRenderer()); + core_1.rendererRegistry.setRenderer(new enumerate_1.OuterEnvEnumerateRenderer()); + core_1.rendererRegistry.setRenderer(new gather_math_1.OuterEnvGatherMathRenderer()); core_1.rendererRegistry.setRenderer(new sage_1.OuterEnvSageRenderer()); - core_1.rendererRegistry.setRenderer(new solution_1.OuterEnvSolutionRenderer()); core_1.rendererRegistry.setRenderer(new tabular_1.OuterEnvTabularRenderer()); core_1.rendererRegistry.setRenderer(new tikz_1.OuterEnvTikzRenderer()); core_1.rendererRegistry.setRenderer(new quote_1.OuterEnvQuoteRenderer()); + core_1.rendererRegistry.setRenderer(new item_1.OuterEnvItemRenderer()); + core_1.rendererRegistry.setRenderer(new itemize_1.OuterEnvItemizeRenderer()); core_1.rendererRegistry.setRenderer(new default_3.DefaultInnerEnvRenderer()); core_1.rendererRegistry.setRenderer(new cite_1.InnerEnvCiteRenderer()); core_1.rendererRegistry.setRenderer(new code_1.InnerEnvCodeRenderer()); @@ -85,6 +103,8 @@ function registerTemplateRenderers() { core_1.rendererRegistry.setRenderer(new b_1.InnerEnvBRenderer()); core_1.rendererRegistry.setRenderer(new quoted_1.InnerEnvQuotedRenderer()); core_1.rendererRegistry.setRenderer(new reference_1.InnerEnvReferenceRenderer()); + core_1.rendererRegistry.setRenderer(new small_1.InnerEnvSmallRenderer()); + core_1.rendererRegistry.setRenderer(new u_1.InnerEnvURenderer()); core_1.rendererRegistry.setRenderer(new _index_1.InnerEnvIndexRenderer()); core_1.rendererRegistry.setRenderer(new _reference_1.InnerEnvUReferenceRenderer()); } diff --git a/lib/template/renderers/document-object/algorithm.d.ts b/lib/template/renderers/document-object/algorithm.d.ts new file mode 100644 index 0000000..8ccbe86 --- /dev/null +++ b/lib/template/renderers/document-object/algorithm.d.ts @@ -0,0 +1,13 @@ +import { Renderer } from '../../../core/rendering/renderer'; +import { InfoBlockColors } from '../../../util/lists/styles'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the algorithm document object */ +export declare class DocumentObjectAlgorithmRenderer extends BasicObjectRenderer implements Renderer { + readonly abstractVariant = "algorithm"; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; + /** @override */ + protected titleBackgroundColor: InfoBlockColors; +} diff --git a/lib/template/renderers/document-object/algorithm.js b/lib/template/renderers/document-object/algorithm.js new file mode 100644 index 0000000..98c3dee --- /dev/null +++ b/lib/template/renderers/document-object/algorithm.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DocumentObjectAlgorithmRenderer = void 0; +const styles_1 = require("../../../util/lists/styles"); +const basic_object_1 = require("./basic-object"); +/** Renderer of the algorithm document object */ +class DocumentObjectAlgorithmRenderer extends basic_object_1.BasicObjectRenderer { + constructor() { + super(...arguments); + this.abstractVariant = 'algorithm'; + /** @override */ + this.title = 'Algorithm'; + /** @override */ + this.hasOptionalMetaTitle = true; + /** @override */ + this.titleBackgroundColor = styles_1.InfoBlockColors.Blue; + } +} +exports.DocumentObjectAlgorithmRenderer = DocumentObjectAlgorithmRenderer; diff --git a/lib/template/renderers/document-object/basic-object.d.ts b/lib/template/renderers/document-object/basic-object.d.ts new file mode 100644 index 0000000..2c61513 --- /dev/null +++ b/lib/template/renderers/document-object/basic-object.d.ts @@ -0,0 +1,26 @@ +import { ASTNode } from '../../../core/ast/ast-node'; +import { Renderer } from '../../../core/rendering/renderer'; +import { RenderingManager } from '../../../core/rendering/rendering-manager'; +import { WooElementKind } from '../../../util/types/woo'; +/** Partially implemented renderer for the most comon document objects */ +export declare abstract class BasicObjectRenderer implements Pick, 'render' | 'kind'> { + readonly kind: WooElementKind; + /** The title of the document object */ + protected abstract title: string; + /** + * Whether the document object can optionally have the title metablock item + */ + protected hasOptionalMetaTitle: boolean; + protected titleBackgroundColor?: string; + render(renderingManager: RenderingManager, astNode: ASTNode): Node; + /** + * Customize the title of the document object by appending the contents of + * the optional title metablock item, if applicable. + * + * @param title The title to customize + * @param astNode The AST node of the document object + * @returns The customized title + */ + protected customizeTitle(title: string, astNode: ASTNode): string; + private appendMetaTitle; +} diff --git a/lib/template/renderers/document-object/basic-object.js b/lib/template/renderers/document-object/basic-object.js new file mode 100644 index 0000000..f030419 --- /dev/null +++ b/lib/template/renderers/document-object/basic-object.js @@ -0,0 +1,41 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BasicObjectRenderer = void 0; +const info_block_1 = require("../../../util/html-components/info-block"); +/** Partially implemented renderer for the most comon document objects */ +class BasicObjectRenderer { + constructor() { + this.kind = 'DocumentObject'; + /** + * Whether the document object can optionally have the title metablock item + */ + this.hasOptionalMetaTitle = false; + } + render(renderingManager, astNode) { + return info_block_1.infoBlockComponent({ + title: this.customizeTitle(this.title, astNode), + children: [renderingManager.render(...astNode.children)], + titleBackgroundColor: this.titleBackgroundColor, + }); + } + /** + * Customize the title of the document object by appending the contents of + * the optional title metablock item, if applicable. + * + * @param title The title to customize + * @param astNode The AST node of the document object + * @returns The customized title + */ + customizeTitle(title, astNode) { + return this.appendMetaTitle(title, astNode); + } + appendMetaTitle(title, astNode) { + if (!this.hasOptionalMetaTitle) + return title; + const titleMetadata = astNode.getMetadata('title'); + if (typeof titleMetadata === 'string') + title += `: ${titleMetadata}`; + return title; + } +} +exports.BasicObjectRenderer = BasicObjectRenderer; diff --git a/lib/template/renderers/document-object/corollary.d.ts b/lib/template/renderers/document-object/corollary.d.ts index 915c573..1e8a8eb 100644 --- a/lib/template/renderers/document-object/corollary.d.ts +++ b/lib/template/renderers/document-object/corollary.d.ts @@ -1,9 +1,13 @@ -import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; -import { RenderingManager } from '../../../core/rendering/rendering-manager'; -import { WooElementKind } from '../../../util/types/woo'; -export declare class DocumentObjectCorollaryRenderer implements Renderer { - readonly kind: WooElementKind; +import { InfoBlockColors } from '../../../util/lists/styles'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the corollary document object */ +export declare class DocumentObjectCorollaryRenderer extends BasicObjectRenderer implements Renderer { readonly abstractVariant = "corollary"; - render(renderingManager: RenderingManager, astNode: ASTNode): Node; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; + /** @override */ + protected titleBackgroundColor: InfoBlockColors; } diff --git a/lib/template/renderers/document-object/corollary.js b/lib/template/renderers/document-object/corollary.js index f170b19..34176b9 100644 --- a/lib/template/renderers/document-object/corollary.js +++ b/lib/template/renderers/document-object/corollary.js @@ -1,21 +1,19 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentObjectCorollaryRenderer = void 0; -const info_block_1 = require("../../../util/html-components/info-block"); -class DocumentObjectCorollaryRenderer { +const styles_1 = require("../../../util/lists/styles"); +const basic_object_1 = require("./basic-object"); +/** Renderer of the corollary document object */ +class DocumentObjectCorollaryRenderer extends basic_object_1.BasicObjectRenderer { constructor() { - this.kind = 'DocumentObject'; + super(...arguments); this.abstractVariant = 'corollary'; - } - render(renderingManager, astNode) { - let title = 'Corollary'; - const titleMetadata = astNode.getMetadata('title'); - if (typeof titleMetadata === 'string') - title += `: ${titleMetadata}`; - return info_block_1.infoBlockComponent({ - title, - children: [renderingManager.render(...astNode.children)], - }); + /** @override */ + this.title = 'Corollary'; + /** @override */ + this.hasOptionalMetaTitle = true; + /** @override */ + this.titleBackgroundColor = styles_1.InfoBlockColors.Blue; } } exports.DocumentObjectCorollaryRenderer = DocumentObjectCorollaryRenderer; diff --git a/lib/template/renderers/document-object/default.d.ts b/lib/template/renderers/document-object/default.d.ts index 11aeb25..3e9979a 100644 --- a/lib/template/renderers/document-object/default.d.ts +++ b/lib/template/renderers/document-object/default.d.ts @@ -2,6 +2,7 @@ import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; import { RenderingManager } from '../../../core/rendering/rendering-manager'; import { WooElementKind } from '../../../util/types/woo'; +/** Default renderer of document objects */ export declare class DefaultDocumentObjectRenderer implements Renderer { readonly kind: WooElementKind; render(renderingManager: RenderingManager, astNode: ASTNode): Node; diff --git a/lib/template/renderers/document-object/default.js b/lib/template/renderers/document-object/default.js index 4790f02..6fb1b0d 100644 --- a/lib/template/renderers/document-object/default.js +++ b/lib/template/renderers/document-object/default.js @@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.DefaultDocumentObjectRenderer = void 0; const error_block_1 = require("../../../util/html-components/error-block"); +/** Default renderer of document objects */ class DefaultDocumentObjectRenderer { constructor() { this.kind = 'DocumentObject'; diff --git a/lib/template/renderers/document-object/definition.d.ts b/lib/template/renderers/document-object/definition.d.ts index f6a4800..e50d748 100644 --- a/lib/template/renderers/document-object/definition.d.ts +++ b/lib/template/renderers/document-object/definition.d.ts @@ -1,9 +1,13 @@ -import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; -import { RenderingManager } from '../../../core/rendering/rendering-manager'; -import { WooElementKind } from '../../../util/types/woo'; -export declare class DocumentObjectDefinitionRenderer implements Renderer { - readonly kind: WooElementKind; +import { InfoBlockColors } from '../../../util/lists/styles'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the definition document object */ +export declare class DocumentObjectDefinitionRenderer extends BasicObjectRenderer implements Renderer { readonly abstractVariant = "definition"; - render(renderingManager: RenderingManager, astNode: ASTNode): Node; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; + /** @override */ + protected titleBackgroundColor: InfoBlockColors; } diff --git a/lib/template/renderers/document-object/definition.js b/lib/template/renderers/document-object/definition.js index d921894..c978253 100644 --- a/lib/template/renderers/document-object/definition.js +++ b/lib/template/renderers/document-object/definition.js @@ -1,21 +1,19 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentObjectDefinitionRenderer = void 0; -const info_block_1 = require("../../../util/html-components/info-block"); -class DocumentObjectDefinitionRenderer { +const styles_1 = require("../../../util/lists/styles"); +const basic_object_1 = require("./basic-object"); +/** Renderer of the definition document object */ +class DocumentObjectDefinitionRenderer extends basic_object_1.BasicObjectRenderer { constructor() { - this.kind = 'DocumentObject'; + super(...arguments); this.abstractVariant = 'definition'; - } - render(renderingManager, astNode) { - let title = 'Definition'; - const titleMetadata = astNode.getMetadata('title'); - if (typeof titleMetadata === 'string') - title += `: ${titleMetadata}`; - return info_block_1.infoBlockComponent({ - title, - children: [renderingManager.render(...astNode.children)], - }); + /** @override */ + this.title = 'Definition'; + /** @override */ + this.hasOptionalMetaTitle = true; + /** @override */ + this.titleBackgroundColor = styles_1.InfoBlockColors.Green; } } exports.DocumentObjectDefinitionRenderer = DocumentObjectDefinitionRenderer; diff --git a/lib/template/renderers/document-object/example.d.ts b/lib/template/renderers/document-object/example.d.ts index 17ac7c0..ad87875 100644 --- a/lib/template/renderers/document-object/example.d.ts +++ b/lib/template/renderers/document-object/example.d.ts @@ -1,9 +1,16 @@ import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; -import { RenderingManager } from '../../../core/rendering/rendering-manager'; -import { WooElementKind } from '../../../util/types/woo'; -export declare class DocumentObjectExampleRenderer implements Renderer { - readonly kind: WooElementKind; +import { InfoBlockColors } from '../../../util/lists/styles'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the example document object */ +export declare class DocumentObjectExampleRenderer extends BasicObjectRenderer implements Renderer { readonly abstractVariant = "example"; - render(renderingManager: RenderingManager, astNode: ASTNode): Node; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; + /** @override */ + protected titleBackgroundColor: InfoBlockColors; + protected customizeTitle(title: string, astNode: ASTNode): string; + private starTitle; } diff --git a/lib/template/renderers/document-object/example.js b/lib/template/renderers/document-object/example.js index 0e6f66d..43e4952 100644 --- a/lib/template/renderers/document-object/example.js +++ b/lib/template/renderers/document-object/example.js @@ -1,21 +1,29 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentObjectExampleRenderer = void 0; -const info_block_1 = require("../../../util/html-components/info-block"); -class DocumentObjectExampleRenderer { +const styles_1 = require("../../../util/lists/styles"); +const basic_object_1 = require("./basic-object"); +/** Renderer of the example document object */ +class DocumentObjectExampleRenderer extends basic_object_1.BasicObjectRenderer { constructor() { - this.kind = 'DocumentObject'; + super(...arguments); this.abstractVariant = 'example'; + /** @override */ + this.title = 'Example'; + /** @override */ + this.hasOptionalMetaTitle = true; + /** @override */ + this.titleBackgroundColor = styles_1.InfoBlockColors.Orange; } - render(renderingManager, astNode) { - let title = 'Example'; - const titleMetadata = astNode.getMetadata('title'); - if (typeof titleMetadata === 'string') - title += `: ${titleMetadata}`; - return info_block_1.infoBlockComponent({ - title, - children: [renderingManager.render(...astNode.children)], - }); + customizeTitle(title, astNode) { + title = this.starTitle(title, astNode); + return super.customizeTitle(title, astNode); + } + starTitle(title, astNode) { + const starMetadata = astNode.getMetadata('star'); + if (starMetadata === true) + title = `⭐ ${title}`; + return title; } } exports.DocumentObjectExampleRenderer = DocumentObjectExampleRenderer; diff --git a/lib/template/renderers/document-object/lemma.d.ts b/lib/template/renderers/document-object/lemma.d.ts index d2fc9db..025f05a 100644 --- a/lib/template/renderers/document-object/lemma.d.ts +++ b/lib/template/renderers/document-object/lemma.d.ts @@ -1,9 +1,13 @@ -import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; -import { RenderingManager } from '../../../core/rendering/rendering-manager'; -import { WooElementKind } from '../../../util/types/woo'; -export declare class DocumentObjectLemmaRenderer implements Renderer { - readonly kind: WooElementKind; +import { InfoBlockColors } from '../../../util/lists/styles'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the lemma document object */ +export declare class DocumentObjectLemmaRenderer extends BasicObjectRenderer implements Renderer { readonly abstractVariant = "lemma"; - render(renderingManager: RenderingManager, astNode: ASTNode): Node; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; + /** @override */ + protected titleBackgroundColor: InfoBlockColors; } diff --git a/lib/template/renderers/document-object/lemma.js b/lib/template/renderers/document-object/lemma.js index 8cc6eaa..9d7cd4a 100644 --- a/lib/template/renderers/document-object/lemma.js +++ b/lib/template/renderers/document-object/lemma.js @@ -1,21 +1,19 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentObjectLemmaRenderer = void 0; -const info_block_1 = require("../../../util/html-components/info-block"); -class DocumentObjectLemmaRenderer { +const styles_1 = require("../../../util/lists/styles"); +const basic_object_1 = require("./basic-object"); +/** Renderer of the lemma document object */ +class DocumentObjectLemmaRenderer extends basic_object_1.BasicObjectRenderer { constructor() { - this.kind = 'DocumentObject'; + super(...arguments); this.abstractVariant = 'lemma'; - } - render(renderingManager, astNode) { - let title = 'Lemma'; - const titleMetadata = astNode.getMetadata('title'); - if (typeof titleMetadata === 'string') - title += `: ${titleMetadata}`; - return info_block_1.infoBlockComponent({ - title, - children: [renderingManager.render(...astNode.children)], - }); + /** @override */ + this.title = 'Lemma'; + /** @override */ + this.hasOptionalMetaTitle = true; + /** @override */ + this.titleBackgroundColor = styles_1.InfoBlockColors.Blue; } } exports.DocumentObjectLemmaRenderer = DocumentObjectLemmaRenderer; diff --git a/lib/template/renderers/document-object/observation.d.ts b/lib/template/renderers/document-object/observation.d.ts new file mode 100644 index 0000000..0bcd1f4 --- /dev/null +++ b/lib/template/renderers/document-object/observation.d.ts @@ -0,0 +1,13 @@ +import { Renderer } from '../../../core/rendering/renderer'; +import { InfoBlockColors } from '../../../util/lists/styles'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the observation document object */ +export declare class DocumentObjectObservationRenderer extends BasicObjectRenderer implements Renderer { + readonly abstractVariant = "observation"; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; + /** @override */ + protected titleBackgroundColor: InfoBlockColors; +} diff --git a/lib/template/renderers/document-object/observation.js b/lib/template/renderers/document-object/observation.js new file mode 100644 index 0000000..3968eb8 --- /dev/null +++ b/lib/template/renderers/document-object/observation.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DocumentObjectObservationRenderer = void 0; +const styles_1 = require("../../../util/lists/styles"); +const basic_object_1 = require("./basic-object"); +/** Renderer of the observation document object */ +class DocumentObjectObservationRenderer extends basic_object_1.BasicObjectRenderer { + constructor() { + super(...arguments); + this.abstractVariant = 'observation'; + /** @override */ + this.title = 'Observation'; + /** @override */ + this.hasOptionalMetaTitle = true; + /** @override */ + this.titleBackgroundColor = styles_1.InfoBlockColors.Orange; + } +} +exports.DocumentObjectObservationRenderer = DocumentObjectObservationRenderer; diff --git a/lib/template/renderers/document-object/proof.d.ts b/lib/template/renderers/document-object/proof.d.ts index 8a43e7e..7c58132 100644 --- a/lib/template/renderers/document-object/proof.d.ts +++ b/lib/template/renderers/document-object/proof.d.ts @@ -1,9 +1,10 @@ -import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; -import { RenderingManager } from '../../../core/rendering/rendering-manager'; -import { WooElementKind } from '../../../util/types/woo'; -export declare class DocumentObjectProofRenderer implements Renderer { - readonly kind: WooElementKind; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the proof document object */ +export declare class DocumentObjectProofRenderer extends BasicObjectRenderer implements Renderer { readonly abstractVariant = "proof"; - render(renderingManager: RenderingManager, astNode: ASTNode): Node; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; } diff --git a/lib/template/renderers/document-object/proof.js b/lib/template/renderers/document-object/proof.js index f06eca5..308fdf3 100644 --- a/lib/template/renderers/document-object/proof.js +++ b/lib/template/renderers/document-object/proof.js @@ -1,21 +1,16 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentObjectProofRenderer = void 0; -const info_block_1 = require("../../../util/html-components/info-block"); -class DocumentObjectProofRenderer { +const basic_object_1 = require("./basic-object"); +/** Renderer of the proof document object */ +class DocumentObjectProofRenderer extends basic_object_1.BasicObjectRenderer { constructor() { - this.kind = 'DocumentObject'; + super(...arguments); this.abstractVariant = 'proof'; - } - render(renderingManager, astNode) { - let title = 'Proof'; - const titleMetadata = astNode.getMetadata('title'); - if (typeof titleMetadata === 'string') - title += `: ${titleMetadata}`; - return info_block_1.infoBlockComponent({ - title, - children: [renderingManager.render(...astNode.children)], - }); + /** @override */ + this.title = 'Proof'; + /** @override */ + this.hasOptionalMetaTitle = true; } } exports.DocumentObjectProofRenderer = DocumentObjectProofRenderer; diff --git a/lib/template/renderers/document-object/proposition.d.ts b/lib/template/renderers/document-object/proposition.d.ts new file mode 100644 index 0000000..3d9ae02 --- /dev/null +++ b/lib/template/renderers/document-object/proposition.d.ts @@ -0,0 +1,13 @@ +import { Renderer } from '../../../core/rendering/renderer'; +import { InfoBlockColors } from '../../../util/lists/styles'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the proposition document object */ +export declare class DocumentObjectPropositionRenderer extends BasicObjectRenderer implements Renderer { + readonly abstractVariant = "proposition"; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; + /** @override */ + protected titleBackgroundColor: InfoBlockColors; +} diff --git a/lib/template/renderers/document-object/proposition.js b/lib/template/renderers/document-object/proposition.js new file mode 100644 index 0000000..7baf419 --- /dev/null +++ b/lib/template/renderers/document-object/proposition.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DocumentObjectPropositionRenderer = void 0; +const styles_1 = require("../../../util/lists/styles"); +const basic_object_1 = require("./basic-object"); +/** Renderer of the proposition document object */ +class DocumentObjectPropositionRenderer extends basic_object_1.BasicObjectRenderer { + constructor() { + super(...arguments); + this.abstractVariant = 'proposition'; + /** @override */ + this.title = 'Proposition'; + /** @override */ + this.hasOptionalMetaTitle = true; + /** @override */ + this.titleBackgroundColor = styles_1.InfoBlockColors.Blue; + } +} +exports.DocumentObjectPropositionRenderer = DocumentObjectPropositionRenderer; diff --git a/lib/template/renderers/document-object/question.d.ts b/lib/template/renderers/document-object/question.d.ts index 5750433..ae361e4 100644 --- a/lib/template/renderers/document-object/question.d.ts +++ b/lib/template/renderers/document-object/question.d.ts @@ -2,8 +2,11 @@ import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; import { RenderingManager } from '../../../core/rendering/rendering-manager'; import { WooElementKind } from '../../../util/types/woo'; +/** Renderer of the question document object */ export declare class DocumentObjectQuestionRenderer implements Renderer { readonly kind: WooElementKind; readonly abstractVariant = "question"; render(renderingManager: RenderingManager, astNode: ASTNode): Node; + private renderSolution; + private parseAndTypesetSolution; } diff --git a/lib/template/renderers/document-object/question.js b/lib/template/renderers/document-object/question.js index dddbd0c..e81035c 100644 --- a/lib/template/renderers/document-object/question.js +++ b/lib/template/renderers/document-object/question.js @@ -2,19 +2,39 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentObjectQuestionRenderer = void 0; const info_block_1 = require("../../../util/html-components/info-block"); +const mathjax_1 = require("../../mathjax"); +/** Renderer of the question document object */ class DocumentObjectQuestionRenderer { constructor() { this.kind = 'DocumentObject'; this.abstractVariant = 'question'; } render(renderingManager, astNode) { - let title = 'Question'; - const titleMetadata = astNode.getMetadata('title'); - if (typeof titleMetadata === 'string') - title += `: ${titleMetadata}`; + const children = [renderingManager.render(...astNode.children)]; + const solution = this.renderSolution(astNode); + if (typeof solution !== 'undefined') + children.push(solution); return info_block_1.infoBlockComponent({ - title, - children: [renderingManager.render(...astNode.children)], + title: 'Question', + children, + }); + } + renderSolution(astNode) { + const solution = astNode.getMetadata('solution'); + if (typeof solution !== 'string') + return; + const p = document.createElement('p'); + p.append(...this.parseAndTypesetSolution(solution)); + return info_block_1.infoBlockComponent({ + title: 'Question solution', + children: [p], + }); + } + parseAndTypesetSolution(solution) { + return solution.split('$').map((part, index) => { + if (index % 2 === 0) + return part; + return mathjax_1.typesetInlineMath(part); }); } } diff --git a/lib/template/renderers/document-object/remark.d.ts b/lib/template/renderers/document-object/remark.d.ts index 4273b2f..872cdb4 100644 --- a/lib/template/renderers/document-object/remark.d.ts +++ b/lib/template/renderers/document-object/remark.d.ts @@ -1,9 +1,13 @@ -import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; -import { RenderingManager } from '../../../core/rendering/rendering-manager'; -import { WooElementKind } from '../../../util/types/woo'; -export declare class DocumentObjectRemarkRenderer implements Renderer { - readonly kind: WooElementKind; +import { InfoBlockColors } from '../../../util/lists/styles'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the remark document object */ +export declare class DocumentObjectRemarkRenderer extends BasicObjectRenderer implements Renderer { readonly abstractVariant = "remark"; - render(renderingManager: RenderingManager, astNode: ASTNode): Node; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; + /** @override */ + protected titleBackgroundColor: InfoBlockColors; } diff --git a/lib/template/renderers/document-object/remark.js b/lib/template/renderers/document-object/remark.js index 080a44f..ed4ba4e 100644 --- a/lib/template/renderers/document-object/remark.js +++ b/lib/template/renderers/document-object/remark.js @@ -1,21 +1,19 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentObjectRemarkRenderer = void 0; -const info_block_1 = require("../../../util/html-components/info-block"); -class DocumentObjectRemarkRenderer { +const styles_1 = require("../../../util/lists/styles"); +const basic_object_1 = require("./basic-object"); +/** Renderer of the remark document object */ +class DocumentObjectRemarkRenderer extends basic_object_1.BasicObjectRenderer { constructor() { - this.kind = 'DocumentObject'; + super(...arguments); this.abstractVariant = 'remark'; - } - render(renderingManager, astNode) { - let title = 'Remark'; - const titleMetadata = astNode.getMetadata('title'); - if (typeof titleMetadata === 'string') - title += `: ${titleMetadata}`; - return info_block_1.infoBlockComponent({ - title, - children: [renderingManager.render(...astNode.children)], - }); + /** @override */ + this.title = 'Remark'; + /** @override */ + this.hasOptionalMetaTitle = true; + /** @override */ + this.titleBackgroundColor = styles_1.InfoBlockColors.Orange; } } exports.DocumentObjectRemarkRenderer = DocumentObjectRemarkRenderer; diff --git a/lib/template/renderers/document-object/solution.d.ts b/lib/template/renderers/document-object/solution.d.ts new file mode 100644 index 0000000..da32216 --- /dev/null +++ b/lib/template/renderers/document-object/solution.d.ts @@ -0,0 +1,10 @@ +import { Renderer } from '../../../core/rendering/renderer'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the solution document object */ +export declare class DocumentObjectSolutionRenderer extends BasicObjectRenderer implements Renderer { + readonly abstractVariant = "solution"; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; +} diff --git a/lib/template/renderers/document-object/solution.js b/lib/template/renderers/document-object/solution.js new file mode 100644 index 0000000..00c9872 --- /dev/null +++ b/lib/template/renderers/document-object/solution.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DocumentObjectSolutionRenderer = void 0; +const basic_object_1 = require("./basic-object"); +/** Renderer of the solution document object */ +class DocumentObjectSolutionRenderer extends basic_object_1.BasicObjectRenderer { + constructor() { + super(...arguments); + this.abstractVariant = 'solution'; + /** @override */ + this.title = 'Solution'; + /** @override */ + this.hasOptionalMetaTitle = true; + } +} +exports.DocumentObjectSolutionRenderer = DocumentObjectSolutionRenderer; diff --git a/lib/template/renderers/document-object/table.d.ts b/lib/template/renderers/document-object/table.d.ts index 59a56f1..2eff904 100644 --- a/lib/template/renderers/document-object/table.d.ts +++ b/lib/template/renderers/document-object/table.d.ts @@ -1,9 +1,10 @@ -import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; -import { RenderingManager } from '../../../core/rendering/rendering-manager'; -import { WooElementKind } from '../../../util/types/woo'; -export declare class DocumentObjectTableRenderer implements Renderer { - readonly kind: WooElementKind; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the table document object */ +export declare class DocumentObjectTableRenderer extends BasicObjectRenderer implements Renderer { readonly abstractVariant = "table"; - render(renderingManager: RenderingManager, astNode: ASTNode): Node; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; } diff --git a/lib/template/renderers/document-object/table.js b/lib/template/renderers/document-object/table.js index a39e0d6..3b4a3f1 100644 --- a/lib/template/renderers/document-object/table.js +++ b/lib/template/renderers/document-object/table.js @@ -1,21 +1,16 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentObjectTableRenderer = void 0; -const info_block_1 = require("../../../util/html-components/info-block"); -class DocumentObjectTableRenderer { +const basic_object_1 = require("./basic-object"); +/** Renderer of the table document object */ +class DocumentObjectTableRenderer extends basic_object_1.BasicObjectRenderer { constructor() { - this.kind = 'DocumentObject'; + super(...arguments); this.abstractVariant = 'table'; - } - render(renderingManager, astNode) { - let title = 'Table'; - const titleMetadata = astNode.getMetadata('title'); - if (typeof titleMetadata === 'string') - title += `: ${titleMetadata}`; - return info_block_1.infoBlockComponent({ - title, - children: [renderingManager.render(...astNode.children)], - }); + /** @override */ + this.title = 'Table'; + /** @override */ + this.hasOptionalMetaTitle = true; } } exports.DocumentObjectTableRenderer = DocumentObjectTableRenderer; diff --git a/lib/template/renderers/document-object/theorem.d.ts b/lib/template/renderers/document-object/theorem.d.ts index be2a503..db7b357 100644 --- a/lib/template/renderers/document-object/theorem.d.ts +++ b/lib/template/renderers/document-object/theorem.d.ts @@ -1,9 +1,13 @@ -import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; -import { RenderingManager } from '../../../core/rendering/rendering-manager'; -import { WooElementKind } from '../../../util/types/woo'; -export declare class DocumentObjectTheoremRenderer implements Renderer { - readonly kind: WooElementKind; +import { InfoBlockColors } from '../../../util/lists/styles'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the theorem document object */ +export declare class DocumentObjectTheoremRenderer extends BasicObjectRenderer implements Renderer { readonly abstractVariant = "theorem"; - render(renderingManager: RenderingManager, astNode: ASTNode): Node; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; + /** @override */ + protected titleBackgroundColor: InfoBlockColors; } diff --git a/lib/template/renderers/document-object/theorem.js b/lib/template/renderers/document-object/theorem.js index 63d0267..a8174a5 100644 --- a/lib/template/renderers/document-object/theorem.js +++ b/lib/template/renderers/document-object/theorem.js @@ -1,21 +1,19 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentObjectTheoremRenderer = void 0; -const info_block_1 = require("../../../util/html-components/info-block"); -class DocumentObjectTheoremRenderer { +const styles_1 = require("../../../util/lists/styles"); +const basic_object_1 = require("./basic-object"); +/** Renderer of the theorem document object */ +class DocumentObjectTheoremRenderer extends basic_object_1.BasicObjectRenderer { constructor() { - this.kind = 'DocumentObject'; + super(...arguments); this.abstractVariant = 'theorem'; - } - render(renderingManager, astNode) { - let title = 'Theorem'; - const titleMetadata = astNode.getMetadata('title'); - if (typeof titleMetadata === 'string') - title += `: ${titleMetadata}`; - return info_block_1.infoBlockComponent({ - title, - children: [renderingManager.render(...astNode.children)], - }); + /** @override */ + this.title = 'Theorem'; + /** @override */ + this.hasOptionalMetaTitle = true; + /** @override */ + this.titleBackgroundColor = styles_1.InfoBlockColors.Blue; } } exports.DocumentObjectTheoremRenderer = DocumentObjectTheoremRenderer; diff --git a/lib/template/renderers/document-object/warning.d.ts b/lib/template/renderers/document-object/warning.d.ts new file mode 100644 index 0000000..4c3ecfe --- /dev/null +++ b/lib/template/renderers/document-object/warning.d.ts @@ -0,0 +1,13 @@ +import { Renderer } from '../../../core/rendering/renderer'; +import { InfoBlockColors } from '../../../util/lists/styles'; +import { BasicObjectRenderer } from './basic-object'; +/** Renderer of the warning document object */ +export declare class DocumentObjectWarningRenderer extends BasicObjectRenderer implements Renderer { + readonly abstractVariant = "warning"; + /** @override */ + protected title: string; + /** @override */ + protected hasOptionalMetaTitle: boolean; + /** @override */ + protected titleBackgroundColor: InfoBlockColors; +} diff --git a/lib/template/renderers/document-object/warning.js b/lib/template/renderers/document-object/warning.js new file mode 100644 index 0000000..d9ebf64 --- /dev/null +++ b/lib/template/renderers/document-object/warning.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DocumentObjectWarningRenderer = void 0; +const styles_1 = require("../../../util/lists/styles"); +const basic_object_1 = require("./basic-object"); +/** Renderer of the warning document object */ +class DocumentObjectWarningRenderer extends basic_object_1.BasicObjectRenderer { + constructor() { + super(...arguments); + this.abstractVariant = 'warning'; + /** @override */ + this.title = 'Warning'; + /** @override */ + this.hasOptionalMetaTitle = true; + /** @override */ + this.titleBackgroundColor = styles_1.InfoBlockColors.Orange; + } +} +exports.DocumentObjectWarningRenderer = DocumentObjectWarningRenderer; diff --git a/lib/template/renderers/inner-env/small.d.ts b/lib/template/renderers/inner-env/small.d.ts new file mode 100644 index 0000000..a34cbcf --- /dev/null +++ b/lib/template/renderers/inner-env/small.d.ts @@ -0,0 +1,10 @@ +import { ASTNode } from '../../../core/ast/ast-node'; +import { Renderer } from '../../../core/rendering/renderer'; +import { RenderingManager } from '../../../core/rendering/rendering-manager'; +import { WooElementKind } from '../../../util/types/woo'; +/** Renderer of the small inner environment */ +export declare class InnerEnvSmallRenderer implements Renderer { + readonly kind: WooElementKind; + readonly abstractVariant = "small"; + render(renderingManager: RenderingManager, astNode: ASTNode): Node; +} diff --git a/lib/template/renderers/inner-env/small.js b/lib/template/renderers/inner-env/small.js new file mode 100644 index 0000000..bf97f4f --- /dev/null +++ b/lib/template/renderers/inner-env/small.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InnerEnvSmallRenderer = void 0; +/** Renderer of the small inner environment */ +class InnerEnvSmallRenderer { + constructor() { + this.kind = 'InnerEnv'; + this.abstractVariant = 'small'; + } + render(renderingManager, astNode) { + const small = document.createElement('small'); + small.append(renderingManager.render(...astNode.children)); + return small; + } +} +exports.InnerEnvSmallRenderer = InnerEnvSmallRenderer; diff --git a/lib/template/renderers/inner-env/u.d.ts b/lib/template/renderers/inner-env/u.d.ts new file mode 100644 index 0000000..4af8945 --- /dev/null +++ b/lib/template/renderers/inner-env/u.d.ts @@ -0,0 +1,10 @@ +import { ASTNode } from '../../../core/ast/ast-node'; +import { Renderer } from '../../../core/rendering/renderer'; +import { RenderingManager } from '../../../core/rendering/rendering-manager'; +import { WooElementKind } from '../../../util/types/woo'; +/** Renderer of the u (unarticulated, underlined) inner environment */ +export declare class InnerEnvURenderer implements Renderer { + readonly kind: WooElementKind; + readonly abstractVariant = "u"; + render(renderingManager: RenderingManager, astNode: ASTNode): Node; +} diff --git a/lib/template/renderers/inner-env/u.js b/lib/template/renderers/inner-env/u.js new file mode 100644 index 0000000..75e2775 --- /dev/null +++ b/lib/template/renderers/inner-env/u.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InnerEnvURenderer = void 0; +/** Renderer of the u (unarticulated, underlined) inner environment */ +class InnerEnvURenderer { + constructor() { + this.kind = 'InnerEnv'; + this.abstractVariant = 'u'; + } + render(renderingManager, astNode) { + const u = document.createElement('u'); + u.append(renderingManager.render(...astNode.children)); + return u; + } +} +exports.InnerEnvURenderer = InnerEnvURenderer; diff --git a/lib/template/renderers/outer-env/align.d.ts b/lib/template/renderers/outer-env/align-math.d.ts similarity index 100% rename from lib/template/renderers/outer-env/align.d.ts rename to lib/template/renderers/outer-env/align-math.d.ts diff --git a/lib/template/renderers/outer-env/align.js b/lib/template/renderers/outer-env/align-math.js similarity index 100% rename from lib/template/renderers/outer-env/align.js rename to lib/template/renderers/outer-env/align-math.js diff --git a/lib/template/renderers/outer-env/enumerate.d.ts b/lib/template/renderers/outer-env/enumerate.d.ts new file mode 100644 index 0000000..81aef81 --- /dev/null +++ b/lib/template/renderers/outer-env/enumerate.d.ts @@ -0,0 +1,9 @@ +import { ASTNode } from '../../../core/ast/ast-node'; +import { Renderer } from '../../../core/rendering/renderer'; +import { RenderingManager } from '../../../core/rendering/rendering-manager'; +import { WooElementKind } from '../../../util/types/woo'; +export declare class OuterEnvEnumerateRenderer implements Renderer { + readonly kind: WooElementKind; + readonly abstractVariant = "enumerate"; + render(renderingManager: RenderingManager, astNode: ASTNode): Node; +} diff --git a/lib/template/renderers/outer-env/enumerate.js b/lib/template/renderers/outer-env/enumerate.js new file mode 100644 index 0000000..ff350d1 --- /dev/null +++ b/lib/template/renderers/outer-env/enumerate.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.OuterEnvEnumerateRenderer = void 0; +class OuterEnvEnumerateRenderer { + constructor() { + this.kind = 'OuterEnv'; + this.abstractVariant = 'enumerate'; + } + render(renderingManager, astNode) { + const enumerate = document.createElement('ol'); + enumerate.append(renderingManager.render(...astNode.children)); + return enumerate; + } +} +exports.OuterEnvEnumerateRenderer = OuterEnvEnumerateRenderer; diff --git a/lib/template/renderers/outer-env/gather-math.d.ts b/lib/template/renderers/outer-env/gather-math.d.ts new file mode 100644 index 0000000..e728817 --- /dev/null +++ b/lib/template/renderers/outer-env/gather-math.d.ts @@ -0,0 +1,10 @@ +import { ASTNode } from '../../../core/ast/ast-node'; +import { Renderer } from '../../../core/rendering/renderer'; +import { RenderingManager } from '../../../core/rendering/rendering-manager'; +import { WooElementKind } from '../../../util/types/woo'; +/** Renderer of the gather-math outer environment */ +export declare class OuterEnvGatherMathRenderer implements Renderer { + readonly kind: WooElementKind; + readonly abstractVariant = "gather-math"; + render(renderingManager: RenderingManager, astNode: ASTNode): Node; +} diff --git a/lib/template/renderers/outer-env/gather-math.js b/lib/template/renderers/outer-env/gather-math.js new file mode 100644 index 0000000..2864e31 --- /dev/null +++ b/lib/template/renderers/outer-env/gather-math.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.OuterEnvGatherMathRenderer = void 0; +const mathjax_1 = require("../../mathjax"); +/** Renderer of the gather-math outer environment */ +class OuterEnvGatherMathRenderer { + constructor() { + this.kind = 'OuterEnv'; + this.abstractVariant = 'gather-math'; + } + render(renderingManager, astNode) { + var _a; + const children = renderingManager.render(...astNode.children); + const mathSource = `\\begin{gather*}${(_a = children.textContent) !== null && _a !== void 0 ? _a : ''}\\end{gather*}`; + return mathjax_1.typesetBlockMath(mathSource); + } +} +exports.OuterEnvGatherMathRenderer = OuterEnvGatherMathRenderer; diff --git a/lib/template/renderers/outer-env/solution.d.ts b/lib/template/renderers/outer-env/item.d.ts similarity index 76% rename from lib/template/renderers/outer-env/solution.d.ts rename to lib/template/renderers/outer-env/item.d.ts index ec46b3a..e333145 100644 --- a/lib/template/renderers/outer-env/solution.d.ts +++ b/lib/template/renderers/outer-env/item.d.ts @@ -2,8 +2,8 @@ import { ASTNode } from '../../../core/ast/ast-node'; import { Renderer } from '../../../core/rendering/renderer'; import { RenderingManager } from '../../../core/rendering/rendering-manager'; import { WooElementKind } from '../../../util/types/woo'; -export declare class OuterEnvSolutionRenderer implements Renderer { +export declare class OuterEnvItemRenderer implements Renderer { readonly kind: WooElementKind; - readonly abstractVariant = "solution"; + readonly abstractVariant = "item"; render(renderingManager: RenderingManager, astNode: ASTNode): Node; } diff --git a/lib/template/renderers/outer-env/item.js b/lib/template/renderers/outer-env/item.js new file mode 100644 index 0000000..3b8d949 --- /dev/null +++ b/lib/template/renderers/outer-env/item.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.OuterEnvItemRenderer = void 0; +class OuterEnvItemRenderer { + constructor() { + this.kind = 'OuterEnv'; + this.abstractVariant = 'item'; + } + render(renderingManager, astNode) { + const item = document.createElement('li'); + item.append(renderingManager.render(...astNode.children)); + return item; + } +} +exports.OuterEnvItemRenderer = OuterEnvItemRenderer; diff --git a/lib/template/renderers/outer-env/itemize.d.ts b/lib/template/renderers/outer-env/itemize.d.ts new file mode 100644 index 0000000..d5394fd --- /dev/null +++ b/lib/template/renderers/outer-env/itemize.d.ts @@ -0,0 +1,9 @@ +import { ASTNode } from '../../../core/ast/ast-node'; +import { Renderer } from '../../../core/rendering/renderer'; +import { RenderingManager } from '../../../core/rendering/rendering-manager'; +import { WooElementKind } from '../../../util/types/woo'; +export declare class OuterEnvItemizeRenderer implements Renderer { + readonly kind: WooElementKind; + readonly abstractVariant = "itemize"; + render(renderingManager: RenderingManager, astNode: ASTNode): Node; +} diff --git a/lib/template/renderers/outer-env/itemize.js b/lib/template/renderers/outer-env/itemize.js new file mode 100644 index 0000000..e38ec89 --- /dev/null +++ b/lib/template/renderers/outer-env/itemize.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.OuterEnvItemizeRenderer = void 0; +class OuterEnvItemizeRenderer { + constructor() { + this.kind = 'OuterEnv'; + this.abstractVariant = 'itemize'; + } + render(renderingManager, astNode) { + const itemize = document.createElement('ul'); + itemize.append(renderingManager.render(...astNode.children)); + return itemize; + } +} +exports.OuterEnvItemizeRenderer = OuterEnvItemizeRenderer; diff --git a/lib/template/renderers/outer-env/solution.js b/lib/template/renderers/outer-env/solution.js deleted file mode 100644 index 0c6961c..0000000 --- a/lib/template/renderers/outer-env/solution.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.OuterEnvSolutionRenderer = void 0; -const info_block_1 = require("../../../util/html-components/info-block"); -class OuterEnvSolutionRenderer { - constructor() { - this.kind = 'OuterEnv'; - this.abstractVariant = 'solution'; - } - render(renderingManager, astNode) { - return info_block_1.infoBlockComponent({ - title: 'Solution', - children: [renderingManager.render(...astNode.children)], - }); - } -} -exports.OuterEnvSolutionRenderer = OuterEnvSolutionRenderer; diff --git a/lib/template/variants.js b/lib/template/variants.js index 001a97c..7a51c81 100644 --- a/lib/template/variants.js +++ b/lib/template/variants.js @@ -6,27 +6,33 @@ function registerTemplateVariants() { core_1.variantRegistry.setVariant('DocumentPart', 'Chapter', 'h1'); core_1.variantRegistry.setVariant('DocumentPart', 'Section', 'h2'); core_1.variantRegistry.setVariant('DocumentPart', 'Subsection', 'h3'); + core_1.variantRegistry.setVariant('DocumentObject', 'Algorithm', 'algorithm'); core_1.variantRegistry.setVariant('DocumentObject', 'Definition', 'definition'); core_1.variantRegistry.setVariant('DocumentObject', 'Corollary', 'corollary'); core_1.variantRegistry.setVariant('DocumentObject', 'Lemma', 'lemma'); + core_1.variantRegistry.setVariant('DocumentObject', 'Observation', 'observation'); + core_1.variantRegistry.setVariant('DocumentObject', 'Proposition', 'proposition'); core_1.variantRegistry.setVariant('DocumentObject', 'Theorem', 'theorem'); core_1.variantRegistry.setVariant('DocumentObject', 'Proof', 'proof'); core_1.variantRegistry.setVariant('DocumentObject', 'Remark', 'remark'); core_1.variantRegistry.setVariant('DocumentObject', 'Example', 'example'); core_1.variantRegistry.setVariant('DocumentObject', 'Figure', 'figure'); core_1.variantRegistry.setVariant('DocumentObject', 'Question', 'question'); + core_1.variantRegistry.setVariant('DocumentObject', 'Solution', 'solution'); core_1.variantRegistry.setVariant('DocumentObject', 'Table', 'table'); + core_1.variantRegistry.setVariant('DocumentObject', 'Warning', 'warning'); core_1.variantRegistry.setVariant('OuterEnv', 'align', 'align-math'); core_1.variantRegistry.setVariant('OuterEnv', 'caption', 'caption'); core_1.variantRegistry.setVariant('OuterEnv', 'codeblock', 'codeblock'); - core_1.variantRegistry.setVariant('OuterEnv', 'enumerate', 'enumerate'); // TODO + core_1.variantRegistry.setVariant('OuterEnv', 'enumerate', 'enumerate'); core_1.variantRegistry.setVariant('OuterEnv', 'equation', 'block-math'); + core_1.variantRegistry.setVariant('OuterEnv', 'gather', 'gather-math'); core_1.variantRegistry.setVariant('OuterEnv', 'sage', 'sage'); - core_1.variantRegistry.setVariant('OuterEnv', 'solution', 'solution'); core_1.variantRegistry.setVariant('OuterEnv', 'tabular', 'tabular'); core_1.variantRegistry.setVariant('OuterEnv', 'tikz', 'tikz'); core_1.variantRegistry.setVariant('OuterEnv', 'image', 'image'); // TODO - core_1.variantRegistry.setVariant('OuterEnv', 'itemize', 'itemize'); // TODO + core_1.variantRegistry.setVariant('OuterEnv', 'itemize', 'itemize'); + core_1.variantRegistry.setVariant('OuterEnv', 'item', 'item'); core_1.variantRegistry.setVariant('OuterEnv', 'quote', 'quote'); core_1.variantRegistry.setVariant('InnerEnv', 'cite', 'cite'); core_1.variantRegistry.setVariant('InnerEnv', 'code', 'code'); @@ -38,7 +44,9 @@ function registerTemplateVariants() { core_1.variantRegistry.setVariant('InnerEnv', 'notion', 'b'); core_1.variantRegistry.setVariant('InnerEnv', 'quoted', 'quoted'); core_1.variantRegistry.setVariant('InnerEnv', 'reference', 'reference'); + core_1.variantRegistry.setVariant('InnerEnv', 'small', 'small'); core_1.variantRegistry.setVariant('InnerEnv', 'todo', 'todo'); // TODO + core_1.variantRegistry.setVariant('InnerEnv', 'underline', 'u'); core_1.variantRegistry.setVariant('InnerEnv', '_index', '_index'); core_1.variantRegistry.setVariant('InnerEnv', '_reference', '_reference'); } diff --git a/lib/util/html-components/info-block.d.ts b/lib/util/html-components/info-block.d.ts index be0c06d..a01e59b 100644 --- a/lib/util/html-components/info-block.d.ts +++ b/lib/util/html-components/info-block.d.ts @@ -1,4 +1,5 @@ -export declare function infoBlockComponent({ title, children, }: { +export declare function infoBlockComponent({ title, children, titleBackgroundColor, }: { title: string; children: Node[]; + titleBackgroundColor?: string; }): Node; diff --git a/lib/util/html-components/info-block.js b/lib/util/html-components/info-block.js index 3957f9d..223f038 100644 --- a/lib/util/html-components/info-block.js +++ b/lib/util/html-components/info-block.js @@ -1,11 +1,15 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.infoBlockComponent = void 0; -function infoBlockComponent({ title, children, }) { +function infoBlockComponent({ title, children, titleBackgroundColor, }) { const block = document.createElement('div'); block.classList.add('wootom-info-block'); const p = document.createElement('p'); p.classList.add('wootom-title'); + if (typeof titleBackgroundColor !== 'undefined') { + block.style.borderColor = titleBackgroundColor; + p.style.backgroundColor = titleBackgroundColor; + } p.append(title); block.append(p); const childrenContainer = document.createElement('div'); diff --git a/lib/util/lists/styles.d.ts b/lib/util/lists/styles.d.ts new file mode 100644 index 0000000..81dd14c --- /dev/null +++ b/lib/util/lists/styles.d.ts @@ -0,0 +1,6 @@ +export declare enum InfoBlockColors { + Green = "var(--color-green)", + Blue = "var(--color-blue)", + Orange = "var(--color-orange)", + Red = "var(--color-red)" +} diff --git a/lib/util/lists/styles.js b/lib/util/lists/styles.js new file mode 100644 index 0000000..d777c8d --- /dev/null +++ b/lib/util/lists/styles.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InfoBlockColors = void 0; +var InfoBlockColors; +(function (InfoBlockColors) { + InfoBlockColors["Green"] = "var(--color-green)"; + InfoBlockColors["Blue"] = "var(--color-blue)"; + InfoBlockColors["Orange"] = "var(--color-orange)"; + InfoBlockColors["Red"] = "var(--color-red)"; +})(InfoBlockColors = exports.InfoBlockColors || (exports.InfoBlockColors = {})); diff --git a/lib/wootom.d.ts b/lib/wootom.d.ts index bd9348b..1902b58 100644 --- a/lib/wootom.d.ts +++ b/lib/wootom.d.ts @@ -26,4 +26,10 @@ export declare const config: { description: string; }[]; }; + updateOnType: { + title: string; + description: string; + type: string; + default: boolean; + }; }; diff --git a/lib/wootom.js b/lib/wootom.js index b565e95..b940e06 100644 --- a/lib/wootom.js +++ b/lib/wootom.js @@ -84,4 +84,12 @@ exports.config = { }, ], }, + updateOnType: { + title: 'Update on Type', + description: 'Update the WooWoo HTML preview and the Navigation panes (also)' + + ' on type. If `false`, the preview will be updated only when a' + + ' new file is opened and when a file is saved.', + type: 'boolean', + default: true, + }, }; diff --git a/package.json b/package.json index 6a16eec..bee94e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wootom", - "version": "0.6.1", + "version": "0.7.0", "author": { "name": "David Straka", "email": "davidstraka.public@gmail.com" @@ -33,6 +33,7 @@ "atomTestRunner": "atom-jasmine3-test-runner", "scripts": { "build": "tsc --build src/lib src/spec", + "clean": "node scripts/clean.mjs", "format:check": "prettier --check .", "format:fix": "prettier --write .", "lint:check": "eslint src --max-warnings=0", diff --git a/snippets/woo.cson b/snippets/woo.cson index d62e40c..494a943 100644 --- a/snippets/woo.cson +++ b/snippets/woo.cson @@ -31,6 +31,18 @@ # Objects + 'Algorithm': + 'prefix': 'alg' + 'body': """ + .Algorithm: + title: $1 + label: $2 + index: $3 + + $4 + + """ + 'Definition': 'prefix': 'def' 'body': """ @@ -67,6 +79,30 @@ """ + 'Observation': + 'prefix': 'obs' + 'body': """ + .Observation: + title: $1 + label: $2 + index: $3 + + $4 + + """ + + 'Proposition': + 'prefix': 'propo' + 'body': """ + .Proposition: + title: $1 + label: $2 + index: $3 + + $4 + + """ + 'Theorem': 'prefix': 'thm' 'body': """ @@ -131,12 +167,21 @@ 'prefix': 'que' 'body': """ .Question: + solution: $1 - $1 + $2 - .solution: + """ - $2 + 'Solution': + 'prefix': 'sol' + 'body': """ + .Solution: + title: $1 + label: $2 + index: $3 + + $4 """ @@ -156,6 +201,18 @@ """ + 'Warning': + 'prefix': 'warn' + 'body': """ + .Warning: + title: $1 + label: $2 + index: $3 + + $4 + + """ + # Outer Environments 'Align': @@ -206,6 +263,15 @@ """ + 'Gather': + 'prefix': 'gat' + 'body': """ + .gather: + + $1 + + """ + 'Image': 'prefix': 'img' 'body': """ @@ -242,15 +308,6 @@ """ - 'Solution': - 'prefix': 'sol' - 'body': """ - .solution: - - $1 - - """ - 'Tabular': 'prefix': 'tabu' 'body': """ @@ -331,8 +388,20 @@ .reference:$1 """ + 'Small': + 'prefix': 'sma' + 'body': """ + "$1".small + """ + 'Todo': 'prefix': 'tod' 'body': """ "$1".todo """ + + 'Underline': + 'prefix': 'u' + 'body': """ + "$1".underline + """ diff --git a/styles/general/blocks.less b/styles/general/blocks.less new file mode 100644 index 0000000..c121e20 --- /dev/null +++ b/styles/general/blocks.less @@ -0,0 +1,33 @@ +@import 'ui-variables'; + +.wootom-html-viewer { + .block(@title-bg-color, @title-color) { + border: 1px solid @title-bg-color; + border-radius: @component-border-radius; + margin: 0.5rem 0; + + > * { + padding: 0.35rem 1rem; + } + + > .wootom-title { + background-color: @title-bg-color; + border-radius: @component-border-radius @component-border-radius 0 0; + color: @title-color; + margin: 0; + } + } + + .wootom-error-block { + .block(@background-color-error, @text-color-highlight); + } + + .wootom-info-block { + .block(@background-color-info, @text-color-highlight); + + --color-green: #198754; // --bs-success + --color-blue: #3498db; // --bs-info + --color-orange: #f39c12; // --bs-warning + --color-red: #e74c3c; // --bs-danger + } +} diff --git a/styles/general/caption.less b/styles/general/caption.less new file mode 100644 index 0000000..d55f448 --- /dev/null +++ b/styles/general/caption.less @@ -0,0 +1,5 @@ +.wootom-html-viewer { + .wootom-caption { + text-align: center; + } +} diff --git a/styles/general/error-details.less b/styles/general/error-details.less new file mode 100644 index 0000000..23dfadb --- /dev/null +++ b/styles/general/error-details.less @@ -0,0 +1,23 @@ +@import 'ui-variables'; + +.wootom-html-viewer { + details.wootom-error-details { + border-radius: @component-border-radius; + + > summary { + background-color: @background-color-error; + border-radius: @component-border-radius; + color: @text-color-highlight; + cursor: pointer; + } + + &[open] { + border: 1px solid @background-color-error; + + > summary { + border-radius: @component-border-radius @component-border-radius + 0 0; + } + } + } +} diff --git a/styles/general/error-inline.less b/styles/general/error-inline.less new file mode 100644 index 0000000..37f987a --- /dev/null +++ b/styles/general/error-inline.less @@ -0,0 +1,10 @@ +@import 'ui-variables'; + +.wootom-html-viewer { + .wootom-error-inline { + background-color: @background-color-error; + color: @text-color-highlight; + margin: 0 0.5em; + padding: 0 0.5em; + } +} diff --git a/styles/general/figure.less b/styles/general/figure.less new file mode 100644 index 0000000..a1cea46 --- /dev/null +++ b/styles/general/figure.less @@ -0,0 +1,15 @@ +.wootom-html-viewer { + .wootom-figure { + text-align: center; + overflow-x: auto; + + > span { + display: inline-block; + margin: 0 1rem; + } + + pre { + text-align: left; + } + } +} diff --git a/styles/general/footnote.less b/styles/general/footnote.less new file mode 100644 index 0000000..bf17a04 --- /dev/null +++ b/styles/general/footnote.less @@ -0,0 +1,25 @@ +@import 'ui-variables'; + +.wootom-html-viewer { + .wootom-footnote { + color: @text-color-subtle; + + &:hover { + color: @text-color-selected; + } + + &:not(.wootom-footnote-shown) > *:not(.wootom-footnote-controls) { + display: none; + } + + > .wootom-footnote-controls::before { + content: '(*\00a0▷)'; + cursor: pointer; + } + + &.wootom-footnote-shown > .wootom-footnote-controls::before { + content: '(*\00a0◁)'; + margin-right: 0.5em; + } + } +} diff --git a/styles/general/tikz.less b/styles/general/tikz.less new file mode 100644 index 0000000..c75b00c --- /dev/null +++ b/styles/general/tikz.less @@ -0,0 +1,11 @@ +.wootom-html-viewer { + svg.wootom-tikz { + &.wootom-tikz-inverted { + filter: invert(1); + } + + &.wootom-tikz-whiteboard { + background-color: #fff; + } + } +} diff --git a/styles/main.less b/styles/main.less index bd95bbd..2349813 100644 --- a/styles/main.less +++ b/styles/main.less @@ -1,112 +1,21 @@ -.wootom-html-viewer { - --color-translucent-red: rgba(255, 0, 0, 0.4); - --color-translucent-blue: rgba(55, 106, 247, 0.4); - --color-translucent-yellow: rgba(255, 255, 0, 0.4); - --color-white: #fff; +@import 'general/blocks.less'; +@import 'general/caption.less'; +@import 'general/error-details.less'; +@import 'general/error-inline.less'; +@import 'general/figure.less'; +@import 'general/footnote.less'; +@import 'general/tikz.less'; +@import 'navigation/lists.less'; +@import 'navigation/search.less'; +.wootom-html-viewer { padding: 1rem; - .wootom-error-block { - border: 1px solid var(--color-translucent-red); - margin: 0.5rem 0; - - > * { - padding: 0.35rem 1rem; - } - - > .wootom-title { - background-color: var(--color-translucent-red); - margin: 0; - } - } - - .wootom-error-inline { - background-color: var(--color-translucent-red); - margin: 0 0.5em; - padding: 0 0.5em; - } - - .wootom-info-block { - border: 1px solid var(--color-translucent-blue); - margin: 0.5rem 0; - - > * { - padding: 0.35rem 1rem; - } - - > .wootom-title { - background-color: var(--color-translucent-blue); - margin: 0; - } - } - - .wootom-caption { - text-align: center; - } - - .wootom-figure { - text-align: center; - - > span { - display: inline-block; - margin: 0 1rem; - } - - pre { - text-align: left; - } - } - - details.wootom-error-details { - border: 1px solid var(--color-translucent-red); - - > summary { - background-color: var(--color-translucent-red); - cursor: pointer; - } - } - - svg.wootom-tikz { - &.wootom-tikz-inverted { - filter: invert(1); - } - - &.wootom-tikz-whiteboard { - background-color: var(--color-white); - } - } - - .wootom-navigation { - ol { - padding-inline-start: 2em; - } - - input.wootom-search { - background: transparent; - border-radius: 25px; - border-style: solid; - border-width: 1px; - padding: 0 1rem; - min-width: 5rem; - width: 100%; - } + p:last-child { + margin-bottom: 0; } - .wootom-footnote { - background-color: var(--color-translucent-yellow); - - &:not(.wootom-footnote-shown) > *:not(.wootom-footnote-controls) { - display: none; - } - - > .wootom-footnote-controls::before { - content: '(*\00a0▷)'; - cursor: pointer; - } - - &.wootom-footnote-shown > .wootom-footnote-controls::before { - content: '(*\00a0◁)'; - margin-right: 0.5em; - } + pre:not(:last-child) { + margin-bottom: 1em; } } diff --git a/styles/navigation/lists.less b/styles/navigation/lists.less new file mode 100644 index 0000000..2d0be0e --- /dev/null +++ b/styles/navigation/lists.less @@ -0,0 +1,9 @@ +.wootom-html-viewer .wootom-navigation { + ol { + padding-inline-start: 2em; + } + + li a { + color: inherit; + } +} diff --git a/styles/navigation/search.less b/styles/navigation/search.less new file mode 100644 index 0000000..2bece3a --- /dev/null +++ b/styles/navigation/search.less @@ -0,0 +1,12 @@ +.wootom-html-viewer .wootom-navigation { + input.wootom-search { + background: transparent; + border-radius: 25px; + border-style: solid; + border-width: 1px; + padding: 0 1rem; + margin-bottom: 0.5rem; + min-width: 5rem; + width: 100%; + } +}