Class: Kramdown::Parser::MarkdownLint

Inherits:
Kramdown
  • Object
show all
Defined in:
lib/mdl/kramdown_parser.rb

Overview

modified parser class - see comment above

Constant Summary collapse

FENCED_CODEBLOCK_MATCH =

GFM fenced code blocks, extended to allow spaces in the info string (e.g. ```c hlines=2). The GFM regex restricts the info string to a single non-whitespace token, which causes kramdown to miss blocks whose info string contains a space, leading to false positives inside them. Capture groups match GFM's: 1=fence, 2=fence-char, 3=full-info, 4=first-word, 5=content.

/^ {0,3}(([~`]){3,})\s*?((\S+?)[^\n]*)?\n(.*?)^ {0,3}\1\2*\s*?\n/m
PARAGRAPH_END =

End paragraphs when a fenced code block starts, matching GFM behavior. Without this, fenced code blocks without a preceding blank line are swallowed into the paragraph.

Regexp.union(
  Kramdown::Parser::Kramdown::PARAGRAPH_END,
  Kramdown::Parser::GFM::FENCED_CODEBLOCK_START,
)

Instance Method Summary collapse

Constructor Details

#initialize(source, options) ⇒ MarkdownLint

Returns a new instance of MarkdownLint.



10
11
12
13
14
15
# File 'lib/mdl/kramdown_parser.rb', line 10

def initialize(source, options)
  super
  i = @block_parsers.index(:codeblock_fenced)
  @block_parsers.delete(:codeblock_fenced)
  @block_parsers.insert(i, :codeblock_fenced_gfm)
end