Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/icyleaf/markd
Yet another markdown parser, Compliant to CommonMark specification, written in Crystal.
https://github.com/icyleaf/markd
commonmark crystal gfm markdown markdown-flavors
Last synced: 29 days ago
JSON representation
Yet another markdown parser, Compliant to CommonMark specification, written in Crystal.
- Host: GitHub
- URL: https://github.com/icyleaf/markd
- Owner: icyleaf
- License: mit
- Created: 2017-06-03T16:44:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-05T05:47:35.000Z (6 months ago)
- Last Synced: 2024-11-06T07:12:07.213Z (about 1 month ago)
- Topics: commonmark, crystal, gfm, markdown, markdown-flavors
- Language: Crystal
- Homepage:
- Size: 656 KB
- Stars: 109
- Watchers: 8
- Forks: 31
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - markd - Yet another markdown parser built for speed, Compliant to CommonMark specification (Markdown/Text Processors)
- awesome-crystal - markd - Yet another markdown parser built for speed, Compliant to CommonMark specification (Markdown/Text Processors)
- awesome-crystal - markd - Yet another markdown parser built for speed, Compliant to CommonMark specification (Markdown/Text Processors)
README
# markd
[![Language](https://img.shields.io/badge/language-crystal-776791.svg)](https://github.com/crystal-lang/crystal)
[![Tag](https://img.shields.io/github/tag/icyleaf/markd.svg)](https://github.com/icyleaf/markd/blob/master/CHANGELOG.md)
[![Build Status](https://img.shields.io/circleci/project/github/icyleaf/markd/master.svg?style=flat)](https://circleci.com/gh/icyleaf/markd)**THIS PROJECT IS LOOKING FOR MAINTAINER**
Unfortunately, the maintainer no longer has the time and/or resources to work on markd further. This means that bugs will not be fixed and features will not be added unless someone else does so.
If you're interested in fixing up markd, please [file an issue](https://github.com/icyleaf/markd/issues/new) let me know.
Yet another markdown parser built for speed, written in [Crystal](https://crystal-lang.org), Compliant to [CommonMark](http://spec.commonmark.org) specification (`v0.29`). Copy from [commonmark.js](https://github.com/jgm/commonmark.js).
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
markd:
github: icyleaf/markd
```## Quick start
```crystal
require "markd"markdown = <<-MD
# Hello Markd> Yet another markdown parser built for speed, written in Crystal, Compliant to CommonMark specification.
MDhtml = Markd.to_html(markdown)
```Also here are options to configure the parse and render.
```crystal
options = Markd::Options.new(smart: true, safe: true)
Markd.to_html(markdown, options)
```## Options
| Name | Type | Default value | Description |
| ----------- | ------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| time | `Bool` | false | render parse cost time during read source, parse blocks, parse inline. |
| smart | `Bool` | false | if **true**, straight quotes will be made curly,
`--` will be changed to an en dash,
`---` will be changed to an em dash, and
`...` will be changed to ellipses. |
| source_pos | `Bool` | false | if **true**, source position information for block-level elements
will be rendered in the data-sourcepos attribute (for HTML) |
| safe | `Bool` | false | if **true**, raw HTML will not be passed through to HTML output (it will be replaced by comments) |
| prettyprint | `Bool` | false | if **true**, code tags generated by code blocks will have a `prettyprint` class added to them, to be used by [Google code-prettify](https://github.com/google/code-prettify). |
| gfm | `Bool` | false | **Not supported for now** |
| toc | `Bool` | false | **Not supported for now** |
| base_url | `URI?` | nil | if not **nil**, relative URLs of links are resolved against this `URI`. It act's like HTML's `` in the context of a Markdown document. |## Advanced
If you want to use a custom renderer, it can!
```crystal
class CustomRenderer < Markd::Renderer
def strong(node, entering)
end# more methods following in render.
endoptions = Markd::Options.new(time: true)
document = Markd::Parser.parse(markdown, options)
renderer = CustomRenderer.new(options)html = renderer.render(document)
```## Performance
Here is the result of [a sample markdown file](benchmarks/source.md) parse at MacBook Pro Retina 2015 (2.2 GHz):
```
Crystal Markdown (no longer present) 3.28k (305.29ยตs) (ยฑ 0.92%) fastest
Markd 305.36 ( 3.27ms) (ยฑ 5.52%) 10.73ร slower
```Recently, I'm working to compare the other popular commonmark parser, the code is stored in [benchmarks](/benchmarks).
## How to Contribute
Your contributions are always welcome! Please submit a pull request or create an issue to add a new question, bug or feature to the list.
All [Contributors](https://github.com/icyleaf/markd/graphs/contributors) are on the wall.
## You may also like
- [halite](https://github.com/icyleaf/halite) - HTTP Requests Client with a chainable REST API, built-in sessions and middlewares.
- [totem](https://github.com/icyleaf/totem) - Load and parse a configuration file or string in JSON, YAML, dotenv formats.
- [poncho](https://github.com/icyleaf/poncho) - A .env parser/loader improved for performance.
- [popcorn](https://github.com/icyleaf/popcorn) - Easy and Safe casting from one type to another.
- [fast-crystal](https://github.com/icyleaf/fast-crystal) - ๐จ Writing Fast Crystal ๐ -- Collect Common Crystal idioms.## License
[MIT License](https://github.com/icyleaf/markd/blob/master/LICENSE) ยฉ icyleaf