├── .github ├── CONTRIBUTING.md └── ISSUE_TEMPLATE.md ├── .gitignore ├── .vscode └── launch.json ├── changelog.md ├── css ├── texmath.css └── vscode-mdmath.css ├── docs ├── euler.html ├── euler.md ├── euler.pdf ├── img │ ├── euler-identity-browser.png │ ├── euler-identity.png │ ├── publication-settings.png │ └── triangle.png ├── publication.html ├── publication.md └── publication.pdf ├── extension.js ├── img ├── DisableMarkdownMath.png ├── TrendingThisMonth.PNG ├── edit.gif ├── htmlExport.png ├── icon.png ├── mdmath.gif ├── triangle.png └── usersettings.png ├── license.txt ├── package-lock.json ├── package.json ├── readme.md ├── syntaxes ├── dollars_display.json └── dollars_inline.json ├── themes ├── default │ ├── style.css │ └── theme.js ├── minimal │ └── theme.js └── publication │ ├── fonts │ ├── LM-bold-italic.ttf │ ├── LM-bold-italic.woff │ ├── LM-bold-italic.woff2 │ ├── LM-bold.ttf │ ├── LM-bold.woff │ ├── LM-bold.woff2 │ ├── LM-italic.ttf │ ├── LM-italic.woff │ ├── LM-italic.woff2 │ ├── LM-regular.ttf │ ├── LM-regular.woff │ └── LM-regular.woff2 │ ├── style.css │ └── theme.js └── triangle.md /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to *mdmath* 2 | 3 | Pull requests to *mdmath* are very welcome. 4 | 5 | #### Testing in other browsers and platforms 6 | 7 | *mdmath* as an extension to VS Code should run seemlessly in other browsers and on all platforms supported by VS Code. 8 | 9 | Verifying that assumption is of valuable help. 10 | 11 | ## Code Styles 12 | 13 | - 4 spaces for indentation 14 | - 80 character line length 15 | - commas last 16 | - declare variables in the outermost scope that they are used 17 | - camelCase for variables in JavaScript 18 | 19 | 20 | ## License 21 | 22 | *Markdown+Math* for VS Code is licensed under the [MIT License](http://opensource.org/licenses/MIT) 23 | 24 | © [Stefan Gössner](https://github.com/goessner) 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Summary 2 | 3 | ... 4 | 5 | ### Expected behavior 6 | 7 | ... 8 | 9 | ### Actual behavior 10 | 11 | ... 12 | 13 | ### Steps to reproduce 14 | 15 | 1. First step 16 | 2. Second step 17 | 3. Third step 18 | 19 | ### Code example 20 | 21 | ```md 22 | Some markdown code ... 23 | 24 | ... with issues. 25 | ``` 26 | 27 | ### Related links 28 | 29 | * [Markdown+Math](https://github.com/goessner/mdmath) 30 | 31 | ### Environment 32 | 33 | ```text 34 | Operating system: ___ 35 | VSCode version: ___ 36 | Markdown+Math version: ___ 37 | ``` 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.vsix 3 | out/ 4 | .vscodeignore -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": [ 11 | "--extensionDevelopmentPath=${workspaceFolder}" 12 | ], 13 | "stopOnEntry": false 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | ## CHANGELOG 2 | ### [2.7.5]() on June 06, 2021 3 | * Name collision with extension `microJam` removed. 4 | 5 | ### [2.7.4]() on June 06, 2021 6 | * Table of Content links bug removed. 7 | * macros settings bug removed. 8 | 9 | ### [2.7.0]() on June 04, 2021 10 | * Different themes for HTML export are supported now. User can choose 11 | * default 12 | * minimal 13 | * publication (LaTeX style) 14 | 15 | theme in user settings. 16 | * Commutative diagrams are working now. 17 | * Insert *Table Of Content* command available. Inject ToC at cursor location via `Insert Table of Content` from Command Palette (Ctrl+K T). 18 | * User notification on HTML export can be suppressed via boolean user setting `Silent` (default: `false`). 19 | * Enforce inline math `$` pair being enclosed by space characters as a guard against misinterpretation of single `$`'s in normal markdown via user setting `Outerspace` (default: `false` for backward compatibility). 20 | * Update to KaTex version 0.13.11. 21 | * Update to `markdown-it` version 12.0.6. 22 | * Update to `markdown-it-texmath` version 0.9.0. 23 | 24 | ### [2.5.0]() on June 14, 2020 25 | * Update with respect to update of [markdown-it-texmath](https://github.com/goessner/markdown-it-texmath) to version 0.7.0 due to support of Pandoc math syntax with `dollars` namespace. 26 | * Multiline math expressions in blockquote blocks are supported. Bug resolved. 27 | * Code size is reduced. 28 | * Regular expressions were simplified. 29 | * Runtime performance is improved. 30 | 31 | ### [2.4.1]() on June 11, 2020 32 | * Update with respect to update of [markdown-it-texmath](https://github.com/goessner/markdown-it-texmath) to version 0.6.9 due to support for multiline display math inside of blockquote blocks. 33 | * Update to `markdown-it` 11.0.0 34 | ### [2.4.0]() on October 06, 2019 35 | * Update with respect to update of [markdown-it-texmath](https://github.com/goessner/markdown-it-texmath) to version 0.6.0 due to support for [Julia Markdown](https://docs.julialang.org/en/v1/stdlib/Markdown/). 36 | * Update to KaTeX 0.11.1 37 | * Removing dependency on node module `clipboardy` in favor of vscode native clipboard support. 38 | * code clean up and minimizing dependency on external node modules. 39 | * Finally support user defined CSS file for HTML export. 40 | * Allow macro definition in an external file. 41 | 42 | ### [2.3.9]() on February 07, 2019 43 | * Update with respect to update of [markdown-it-texmath](https://github.com/goessner/markdown-it-texmath) to version 0.5.5 due to resolved [rendering bug with brackets delimiters](https://github.com/goessner/markdown-it-texmath/issues/9). 44 | 45 | ### [2.3.8]() on January 20, 2019 46 | * Update with respect to update of [markdown-it-texmath](https://github.com/goessner/markdown-it-texmath) to version 0.5.4 due to resolved [blockquote bug](https://github.com/goessner/mdmath/issues/50). 47 | 48 | ### [2.3.5]() on October 25, 2018 49 | * Implemented macros supported by KaTeX. 50 | * Command to save HTML to file. 51 | * Autosave option for saving HTML when Markdown file is changed. 52 | * Ability to configure where HTML files are saved. 53 | * `katex` dependency upgrade to `0.10.0`. 54 | 55 | ### [2.3.3]() on September 07, 2018 56 | * Add support for [Kramdown](https://kramdown.gettalong.org/) . Simply write `"mdmath.delimiters": "kramdown"` into your user settings for activating it. Please note, that syntax highlighting is only properly supported with `dollars`. 57 | 58 | ### [2.3.0]() on August 15, 2018 59 | * fatal `blockquote` behavior gone with VSCode 1.26.0. Obsolete bug fix removed. 60 | * fatal `blockquote` bug fixed. 61 | * `markdown-it` dependency upgrade to `8.5.0`. 62 | * `katex` dependency upgrade to `0.10.0-beta`. 63 | 64 | ### [2.2.0]() on March 19, 2018 65 | * `clip-to-html` bug with Ubuntu fixed. 66 | * `markdown-it` dependency upgrade to `8.4.1`. 67 | * `katex` dependency upgrade to `0.9.0`. 68 | * `clipboardy` dependency upgrade to `1.2.3`. 69 | 70 | ### [2.1.0]() on January 05, 2018 71 | * Fixing escaped underscore bug with `markdown-it-texmath`. 72 | * Experimentally implementing syntax highlighting in markdown source code. 73 | 74 | ### [2.0.7]() on October 02, 2017 75 | * Fixing a css bug in the `clip-to-html` template. 76 | 77 | ### [2.0.6]() on September 27, 2017 78 | * Fixing the `newline` bug with `gitlab` delimiters. 79 | 80 | ### [2.0.4]() on September 08, 2017 81 | * Using extension local 'css' files instead of 'cdn'-served files for enabling offline usage of mdmath. 82 | * Update to KaTex version 0.8.3. 83 | 84 | ### [2.0.0]() on August 20, 2017 85 | * Fundamental rewrite using vscode markdown extension api. 86 | 87 | ### [1.2.8]() on May 15, 2017 88 | * Setting of `process.env["LC_CTYPE"]` removed, which is done by `clipboardy` itself. 89 | 90 | ### [1.2.7]() on May 14, 2017 91 | * Height increase in `mdmath.css` with block equations and formula numbers removed. 92 | * Chinese language bug with `mdmath.clipToHtml` removed ([issue](https://github.com/goessner/mdmath/issues/13#ref-commit-0e32c99)). 93 | * KaTeX version upgrade to 0.7.1. 94 | * `highlight.js` version upgrade to 9.11.0. 95 | 96 | ### [1.2.6]() on March 01, 2017 97 | * Bug in `mdmath.css` removed. 98 | 99 | ### [1.2.5]() on March 01, 2017 100 | * `mdmath.css` modified in order to align KaTeX font-size with surrounding text. 101 | 102 | ### [1.2.4]() on February 24, 2017 103 | * *debounce/throttle* update events to prevent misbehaving scrolling of preview window with large math documents. 104 | 105 | ### [1.2.0]() on February 20, 2017 106 | * *blockquote* bug removed. 107 | * Support of user settings. 108 | * Allow *yaml* and *JSON* front matter in markdown. 109 | * Copy HTML source to clipboard. 110 | * Command `Markdown+Math to Html` is now deprecated. 111 | * Generation of *Table of Contents* is now supported. 112 | * Support of custom CSS styles for preview window. 113 | * Documentation changes 114 | * moved CHANGELOG to its own file 115 | * moved CONTRIBUTING guide 116 | * added ISSUE_TEMPLATE 117 | * updated links in README 118 | * Updated CSS links for generated HTML code. 119 | * Updated dependencies and added bugs section to `package.json`. 120 | 121 | ### [1.1.0](https://github.com/goessner/mdmath/compare/5329d04...fcfcbdf) on December 27, 2016 122 | 123 | * Single character inline formula bug fixed. 124 | * Formula in lists bug fixed. 125 | * Handling of KaTeX errors improved. 126 | * Micro-improvement of regular expressions. 127 | 128 | ### [1.0.1](https://github.com/goessner/mdmath/compare/d7b2f55...5329d04) on December 21, 2016 129 | 130 | * `code block` bug removed. 131 | 132 | ### [1.0.0](https://github.com/goessner/mdmath/compare/f0eaf9b...d7b2f55) on December 20, 2016 133 | 134 | * Dependency on `markdown-it-katex` removed in favour of some lightweight regular expressions. 135 | * Very simple (manual) equation numbering implemented. 136 | * KaTeX error highlighting activated. 137 | * Footnotes by `markdown-it-footnote` added. 138 | * Standalone [tests](http://goessner.github.io/mdmath/test/) for math rendering added. 139 | * Markdown+Math CSS file added to [CDN](https://gitcdn.xyz/repo/goessner/mdmath/master/css/mdmath.css) 140 | * Some minor bugs removed. 141 | 142 | ### [0.9.0](https://github.com/goessner/mdmath/compare/20e9002...f0eaf9b) on December 3, 2016 143 | 144 | * Installation bug resolved 145 | 146 | ### [0.8.0](https://github.com/goessner/mdmath/tree/20e9002) on November 25, 2016 147 | 148 | * First Release 149 | -------------------------------------------------------------------------------- /css/texmath.css: -------------------------------------------------------------------------------- 1 | /* style for html inside of browsers */ 2 | /* align KaTeX font-size to surrounding text */ 3 | .katex { font-size: 1em !important; } 4 | /* supress effect of display formulas with eqno having bigger margin */ 5 | .katex-display { margin: 0em !important; } 6 | /* overwrite github-markdown.css asymmetric margin values */ 7 | .markdown-body .markdown-body dl, .markdown-body ol, .markdown-body p, .markdown-body pre, .markdown-body table, .markdown-body ul { 8 | margin-top: 8px; 9 | margin-bottom: 8px; 10 | } 11 | .markdown-body blockquote { 12 | font-size: 0.9em; 13 | margin: 0.75em 1em; 14 | padding: 0.1em 0.5em; 15 | } 16 | 17 | 18 | eq { display: inline-block; } 19 | eqn { display: block; margin: 0; } 20 | section.eqno { 21 | display: flex; 22 | flex-direction: row; 23 | align-content: space-between; 24 | align-items: center; 25 | 26 | } 27 | section.eqno > eqn { 28 | width: 100%; 29 | margin-left: 3em; 30 | } 31 | section.eqno > span { 32 | width: 3em; 33 | text-align: right; 34 | } 35 | -------------------------------------------------------------------------------- /css/vscode-mdmath.css: -------------------------------------------------------------------------------- 1 | p { 2 | text-align: justify; 3 | hyphens: auto; 4 | } 5 | 6 | table { 7 | display: table; 8 | width: auto; 9 | margin-left: auto; 10 | margin-right: auto; 11 | margin-bottom: 1em; 12 | border-collapse: collapse; 13 | } 14 | 15 | table th, table td { 16 | border-left: none; 17 | border-right: none; 18 | border-top: 1px solid #000; 19 | border-bottom: 1px solid #000; 20 | } 21 | 22 | figure { 23 | margin: 0.5em auto; 24 | } 25 | figure > img { 26 | display: block; 27 | margin: 0 auto; 28 | page-break-inside: avoid; 29 | text-align: center; 30 | } 31 | figcaption { 32 | font-size: 0.9em; 33 | margin-top: 0.5em; 34 | text-align: center; 35 | } 36 | 37 | aside { 38 | font-size: 0.9em; 39 | max-width: 300px; 40 | padding: 0 0 0 1em; 41 | margin: 0 0 0 1em; 42 | float: right; 43 | } 44 | 45 | aside > *:first-child { 46 | margin-top: 0; 47 | } 48 | aside > *:last-child { 49 | margin-bottom: 0; 50 | } 51 | -------------------------------------------------------------------------------- /docs/euler.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Euler's Identity 16 | 17 | 18 |
19 |

Euler's Identity

20 |

How to combine 5 important math constants to a short formula

21 |

Max Muster1, Lisa Master2

22 |
1Hochschule Gartenstadt
2Universität Übersee
23 |
May 2021
24 |
Keywords: markdown+math, VSCode, static page, publication, LaTeX, math
25 |
26 |
27 | 28 |

Abstract

29 |

Euler's identity makes a valid formula out of five mathematical constants.

30 |

1. Introduction

31 |

Euler's identity is often cited as an example of deep mathematical beauty. 32 | Three basic arithmetic operations occur exactly once and combine five fundamental mathematical constants [1].

33 |

2. The Identity

34 |

Starting from Euler's formula eix=cosx+isinxe^{ix}=\cos x + i\sin x for any real number xx, we get to Euler's identity with the special case of x=πx = \pi

35 |
eiπ+1=0.e^{i\pi}+1=0\,.(1)
36 |

The arithmetic operations addition, multiplication and exponentiation combine the fundamental constants

37 | 44 |

3. Conclusion

45 |

It has been shown, how Euler's identity makes a valid formula from five mathematical constants.

46 |

References

47 |

[1] Euler's identity

48 | 49 |
50 | 51 | -------------------------------------------------------------------------------- /docs/euler.md: -------------------------------------------------------------------------------- 1 | --- 2 | "lang": "en", 3 | "title": "Euler's Identity", 4 | "subtitle": "How to combine 5 important math constants to a short formula", 5 | "authors": ["Max Muster1", "Lisa Master2"], 6 | "adresses": ["1Hochschule Gartenstadt","2Universität Übersee"], 7 | "date": "May 2021", 8 | "description": "mdmath LaTeX demo site", 9 | "tags": ["markdown+math","VSCode","static page","publication","LaTeX","math"] 10 | --- 11 | ### Abstract 12 | 13 | Euler's identity makes a valid formula out of five mathematical constants. 14 | 15 | ## 1. Introduction 16 | 17 | Euler's identity is often cited as an example of deep mathematical beauty. 18 | Three basic arithmetic operations occur exactly once and combine five fundamental mathematical constants [[1](#1)]. 19 | 20 | ## 2. The Identity 21 | 22 | Starting from Euler's formula $e^{ix}=\cos x + i\sin x$ for any real number $x$, we get to Euler's identity with the special case of $x = \pi$ 23 | 24 | $$e^{i\pi}+1=0\,.$$ (1) 25 | 26 | The arithmetic operations *addition*, *multiplication* and *exponentiation* combine the fundamental constants 27 | 28 | * the additive identity $0$. 29 | * the multiplicative identity $1$. 30 | * the circle constant $\pi$. 31 | * Euler's number $e$. 32 | * the imaginary constant $i$. 33 | 34 | ## 3. Conclusion 35 | 36 | It has been shown, how Euler's identity makes a valid formula from five mathematical constants. 37 | 38 | ### References 39 | 40 | [1] [Euler's identity](https://en.wikipedia.org/wiki/Euler%27s_identity) -------------------------------------------------------------------------------- /docs/euler.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goessner/mdmath/b562f83cf1f427ea74f80dd90b62e3eeec2cad2c/docs/euler.pdf -------------------------------------------------------------------------------- /docs/img/euler-identity-browser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goessner/mdmath/b562f83cf1f427ea74f80dd90b62e3eeec2cad2c/docs/img/euler-identity-browser.png -------------------------------------------------------------------------------- /docs/img/euler-identity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goessner/mdmath/b562f83cf1f427ea74f80dd90b62e3eeec2cad2c/docs/img/euler-identity.png -------------------------------------------------------------------------------- /docs/img/publication-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goessner/mdmath/b562f83cf1f427ea74f80dd90b62e3eeec2cad2c/docs/img/publication-settings.png -------------------------------------------------------------------------------- /docs/img/triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goessner/mdmath/b562f83cf1f427ea74f80dd90b62e3eeec2cad2c/docs/img/triangle.png -------------------------------------------------------------------------------- /docs/publication.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Web Publications — LaTeX Style 16 | 17 | 18 |
19 |

Web Publications — LaTeX Style

20 |

Give your Web Publications LaTeX Style

21 |

Stefan Gössner1

22 |
1Dortmund University of Applied Sciences. Department of Mechanical Engineering
23 |
May 2021
24 |
Keywords: mdmath, static page, publication, Journal, LaTeX, math
25 |
26 |
27 | 28 |

Abstract

29 |

Now there is an easy way to have both, a possibly interactive, static web page containing math and a scientific print document for documentation and publication, 30 | each looking like a professional LaTeX document. All you need is the popular free, open source Visual Studio Code text editor with its lightweight extension Markdown+Math for managing LaTeX style and math syntax as well as using meanwhile ubiquitous Markdown language. The resulting HTML document already contains prerendered math formulas, so browsers won't have the burden of math rendering via scripting.

31 |

Content

32 | 53 |







54 |

1. Introduction

55 |

There has been an upward trend in using Markdown language not only for web content, but also for student notes, handouts and scientific papers of small to medium size. Markdown source files are benefitial for viewing, editing and archiving content. Additionally we can generate visually pleasing LaTeX style documents from it

56 | 60 |

Markdown parsers usually export semantic HTML, i.e. meaningful HTML elements only without using class attributes. Styling those HTML documents is accomplished then by using classless CSS stylesheets [4,5]. Styling semantic HTML with classless CSS ...

61 | 66 |

Edward Tufte's conventions for styling papers and handouts are followed here as a guidline [6].

67 |

This paper – styled itself as a LaTeX document – first lists the necessary installation aspects in short. After a tiny example of a LaTeX styled markdown document, it gives a quick overview of Markdown for newcomers. Finally some useful features proposed for scientific publication are explained in more detail.

68 |

Source code of the HTML template and its accompanying class-less CSS file can be found on GitHub [7].

69 |

2. Editor, Math Extension and Configuration

70 |

If you are a programmer, chances are high, that you already have installed and use Visual Studio Code. Otherwise you can install it from here and easily use it as a general non-wysiwyg text editor with excellent Markdown support.

71 |

Getting scientific now we install the VSCode extension markdown+math. You can do it directly from within VSCode via

72 |
View > Extensions 73 |
74 |

Now in VSCode select the menu entry

75 |
File > Preferences > Settings 76 |
77 |

and switch to the mdmath extension Theme 'publication'.

78 |
79 | 80 |
81 |
Fig 1: Setting theme for LaTeX output.

82 |

Now for verifying, that everything works as expected ...

83 | 88 |

You should see something similar to the following yet:

89 |
90 | 91 |
92 |
Fig 2: Markdown Example – Euler's Identity

93 |

Now from the VSCode Command Palette (Ctrl+Shift+P) run the command Markdown: Save Markdown+Math to HTML or simply press (Ctrl+K ,).

94 |

That way we have created an HTML version of our markdown file euler.md named euler.html, both located in the same folder. Viewing it in the browser of your choice gives:

95 |
96 | 97 |
98 |
Fig 3: HTML Output – Euler's Identity

99 |

Having this we can generate a print document euler.pdf quite easily using our browser's print to PDF functionality. You can download a version from here for inspection.

100 |

3. Markdown Overview

101 |

According to the CommonMark specification [2], basic Markdown translates into a limited set of semantic HTML elements.

102 |
<a>, <blockquote>, <code>, <em>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <hr>, <img>, <li>, <ol>, <p>, <pre>, <strong>, <ul> 103 |
104 |

It may be noticeable that not very semantic HTML elements <div> and <span> are missing here. For supporting these list of elements, a small CSS file suffices. Please also take note that Markdown allows to embed plain HTML code when needed.

105 |

3.1 Headings

106 |

Edward Tufte's conventions followed here recommend to use <h1> for the document title only, <h2> for section headings, and <h3> for lower level headings [6]. So for document structuring only two heading levels '##' (<h2>) and '###' (<h3>) are totally sufficient – with reference to famous Feynman lectures on physics [11].

107 |
# Reserved for Document Title `<h1>` 108 | ## Primary Section Headings `<h2>` 109 | ### Secondary Lower Level Headings `<h3>` 110 | #### Not Recommended for Use `<h4> - <h6>` 111 |
112 |

3.2 Paragraph

113 |

Markdown interpretes a sequence of text lines, separated from others by a blank line, as a paragraph and translates it into an HTML <p> element. 114 | In the same way you can't control text wrap with HTML, you cannot do that with Markdown.

115 |

But you might – as an exception to that rule – force a hard line break by using HTML <br> or append at least two trailing spaces at the end of a line.

116 |

3.3 Images

117 |

Markdown images are inline elements with the syntax ![alt text](/path/to/img "title"). These images are displayed side by side.

118 |

If we want to center-align an image and give it a caption, we use the semantic HTML <figure> and <figcaption> elements instead.

119 |
<figure> 120 | <img src="./img/triangle.png"> 121 | <figcaption>Fig 1: The right triangle</figcaption> 122 | </figure> 123 |
124 |
125 | 126 |
Fig 4: Right triangle
127 |
128 |

Images are responsive regarding their size, which we can verify by changing the size of the browser window.

129 |

3.4 Blockquote

130 |

Markdown uses email-style > characters for blockquoting.

131 |
> A human being is part of a whole called by us <q>Universe</q>. 132 | > &mdash; Albert Einstein, *A Man of Many Parts* 133 |
134 |
135 |

A human being is part of a whole called by us Universe.
136 | — Albert Einstein, A Man of Many Parts.

137 |
138 |

In scientific documents Theorems, Lemmas and Proofs are frequently written using blockquote syntax in Markdown.

139 |

3.5 Code Blocks

140 |

We can insert preformatted text in code blocks enclosed by three backticks ``` on its own single line each. Immediatelly following the begin-backticks we may specify the language for syntax highlighting.

141 |
```js 142 | function print({x=0,y=0}) { 143 | return `(${x},${y}`; 144 | }; 145 | ``` 146 | <figcaption>Listing 1: JavaScript function</figcaption> 147 |
148 |

<figcaption> heading might be comfortably used as a code block caption.

149 |
function print({x=0,y=0}) { 150 | return `(${x},${y}`; 151 | }; 152 | console.log(print({x:3,y:4})); 153 |
154 |
Listing 1: JavaScript function
155 |

3.6 Inline Markdown

156 |

Besides regular Markdown inline rules there are some beneficial HTML inline elements.

157 |
Table 2: Some Inline Markdown / Markup
158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 |
Markdown / MarkupResult
*italic text*italic text
**strong text**strong text
***strong italic text***strong italic text
~~strike through~~strike through
<!--stripped comment-->
<u>underlining</u>underlining
Super<sup>script</sup>Superscript
Sub<sub>script</sub>Subscript
<small>Small text for fine print</small>Small text for fine print
<kbd>Alt</kbd>+<kbd>Ctrl</kbd> <kbd>Del</kbd>Alt+Ctrl Del
<abbr title="Cascading Style Sheets">CSS</abbr>CSS
Hilite text with <mark>mark</mark>Hilite text with mark
Hard line<br>break *Hard line
break
<q>... quotation ...</q>... quotation ...
<cite>... citation ...</cite>... citation ...
228 |



229 |

3.7 Table

230 |
<figcaption> Table 3: Column alignment </figcaption> 231 | 232 | | Left | Center | Right | 233 | |:---|:---:|--:| 234 | |L|C|R| 235 |
236 |

We can use a simple syntax for tables, which is a popular extension to the CommonMark standard [3]. Inline rules as shown in Table 2 apply to the table cells. Tables as a whole are always center-aligned.

237 |
Table 3: Column alignment
238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 |
LeftCenterRight
LCR
254 |

3.8 Wrapping Text around figures, listings, etc.

255 | 259 |

This is not a Markdown feature. Also text wrapping is controversial discussed regarding its use in scientific papers. 260 | But if you want that, HTML <aside> comes for help. 261 | HTML specification recommends to use <aside> only for content that is indirectly related to the main article content.

262 |
263 |

Note the general fact, that we can use Markdown text inside of HTML block elements, as long as it starts and ends with a blank line.

264 |
265 |
<aside> 266 | 267 | ![aside image](./img/triangle.png "triangle aside") 268 | <figcaption> Fig. 6: Triangle aside</figcaption> 269 | 270 | </aside> 271 |
272 |

3.9 Math Support

273 |

Math support is the core functionality of mdmath. Inline math r=x2+y2r = \sqrt{x^2 + y^2} and display math expressions

eix=cosx+isinxe^{ix}=\cos x + i\sin x
are supported, due to markdown-it extension markdown-it-texmath [8] and the fast math renderer KaTeX [9]. Commutative diagrams can be used since mdmath version 2.6

284 |
AaBbcC=D\begin{CD} A @>a>> B \\ @VbVV @AAcA \\ C @= D \end{CD}
292 |
... Inline math $r = \sqrt{x^2 + y^2}$ and display math expressions $$e^{ix}=\cos x + i\sin x$$ are supported ... Commutative diagrams can be used since *mdmath* version 2.6 293 | 294 | $$\begin{CD} A @>a>> B \\ @VbVV @AAcA \\ C @= D \end{CD}$$ 295 |
296 |

4. Document Structure

297 |

The visual part of exported HTML document is provided by mdmath template themes/publication/theme.js, which has a simple semantic structure:

298 |
<body> 299 | <header> ... </header> 300 | <main> ... </main> 301 | </body> 302 |
303 |

Your Markdown content will be parsed by markdown-it, the Markdown parser used by VSCode [10]. Resulting HTML output goes then into the <main> section.

304 |

Markdown does not assist you to structure your textual content any further. Especially it does not use HTML <article> and <section> elements. But in fact it doesn't need to, as headings – the remaining structuring elements – are totally sufficient.

305 |

The <header> section contains the paper's title, authors, author addresses, date and keywords. These data are to be found in a Frontmatter metadata section at the beginning of the Markdown file and will also be processed via the template file. The Frontmatter section inside euler.md example has following structure

306 |
--- 307 | "lang": "en", 308 | "title": "Euler's Identity", 309 | "subtitle": "How to combine 5 important math constants to a short formula", 310 | "authors": ["Max Muster<sup>1</sup>", "Lisa Master<sup>2</sup>"], 311 | "adresses": ["<sup>1</sup>Hochschule Gartenstadt","<sup>2</sup>Universität Übersee"], 312 | "date": "May 2021", 313 | "description": "mdmath LaTeX demo site", 314 | "tags": ["markdown+math","VSCode","static page","publication","LaTeX","math"] 315 | --- 316 |
317 |
318 |

Note that Frontmatter syntax used here must strictly obey JSON syntax. So it is more restrictive than YAML based Frontmatter syntaxes.

319 |
320 |

mdmath offers a very basic but useful Table Of Content command. While editing Markdown ...

321 |
    322 |
  1. Invoke comand Insert Table of Content from Command Palette or press Ctrl+K T.
  2. 323 |
  3. Manually remove unwanted ToC entries.
  4. 324 |
  5. Done.
  6. 325 |
326 |

5. Styling

327 |

In order to approach LaTeX look and feel by Markdown authoring, a pure classless CSS stylesheet is needed. You might want to have a look into mdmath's stylesheet.

328 |

There are some LaTeX stylesheets on the web.

329 | 359 |

All of these stylesheets seem to address handmade HTML exclusively. HTML as Markdown export is not mentioned.

360 |

Vincent Dörig's approach looks very promising. Acknowledgment goes to him for providing the Latin Modern Roman typeface font reused with mdmath.

361 |

6. Conclusion

362 |

HTML output provided by the theme publication of mdmath offers a styling with LaTeX look and feel. With it student notes, handouts and scientific papers can be comfortably authored using the Markdown language, while previewing the result in texteditor VSCode. During the Markdown → HTML conversion process math formulas are converted to browser understandable markup. So no script based math renderer is finally needed on the browser side. In fact no script at all is used within resulting HTML output.

363 |

mdmath addresses small to medium sized documents. However for large work as theses and books, available powerful LaTeX packages or – if you want to stick with Markdown – 364 | Pandoc is highly recommended.

365 |

References

366 |

[1] Daring Fireball (https://daringfireball.net/projects/markdown/)
367 | [2] CommonMark (https://commonmark.org/)
368 | [3] CommonMark - Deployed Extensions, (https://tinyurl.com/5bm568tn)
369 | [4] No-Class CSS Frameworks, (https://css-tricks.com/no-class-css-frameworks/)
370 | [5] The Next CSS Frontier — Classless, (https://tinyurl.com/vynsw3ew)
371 | [6] Tufte-CSS, (https://edwardtufte.github.io/tufte-css/)
372 | [7] Markdown+Math (https://github.com/goessner/mdmath)
373 | [8] markdown-it-texmath, (https://github.com/goessner/markdown-it-texmath).
374 | [9] KaTeX, (https://katex.org/)
375 | [10] markdown-it, (https://github.com/markdown-it/markdown-it)
376 | [11] The Feyman Lectures on Physics, (https://www.feynmanlectures.caltech.edu/)

377 | 378 |
379 | 380 | -------------------------------------------------------------------------------- /docs/publication.md: -------------------------------------------------------------------------------- 1 | --- 2 | "lang": "en", 3 | "title": "Web Publications — LaTeX Style", 4 | "subtitle": "Give your Web Publications LaTeX Style", 5 | "authors": ["Stefan Gössner1"], 6 | "adresses": ["1Dortmund University of Applied Sciences. Department of Mechanical Engineering"], 7 | "date": "May 2021", 8 | "description": "mdmath – how to use LaTex theme with markdown", 9 | "tags": ["mdmath","static page","publication","Journal","LaTeX","math"] 10 | --- 11 | ### Abstract 12 | Now there is an easy way to have both, a possibly interactive, static web page containing math and a scientific print document for documentation and publication, 13 | each looking like a professional LaTeX document. All you need is the popular free, open source [*Visual Studio Code* text editor](https://code.visualstudio.com/) with its lightweight extension [*Markdown+Math*](https://marketplace.visualstudio.com/items?itemName=goessner.mdmath) for managing LaTeX style and math syntax as well as using meanwhile ubiquitous Markdown language. The resulting *HTML* document already contains prerendered math formulas, so browsers won't have the burden of math rendering via scripting. 14 | 15 | ## Content 16 | - [1. Introduction](#1-introduction) 17 | - [2. Editor, Math Extension and Configuration](#2-editor-math-extension-and-configuration) 18 | - [3. Markdown Overview](#3-markdown-overview) 19 | - [3.1 Headings](#31-headings) 20 | - [3.2 Paragraph](#32-paragraph) 21 | - [3.3 Images](#33-images) 22 | - [3.4 Blockquote](#34-blockquote) 23 | - [3.5 Code Blocks](#35-code-blocks) 24 | - [3.6 Inline Markdown](#36-inline-markdown) 25 | - [3.7 Table](#37-table) 26 | - [3.8 Wrapping Text around figures, listings, etc.](#38-wrapping-text-around-figures-listings-etc) 27 | - [3.9 Math Support](#39-math-support) 28 | - [4. Document Structure](#4-document-structure) 29 | - [5. Styling](#5-styling) 30 | - [6. Conclusion](#6-conclusion) 31 | - [References](#references) 32 | 33 |





34 | 35 | ## 1. Introduction 36 | 37 | There has been an upward trend in using Markdown language not only for web content, but also for student notes, handouts and scientific papers of small to medium size. Markdown source files are benefitial for viewing, editing and archiving content. Additionally we can generate visually pleasing LaTeX style documents from it 38 | 39 | * as HTML pages possibly containing interactive graphics. 40 | * as static PDF print documents. 41 | 42 | Markdown parsers usually export semantic HTML, i.e. meaningful HTML elements only without using `class` attributes. Styling those HTML documents is accomplished then by using *classless* CSS stylesheets [[4,5](#4)]. Styling semantic HTML with classless CSS ... 43 | 44 | * makes HTML and CSS easy to read and understand. 45 | * results in overall small code size. 46 | * installs no rigid class name dependencies between HTML and CSS. 47 | 48 | Edward Tufte's conventions for styling papers and handouts are followed here as a guidline [[6](#6)]. 49 | 50 | This paper – styled itself as a LaTeX document – first lists the necessary installation aspects in short. After a tiny example of a LaTeX styled markdown document, it gives a quick overview of Markdown for newcomers. Finally some useful features proposed for scientific publication are explained in more detail. 51 | 52 | Source code of the HTML template and its accompanying class-less CSS file can be found on GitHub [[7](#7)]. 53 | 54 | ## 2. Editor, Math Extension and Configuration 55 | 56 | If you are a programmer, chances are high, that you already have installed and use [*Visual Studio Code*](https://code.visualstudio.com/). Otherwise you can install it from [here](https://code.visualstudio.com/) and easily use it as a general non-wysiwyg text editor with excellent Markdown support. 57 | 58 | Getting scientific now we install the VSCode extension [markdown+math](https://marketplace.visualstudio.com/items?itemName=goessner.mdmath). You can do it [directly from within VSCode](https://code.visualstudio.com/docs/editor/extension-marketplace) via 59 | ``` 60 | View > Extensions 61 | ``` 62 | Now in VSCode select the menu entry 63 | ``` 64 | File > Preferences > Settings 65 | ``` 66 | and switch to the *mdmath* extension Theme `'publication'`. 67 | 68 |
69 | 70 |
71 |
Fig 1: Setting theme for LaTeX output.

72 | 73 | Now for verifying, that everything works as expected ... 74 | 75 | * Open a new file in VSCode and save it as `euler.md`. 76 | * Navigate your browser to the example file [`https://raw.githubusercontent.com/goessner/mdmath/master/docs/euler.md`](https://raw.githubusercontent.com/goessner/mdmath/master/docs/euler.md) and copy / paste the markdown text into your open VSCode document. 77 | * Open a preview window to the side (Ctrl+K V). 78 | 79 | You should see something similar to the following yet: 80 | 81 |
82 | 83 |
84 |
Fig 2: Markdown Example – Euler's Identity

85 | 86 | Now from the VSCode Command Palette (Ctrl+Shift+P) run the command `Markdown: Save Markdown+Math to HTML` or simply press (Ctrl+K ,). 87 | 88 | That way we have created an HTML version of our markdown file `euler.md` named `euler.html`, both located in the same folder. Viewing it in the browser of your choice gives: 89 | 90 |
91 | 92 |
93 |
Fig 3: HTML Output – Euler's Identity

94 | 95 | Having this we can generate a print document `euler.pdf` quite easily using our browser's *print to PDF* functionality. You can [download a version from here]() for inspection. 96 | 97 | ## 3. Markdown Overview 98 | 99 | According to the CommonMark specification [[2](#2)], basic Markdown translates into a limited set of semantic HTML elements. 100 | 101 | ```html 102 | ,
, , ,

,

,

,

,

,
,
, ,
  • ,
      ,

      ,

      , , 
        103 | ``` 104 | It may be noticeable that not very semantic HTML elements `
        ` and `` are missing here. For supporting these list of elements, a small CSS file suffices. Please also take note that Markdown allows to embed plain HTML code when needed. 105 | 106 | ### 3.1 Headings 107 | 108 | Edward Tufte's conventions followed here recommend to use `

        ` for the document title only, `

        ` for section headings, and `

        ` for lower level headings [[6](#6)]. So for document structuring only two heading levels `'##'` (`

        `) and `'###'` (`

        `) are totally sufficient – with reference to famous *Feynman* lectures on physics [[11](#11)]. 109 | 110 | ```md 111 | # Reserved for Document Title `

        ` 112 | ## Primary Section Headings `

        ` 113 | ### Secondary Lower Level Headings `

        ` 114 | #### Not Recommended for Use `

        -

        ` 115 | ``` 116 | 117 | ### 3.2 Paragraph 118 | 119 | Markdown interpretes a sequence of text lines, separated from others by a blank line, as a paragraph and translates it into an HTML `

        ` element. 120 | In the same way you can't control text wrap with HTML, you cannot do that with Markdown. 121 | 122 | But you might – as an exception to that rule – force a *hard line break* by using HTML `
        ` or append at least two trailing spaces at the end of a line. 123 | 124 | ### 3.3 Images 125 | 126 | Markdown images are inline elements with the syntax `![alt text](/path/to/img "title")`. These images are displayed side by side. 127 | 128 | If we want to center-align an image and give it a caption, we use the semantic HTML `

        ` and `
        ` elements instead. 129 | ``` 130 |
        131 | 132 |
        Fig 1: The right triangle
        133 |
        134 | ``` 135 | 136 |
        137 | 138 |
        Fig 4: Right triangle
        139 |
        140 | 141 | Images are responsive regarding their size, which we can verify by changing the size of the browser window. 142 | 143 | ### 3.4 Blockquote 144 | 145 | Markdown uses email-style `>` characters for blockquoting. 146 | 147 | ```md 148 | > A human being is part of a whole called by us Universe. 149 | > — Albert Einstein, *A Man of Many Parts* 150 | ``` 151 | > A human being is part of a whole called by us Universe. 152 | > — Albert Einstein, *A Man of Many Parts*. 153 | 154 | In scientific documents *Theorems*, *Lemmas* and *Proofs* are frequently written using blockquote syntax in Markdown. 155 | 156 | ### 3.5 Code Blocks 157 | 158 | We can insert preformatted text in code blocks enclosed by three backticks `` ``` `` on its own single line each. Immediatelly following the begin-backticks we may specify the language for syntax highlighting. 159 | 160 | ```` 161 | ```js 162 | function print({x=0,y=0}) { 163 | return `(${x},${y}`; 164 | }; 165 | ``` 166 |
        Listing 1: JavaScript function
        167 | ```` 168 | `
        ` heading might be comfortably used as a code block caption. 169 | ``` js 170 | function print({x=0,y=0}) { 171 | return `(${x},${y}`; 172 | }; 173 | console.log(print({x:3,y:4})); 174 | ``` 175 |
        Listing 1: JavaScript function
        176 | 177 | ### 3.6 Inline Markdown 178 | 179 | Besides regular Markdown inline rules there are some beneficial HTML inline elements. 180 | 181 |
        Table 2: Some Inline Markdown / Markup
        182 | 183 | | Markdown / Markup | Result | 184 | |:--|:--| 185 | |`*italic text*` |*italic text* | 186 | |`**strong text**` |**strong text** | 187 | |`***strong italic text***` |***strong italic text*** | 188 | |`~~strike through~~` |~~strike through~~ | 189 | |`` | | 190 | |`underlining` |underlining | 191 | |`Superscript` |Superscript | 192 | |`Subscript` |Subscript | 193 | |`Small text for fine print` |Small text for fine print | 194 | |`Alt+Ctrl Del` |Alt+Ctrl Del | 195 | |`CSS` |CSS | 196 | |`Hilite text with mark` | Hilite text with mark | 197 | |`Hard line
        break` * | Hard line
        break | 198 | |`... quotation ...` | ... quotation ... | 199 | |`... citation ...` | ... citation ... | 200 | 201 |

        202 | 203 | ### 3.7 Table 204 | 205 | ``` 206 |
        Table 3: Column alignment
        207 | 208 | | Left | Center | Right | 209 | |:---|:---:|--:| 210 | |L|C|R| 211 | ``` 212 | We can use a simple syntax for tables, which is a popular extension to the CommonMark standard [[3](#3)]. Inline rules as shown in Table 2 apply to the table cells. Tables as a whole are always center-aligned. 213 | 214 |
        Table 3: Column alignment
        215 | 216 | | Left | Center | Right | 217 | |:---|:---:|--:| 218 | |L|C|R| 219 | 220 | 221 | ### 3.8 Wrapping Text around figures, listings, etc. 222 | 223 | 229 | 230 | This is not a Markdown feature. Also text wrapping is controversial discussed regarding its use in scientific papers. 231 | But if you want that, HTML `