https://github.com/matmoore/markdown-parser
A home made artisanal markdown parser
https://github.com/matmoore/markdown-parser
exercise
Last synced: 7 months ago
JSON representation
A home made artisanal markdown parser
- Host: GitHub
- URL: https://github.com/matmoore/markdown-parser
- Owner: MatMoore
- Created: 2020-05-31T14:28:07.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-22T19:37:31.000Z (about 4 years ago)
- Last Synced: 2025-04-02T22:29:59.502Z (about 1 year ago)
- Topics: exercise
- Language: Ruby
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Markdown parser
A home made artisanal markdown parser.
This parses a very small subset of markdown. It can generate formatted text in a console, using ANSI escape sequences.
## Usage
`ruby markdown_parser.rb < example.md`

## How it works
The project is split into 4 components:
- [tokenizer.rb](tokenizer.rb) - splits text into a sequence of tokens
- [parser.rb](parser.rb) - builds an abstract syntax tree (AST) from the tokens
- [generator.rb](generator.rb) - generates formatted text from the AST (using the [visitor pattern](https://en.wikipedia.org/wiki/Visitor_pattern))
- [markdown_parser.rb](markdown_parser.rb) - a simple command line interface
## References
- [Writing a Markdown Compiler](https://blog.beezwax.net/2017/07/07/writing-a-markdown-compiler/)
## Licence
MIT