Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timhaj/md2html
Markdown to HTML parser
https://github.com/timhaj/md2html
html javascript javascript-library markdown markdown-to-html parser
Last synced: 20 days ago
JSON representation
Markdown to HTML parser
- Host: GitHub
- URL: https://github.com/timhaj/md2html
- Owner: timhaj
- Created: 2024-09-17T13:04:30.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-18T19:21:10.000Z (4 months ago)
- Last Synced: 2024-10-31T11:25:44.878Z (2 months ago)
- Topics: html, javascript, javascript-library, markdown, markdown-to-html, parser
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# md2HTML
A lightweight markdown to HTML parser (5 kB standrad, 3 kB .min version).## Usage
- Download `main.js` or `main.min.js` if you're having to much overhead (weird, but ok).
- Make sure you're using the correct markdown syntax, as shown [here](https://www.markdownguide.org/cheat-sheet/).
- You can use it in two ways:
- Static: by just calling `md2HTML()`, the parser will select all div's with `md2HTML` class, and apply the parsing inside its text content.
- Dynamic: by calling `div.innerHTML = md2HTMLParseElementText(div.textContent)`, the parser will parse the text inside the div text contents you passed as a argument.
- See `demo.html` for a example how the parser works.## Supports the following markdown elements:
- Headings
- Bold
- Italic
- Code emphasis
- Blockquote
- Ordered list
- Unordered list
- Horizontal rule
- Link
- Image
- Code blocks
- Tables## Markdown elements and their conversions in HTML:
| Markdown element | HTML conversion |
| :----: | :----: |
| # Heading | `Heading
` |
| ## Heading | `Heading ` |
| ### Heading | `Heading ` |
| #### Heading | `Heading ` |
| ##### Heading | `Heading ` |
| ###### Heading | `Heading ` |
| `**Bold**` | `Bold` |
| `*Italic*` | `Italic` |
| `Code emphasis` (has ` ) | `Code emphasis
` |
| `> Quote` | `Quote` |
| `***` | `
` |
| `---` | `
` |
| `___` | `
` |
| `[Title](https://link.to.somewhere)` | `Title` |
| `![Alt text](img.png)` | `` |## Contributions, issues,...
- Found any issues or want to add other complex/extended markdown syntax? Simply open a issue/PR!