Repository navigation
Add entangled weave command for transforming Markdown - #103
Merged
Merged
Conversation
Adds a renderer-agnostic Markdown transform API in `entangled.weave` (`transform_markdown`, `ContentFilter`, `codeblock_filter`, `compose_filters`) and an `entangled weave` command exposing it, with `--list-filters` and two filters: - `label`: wrap named code blocks in a labelled `<div>`, rendering in most Markdown previews. - `title`: add a pymdownx-style `title` attribute to the code block header (port of the mkdocs-plugin's `add_title`). Logging now goes to stderr so that `weave` output on stdout is clean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Addresses #102.
Summary
entangled.weavepackage with a renderer-agnostic transform API:transform_markdown(context, text, *filters, filename=..., reference_map=None) -> Iterator[str],plus the generic helpers moved from the mkdocs-plugin (
ContentFilter,codeblock_filter,compose_filters,iter_bind).The optional
reference_mapleaves room for project-wide references across pages.entangled weave [-f filter]... [-o output] [input]command (stdin/stdout by default,labelfilter by default), with--list-filters.label: wraps code blocks that have an id orfile=in<div class="entangled-code-block" markdown="1">with a label line. Renders in GitHub, Pandoc and Python-Markdown (md_in_html+attr_list). Known limitation: Python-Markdown doesn't processmd_in_htmlinside list items.title: port of the plugin'sadd_title, adding a pymdownx-styletitleattribute; keeps the original fence.weaveoutput on stdout isn't mixed with log messages. This affects all commands.More advanced filters (e.g. REPL output) are left for later.
Test plan
uv run pytest(82 passed, 6 new intest/weave/test_weave.py)mypyandpyrightclean on the new modulestest/data/hello-world/hello-world.mdwith Pandoc and Python-Markdown🤖 Generated with Claude Code