module

Hwaro::Content::Processors::TableParser

Constants

BLOCKQUOTE_PREFIX_RE = /\A {0,3}> ?/

The blockquote marker of a single-level quote line: up to three spaces of indentation, >, and the optional following space (CommonMark's block quote marker). Nil for anything else — including a nested > > quote, whose inner content is left to the paragraph path as before.

TABLE_SEPARATOR_CHECK = /^\s*(?:> ?)?\s*\|?\s*:?-+:?\s*\|/m

Quick check if content might contain tables. Detects the separator row pattern which is the definitive marker of a markdown table (e.g. |---|---| or ---|---). This avoids false positives from random | in code blocks, URLs, or inline code while still catching tables with or without leading/trailing pipes. -+, not -{3,}: GFM's delimiter cell is :?-+:?, so |:-:|, |:--| and | - | are all valid tables. Requiring three hyphens silently demoted every short ALIGNED row (|:--|--:|) to a paragraph of literal pipes — the plain |---|---| form happened to clear the bar, so the bug only showed up once an author added alignment. The optional > lets a table quoted inside a blockquote (or an admonition body) past this gate; process then parses it through blockquote_prefix.

Instance methods

has_table?(content : String) : Bool
Source
process(content : String, *, math : Bool = false, flags : InlineMarkdown::Flags | Nil = nil, hooks : RenderHooks::HookRenderContext | Nil = nil, trusted : Bool = false) : String

Process markdown content and convert tables to HTML Tables are converted to HTML placeholders, then markd processes the rest, and placeholders are replaced with actual HTML tables. math: true keeps $…$ spans in cells untransformed for the later math pass. flags (when given) takes precedence over math and also threads the F10 inline markup flags (ins/mark/sub/sup) into cell rendering. hooks routes each table through the render-table hook (see Table#to_html); nil keeps the stock output. trusted (safe mode) marks the emitted markup, see MarkdownExtensions.trust.

Source
separator_row?(line : String) : Bool

Check if a line is a separator row (contains dashes and optional colons)

Source
table_row?(line : String) : Bool

Check if a line looks like a table row (contains pipe characters)

Source

Nested types