Class: LLM::Console::Markdown::Parser

Inherits:
Kramdown::Parser::Kramdown
  • Object
show all
Defined in:
lib/llm/console/markdown/parser.rb

Overview

Treats HTML and smart punctuation as plain text. Keep each parser registered (so kramdown's sub-parser lists, eg tables, still resolve) but point it at a no-op that emits the matched text literally instead of parsing it.

Tables are enabled but only match when a header row is followed by a delimiter row (---). This breaks from default kramdown behavior which parses |foo| as a table.

Constant Summary collapse

LITERAL =

Swap these parser slots for literal-text no-ops.

%i[span_html block_html smart_quotes typographic_syms]
TABLE_START =

A table starts with a header row that holds a pipe and a delimiter row (---). A lone |foo| in prose is not a table, so this matches only when a delimiter follows.

/^[ \t]*(?=\S)#{TABLE_LINE}(?=#{TABLE_SEP_LINE})/m

Instance Method Summary collapse

Instance Method Details

#configure_parser ⇒ Object



25
26
27
28
29
# File 'lib/llm/console/markdown/parser.rb', line 25

def configure_parser
  super
  LITERAL.each { |name| swap(name, :"parse_#{name}") }
  swap_table!
end