telegram_markd

Yet another markdown parser, Compliant to CommonMark specification, written in Crystal.
0.1.1 Latest release released

This repo seems to be no longer available at policr-community/telegram_markd.

Git synchronization failed . Last successful sync was .

Help find it again! … or have it archived.

markd

Tag Dependency Status devDependency Status Build Status License

Yet another markdown parser built for speed, written in Crystal, Compliant to CommonMark specification (v0.27). Copy from commonmark.js.

Installation

Add this to your application's shard.yml:

dependencies:
  markd:
    github: icyleaf/markd

Quick start

require "markd"

markdown = <<-MD
# Hello Markd

> Yet another markdown parser built for speed, written in Crystal, Compliant to CommonMark specification.
MD

html = Markd.to_html(markdown)

Also here is an options to configure the parse and render.

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) gfm | Bool | false | Not support for now toc | Bool | false | Not support for now

Advanced

If you want use custom renderer, it can!


class CustomRenderer < Markd::Renderer

  def strong(node, entering)
  end

  # more methods following in render.
end

options = Markd::Options.new(time: true)
document = Markd::Parser.parse(markdown, options)
renderer = CustomRenderer.new(options)

html = renderer.render(document)

Performance

First of all, Markd is slower than Crystal Built-in Markdown which it is a lite version, only apply for generte Cystal documents (#4496, #4613).

Here is the result of a sample markdown file parse at MacBook Pro Retina 2015 (2.2 GHz):

Crystal Markdown   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.

Contributing

  1. Fork it ( https://github.com/icyleaf/markd/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

telegram_markd:
  github: policr-community/telegram_markd
  version: ~> 0.1.1
License MIT
Crystal 0.24.2

Authors

Dependencies 0

Development Dependencies 0

Dependents 1

Last synced .
search fire star recently