Module: MDOM::InlineParser

Defined in:
lib/mdom/inline_parser.rb

Overview

Tokenizes a run of inline text into inline nodes: Text, Emphasis, Strong, Code, Link, Image, Softbreak, Hardbreak and escaped characters.

This is a pragmatic subset of CommonMark inline syntax. Code spans and links/images are matched textually; emphasis/strong is resolved by finding the next matching delimiter and recursing into the enclosed text. Delimiter runs and exact flanking rules are intentionally simplified.

Defined Under Namespace

Classes: Scanner

Constant Summary collapse

ESCAPABLE =
/[\x00`*_{}\[\]()#+\-.!>]/.freeze
SPECIAL =
/[\\`!*_\[\n]/.freeze

Class Method Summary collapse

Class Method Details

.parse(source) ⇒ Object



17
18
19
# File 'lib/mdom/inline_parser.rb', line 17

def parse(source)
  Scanner.new(source.to_s).read_nodes
end