Class: Kramdown::Parser::KramdownGist

Inherits:
Kramdown
  • Object
show all
Defined in:
lib/kramdown-gist/parser/kramdown.rb

Overview

Standard Kramdown parser with support for embedding GitHub Gists in the output.

This class extends the default Kramdown syntax with a new block-level element for embedding gists: *{gist:<id>}. The element is rendered as a <script> tag pointing to http://gist.github.com/<id>.js.

Author:

  • Matteo Panella

Instance Method Summary collapse

Constructor Details

#initialize(source, options) ⇒ KramdownGist

Create a new gist-enabled Kramdown parser with the given options.



35
36
37
38
# File 'lib/kramdown-gist/parser/kramdown.rb', line 35

def initialize(source, options)
  super
  @block_parsers.unshift(:gist)
end

Instance Method Details

#parse_gistObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Do not use this method directly, it's used internally by Kramdown.



46
47
48
49
50
# File 'lib/kramdown-gist/parser/kramdown.rb', line 46

def parse_gist
  @src.pos += @src.matched_size
  gist_id = @src[1]
  @tree.children << Element.new(:gist, gist_id)
end