Repository navigation
feat(html): declarative element rules - #37
Merged
Merged
Conversation
chaliy
force-pushed
the
claude/project-thread-2rc0mr
branch
2 times, most recently
from
October 27, 2026 01:44
73fd520 to
55a6c9e
Compare
- rules::HtmlRule { selector, action } with ElementAction (skip, unwrap,
heading, paragraph, block_quote+title, code_block, inline_code, bold,
italic, text); serde JSON shape
- MarkkitBuilder::html_rule / html_rules; tried before built-in mapping,
invalid selectors fail with Error::HtmlParse
- CLI: markkit extract --rules rules.json
chaliy
force-pushed
the
claude/project-thread-2rc0mr
branch
from
October 27, 2026 02:17
55a6c9e to
c5dd25b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Михайло · project thread
What changed
Site-specific HTML handling without writing Rust: map CSS selectors to IR actions.
rules::HtmlRule { selector, action }withElementAction:skip,unwrap,heading{level},paragraph,block_quote{title},code_block{language},inline_code,bold,italic,text.MarkkitBuilder::html_rule(sel, action)/html_rules(..). Rules are checked before the built-in element mapping; the first matching rule wins. Invalid selectors fail at extraction withError::HtmlParse.{"selector": ".callout", "action": "block_quote", "title": "Note"}), so rules can live in config files.markkit extract --rules rules.json(works alongside--base-url).<script>,<style>, forms, etc.**Breaking:**in CHANGELOG).Why
Roadmap "Extensibility": callouts, keyboard keys, ad blocks and doc-site widgets each need custom mapping. Before, the only knobs were include/exclude selectors.
Before / After
<div class="callout"><p>Heads up</p></div><span class="kbd">Ctrl</span> + C<div class="ad">Buy now</div>Before (
markkit extract --file p.html):After (
--rules r.jsonwith.callout→block_quote"Note",.kbd→inline_code,.ad→skip):No rules configured: output unchanged.
Risk
MAX_DEPTH) and pre-stripping as built-in mapping (html_security::element_rules_respect_depth_limit,element_rules_cannot_resurrect_stripped_elements).code_block/inline_codecontent goes through the existing fence and backtick escaping.Checklist
--ruleshappy path + bad file, security)formats/html-extraction.md, log), README CLI, CHANGELOG, AGENTS.md