Hwaro::Content::Processors::MarkdownAttributes
Constants
(?<![\w-]) guards keep data-id=/data-class= from counting
as the element's own id/class.
One token: #id, .class, or key=value/key="quoted value".
\G anchors each successive match at the end of the previous one
(via the pos argument to match), so a run of intervening
whitespace is consumed but any OTHER leftover text — a token that
matches none of the three forms — breaks the chain and shows up
as residue, which invalidates the whole block.
Capture groups: 1 = #id token (with #), 2 = .class token
(with .), 3 = kv key, 4 = kv value (quotes included if quoted),
5 = kv value's inner text when quoted (nil when bare).
Instance methods
Merges parsed into an <img ... tag's opening portion (up to,
but NOT including, its />/> closer — the caller re-appends the
original closer so self-closing style is preserved untouched).
Merges id (replace-or-append) and classes
(merge-into-existing-or-add) into an existing heading tag's
attribute string (e.g. class="foo", or "" when the tag had
no attributes), matching postprocess_heading_ids's formatting
byte-for-byte for the id case.
Inverse of encode. nil on any malformed (odd-length / non-hex)
payload — never raises.
Hex-encodes block_inner (the RAW, still-unparsed {...} contents)
so it can ride through Markd's render inside an HTML comment
without needing its own comment-safe escaping — hex is immune to
-->/</& entirely.
Parses the inside of a {...} block (braces already stripped).
Returns nil when the block is empty, contains a token matching
none of the three forms, or has unconsumed non-whitespace residue
between/after valid tokens.