Markdown To HTML Viewer
I'm getting tired of writing large markdown files in VS code only to not know what the resulting HTML will look like (actually, there are a couple good extensions for this - I use the Markdown Preview Enhanced extension), so I created this page with codemirror and marked js that shows what the resulting HTML will look like when markdown is transformed to HTML and put in the form of my design system.
As mentioned above, there are actually good extensions for rendering markdown to HTML, but I want to keep track of my notes on this website, and I also need to be able to translate my Lexical Implementation from and to Markdown, so I went ahead and tried to create this.
I haven't finished implementing this. I need to learn more about / get better at regular expressions before trying to add more features to the markdown parser, but I wanted to move on to different things, so this is its current state.
This is a custom implementation of Markdown, and there are custom features beyond the Basic Syntax.
The marked katex extension allows you to render katex code inline and with a block element. To render elements inline, wrap the katex expression in single dollar signs ($).
$x^{2}+y^{2}=z^{2}$
Results in:
You can render block Katex elements by wrapping the expression in double dollar signs or a fenced block with an info string of math. If you use the double dollar sign, the katex will be rendered in the primary text color and will inherit the page background, else the katex expression will be rendered with a white background, black text, and will be able to be copied.
$$x^{2}+y^{2}=z^{2}$$
```math
x^{2}+y^{2}=z^{2}
```
The marked-extended-tables plugin allows for cells that span multiple columns / rows and for multi-row headers.
For some reason, this is not working properly right now.
Column Spanning:
| H1 | H2 | H3 |
|---------|---------|---------|
| This cell spans 3 columns |||
Row Spanning:
| H1 | H2 |
|--------------|---------|
| This cell | Cell A |
| spans three ^| Cell B |
| rows ^| Cell C |
Multi-row Headers:
| This header spans two || Header A |
| columns *and* two rows ^|| Header B |
|-------------|------------|----------|
| Cell A | Cell B | Cell C |
At the very least, I should try to implement the rest of what is included in the extended markdown syntax.
Also, for the code editor below, and for the website in general, I should probably implement better CTRL+F search functionality. (Regex Search and styling).
Also, the parsing is pretty slow right now, which needs to be improved.