• Stars
    star
    107
  • Rank 312,735 (Top 7 %)
  • Language
    Crystal
  • License
    MIT License
  • Created almost 7 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Yet another markdown parser, Compliant to CommonMark specification, written in Crystal.

markd

Language Tag Build Status

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 let me know.


Yet another markdown parser built for speed, written in Crystal, Compliant to CommonMark specification (v0.29). 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 are 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)
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.
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 <base href="base_url"> in the context of a Markdown document.

Advanced

If you want to use a 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

Here is the result of a sample markdown file 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.

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

More Repositories

1

EFI-ASRock-Z390-Phantom-Gaming-ITX

Mini ITX 4k 视频剪辑黑苹果 macOS 13 Ventura OpenCore EFI since from OS X 10.14.5
285
star
2

halite

💎HTTP Requests Client with a chainable REST API, built-in sessions and middlewares.
Crystal
172
star
3

fast-crystal

💨 Writing Fast Crystal 😍 -- Collect Common Crystal idioms.
Crystal
167
star
4

hpr

镜像任意 git 仓库到 gitlab 的同步工具,具有定时更新的功能
Ruby
86
star
5

totem

Crystal configuration with spirit. Load and parse configuration in JSON, YAML, dotenv formats.
Crystal
65
star
6

anne-keyboard

Unofficial Anne Keyboard Resources - 安妮机械键盘相关资料
58
star
7

kohana-douban

Douban API Package (PHP版本) 基于 Kohana 开发 (`master` for v3.0.x / `develop` for v3.2.x)
PHP
48
star
8

app-info

Teardown tool for mac, windows and mobile app (ipa, apk and aab file) and dSYM.zip file, analysis metedata like version, name, icon etc.
Ruby
44
star
9

swagger

Swagger contains a OpenAPI / Swagger universal documentation generator and HTTP server handler.
Crystal
40
star
10

poncho

A .env parser/loader improved for performance.
Crystal
30
star
11

gitlab.cr

Gitlab.cr is a GitLab API wrapper written by Crystal
Crystal
29
star
12

dotfiles

icyleaf's dotfiles apply for macOS (includes macos tricks)
Shell
27
star
13

popcorn

Easy and Safe popping from one type to another.
Crystal
25
star
14

alpaca

A swift, lightweight forum system
PHP
25
star
15

fastlane-plugins

自创造超实用性 Fastlane 插件和自定义 actions 的聚合仓库
Ruby
21
star
16

wasp

A Static Site Generator written in Crystal.
JavaScript
20
star
17

salt

**Unmaintained** A Human Friendly Interface for HTTP server written in Crystal.
Crystal
19
star
18

qihu360

360.cn 点睛营销平台(广告竞价排名系统) API Ruby 封装.
Ruby
18
star
19

modou

豆瓣非官方移动 (附赠豆瓣 API 测试平台) 项目源码
PHP
18
star
20

EasyConvert

Easy convert GBK(2312/18030) to UTF-8 for Mac
Objective-C
16
star
21

EFI-ASUS-B150M-A-D3-QL3X

华硕 B150M A D3 + QL3X + 独显 + UHD630 核显 macOS 12 Monterey OpenCore EFI
13
star
22

fish-pkg-git

This plugin adds many useful git aliases and functions for fish shell
Shell
10
star
23

terminal

Terminal output styling with intuitive, clean and easy API written by Crystal.
Crystal
9
star
24

wechat-bot

还不知道如何走向的微信机器人
Ruby
9
star
25

icyleaf.com

Host on Github page
JavaScript
8
star
26

xiaomi-push

(unofficial) xiaomi push server sdk for ruby - 非官方小米推送服务端 Ruby SDK
Ruby
8
star
27

openwrt-autobuilder

Openwrt amd64 (x86 64bit) CPU 自動鏡像生成
Shell
7
star
28

beijing-points-based-hukou

北京积分落户数据库
6
star
29

fastlane-plugin-ci_changelog

Automate generate changelog between previous built failed and the latest commit of scm in CI
Ruby
6
star
30

kohana-dbmanager

Database Manager For Kohana v3.0.x
PHP
5
star
31

fish-pkg-docker

Automate loading default docker-machine environment and add missing tab completion for Fish Shell.
Shell
4
star
32

HTTPProxy

iOS HTTP Proxy: A network debugging tool for iOS
Swift
4
star
33

fastlane-plugin-humanable_build_number

Automatic set app build number unque and human readable friendly
Ruby
4
star
34

alpine-hexo

Minimal Hexo Docker Images (176MB or 56 MB compressed)
Nginx
4
star
35

fish-pkg-pod

This plugin add cocoapods competions for fish shell
Shell
4
star
36

awesome-hackintosh

A curated list of awesome articles, kexts, tools and shiny things for Hackintosh.
3
star
37

better-cli-solution

🤹 Better CLI Solution
3
star
38

fastlane-plugin-app_info

Teardown tool for mobile app(ipa/apk), analysis metedata like version, name, icon etc.
Ruby
3
star
39

app_status_notification

🎉 Quick deliver your app(s) review status with your team for mostly platforms like Slack, Dingtalk, WeChat work etc
Ruby
3
star
40

elong

Elong OpenAPI sdk wrapper for ruby
Ruby
2
star
41

guard-webpacker

Guard::Webpacker automatically runs webpacker-dev-server/webpack from rails-webpacker.
Ruby
2
star
42

fastlane-plugin-update_jenkins_build

Update build's description of jenkins.
Ruby
2
star
43

kohana-cli

command line tools for Kohana v3
PHP
2
star
44

ansible-centos-ruby-nginx-posgresql

Ansible delpoy centos + ruby + nginx + postgresql
Vim Script
2
star
45

qyer-mobile-app

穷游移动团队专用分发命令行工具
Ruby
2
star
46

colorful.cr

**Unmaintained** Colors in your terminal writes with Crystal Language.
Crystal
2
star
47

fastlane-plugin-upload_to_qmobile

Upload mobile app to qmobile sytem
Ruby
1
star
48

docker-images

Customize docker images box
Dockerfile
1
star
49

acme-extractor

The best extract certificates tool from acme.json (traefik).
Ruby
1
star
50

openwrt-dist

1
star
51

fastlane-plugin-android_channels

Package unsign apk with channels and sign it
Ruby
1
star
52

any_merge

Crystal
1
star
53

ChromeExtension-dbObject

批量喜欢友邻刷屏的豆瓣东西。
JavaScript
1
star
54

cloudflare-workers-kv-action

A GitHub action to Put and get values from Cloudflare Workers KV action.
JavaScript
1
star