Add wikilink rendering extension#222
Open
soreavis wants to merge 1 commit into
Open
Conversation
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.
Adds support for
[[wikilinks]](closes #63). cmark-gfm reserves[for its own link parser, so this is a post-processcmark-extraextension (wikilink.c) modeled on cmark-gfm's ownautolink— it splits text nodes after parsing, leaving the cmark engine untouched.[[Page Name]]and[[Target|Display]]are rewritten into styled links:→
Behaviour
[/]— so ordinary text, malformed/nested brackets, code spans, and existing Markdown links are left untouched.[[Target|Display]]splits on the first|(target →href, the rest → label);[[Target|]]falls back to the target as the label.houdini-escaped into thehrefand dangerous URLs (javascript:…) are dropped in safe mode — identical to how cmark renders native links; labels are HTML-escaped. (Validated under AddressSanitizer +leakson adversarial input: no over-reads, use-after-free, or leaks.)default.cssstyles.wikilink(light#8250df/ dark#ab7df8), distinct from regular links.How it's exposed
--wikilink on|offoption.wikilinkExtensionflag (Codable+ app-group defaults), defaulting to off.Examples
examples/test-wikilink.md(basic, aliased, paths, multiple-per-line, plus the edge cases: empty/whitespace markers, malformed brackets, code spans, Markdown-inside).examples/test1.md— the file shown in the Settings live preview — with a "Wikilink extension" section and its TOC entry.Changed files
cmark-extra/extensions/wikilink.{c,h},extra-extensions.c— the extension and its registrationQLMarkdown/Settings.swift,Settings+render.swift,Settings+ext.swift— the flag and render wiringqlmarkdown_cli/qlmarkdown_cli.swift— the CLI optionQLMarkdown/ViewController.swift,Base.lproj/Main.storyboard— the Preferences checkboxResources/default.css— the.wikilinkstyle (light & dark)examples/test-wikilink.md,examples/test1.md— examplesCloses #63.