Code Monkey home page Code Monkey logo

markd's Introduction

markd

Language Tag Build Status

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.

Donate

Markd is a open source, collaboratively funded project. If you run a business and are using Markd in a revenue-generating product, it would make business sense to sponsor Markd development. Individual users are also welcome to make a one time donation if Totem has helped you in your work or personal projects.

You can donate via Paypal.

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 are on the wall.

You may also like

  • halite - HTTP Requests Client with a chainable REST API, built-in sessions and middlewares.
  • totem - Load and parse a configuration file or string in JSON, YAML, dotenv formats.
  • poncho - A .env parser/loader improved for performance.
  • popcorn - Easy and Safe casting from one type to another.
  • fast-crystal - 💨 Writing Fast Crystal 😍 -- Collect Common Crystal idioms.

License

MIT License © icyleaf

markd's People

Contributors

icyleaf avatar straight-shoota avatar xfbs avatar woodruffw avatar

Watchers

Elaine Jackson-Pimentel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.