Giter VIP home page Giter VIP logo

parser-gfm's Introduction

kramdown GFM parser

This is a parser for kramdown that converts Markdown documents in the GFM dialect to HTML.

Note: Until kramdown version 2.0.0 this parser was part of the kramdown distribution.

Installation

gem install kramdown-parser-gfm

Usage

require 'kramdown'
require 'kramdown-parser-gfm'

Kramdown::Document.new(text, input: 'GFM').to_html

Documentation

At the moment this parser is based on the kramdown parser, with the following changes:

  • Support for fenced code blocks using three or more backticks has been added.
  • Hard line breaks in paragraphs are enforced by default (see option hard_wrap).
  • ATX headers need a whitespace character after the hash signs.
  • Strikethroughs can be created using two tildes surrounding a piece of text
  • Blank lines between paragraphs and other block elements are not needed by default (see option gfm_quirks)

Please note that the GFM parser tries to mimic the parser used at GitHub which means that for some special cases broken behaviour is the expected behaviour.

Here is an example:

This ~~is a complex strike through *test ~~with nesting~~ involved* here~~.

In this case the correct GFM result is:

<p>This <del>is a complex strike through *test ~~with nesting</del> involved* here~~.</p>

Options

The GFM parser provides the following options:

  • hard_wrap: Interprets line breaks literally (default: true)

    Insert HTML <br /> tags inside paragraphs where the original Markdown document had newlines (by default, Markdown ignores these newlines).

  • gfm_quirks: Enables a set of GFM specific quirks (default: paragraph_end)

    The way how GFM is transformed on GitHub often differs from the way kramdown does things. Many of these differences are negligible but others are not.

    This option allows one to enable/disable certain GFM quirks, i.e. ways in which GFM parsing differs from kramdown parsing.

    The value has to be a list of quirk names that should be enabled, separated by commas. Possible names are:

    • paragraph_end

      Disables the kramdown restriction that at least one blank line has to be used after a paragraph before a new block element can be started.

      Note that if this quirk is used, lazy line wrapping does not fully work anymore!

    • no_auto_typographic

      Disables automatic conversion of some characters into their corresponding typographic symbols (like -- to em-dash etc). This helps to achieve results closer to what GitHub Flavored Markdown produces.

Development

Clone the git repository and you are good to go. You'll probably want to install rake to use the provided rake tasks.

Run rake --tasks to view a list of available tasks.

License

MIT - see the COPYING file.

parser-gfm's People

Contributors

ashmaroli avatar gettalong avatar

Watchers

James Cloos 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.