Add definition list rendering extension - #220
Open
soreavis wants to merge 1 commit into
Open
Conversation
cmark-gfm has no native definition lists, so this adds them as a post-process cmark-extra extension (defl.c): the compact `term` / `: description` syntax is rewritten into <dl>/<dt>/<dd>, preserving inline markup and working inside blockquotes. Off by default behind a Settings flag and a --definition-list CLI option; the bundled default.css already styles dl/dt/dd. Adds examples/test-definition-list.md. Re sbarex#66.
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 definition lists (closes #66). cmark-gfm has no native definition lists, so this is a post-process
cmark-extraextension (defl.c), in the same style as the existingheads/inlineimageextensions — the cmark engine itself is untouched.A term on its own line followed by one or more
: descriptionlines is rewritten into<dl>/<dt>/<dd>:→
Multiple terms in one list and one or more definitions per term are supported, matching the Markdown Guide.
Behaviour
:line only starts a description when it directly follows a term line, so ordinary paragraphs that happen to contain a colon are unaffected.default.cssalready stylesdl/dt/dd, so no CSS change is needed.How it's exposed
definitionListExtension, enabled →renderAsCodeviaNSNegateBoolean).--definition-list on|offoption.definitionListExtensionflag (Codable+ app-group defaults), defaulting to off.Examples
examples/test-definition-list.md(basic, multiple-descriptions, inline-markup, and blockquote cases).examples/test1.md— the file shown in the Settings live preview — with a "Definition list extension" section (Apple / Markdown / HTML) and its TOC entry, so the effect is visible the moment the checkbox is toggled.Changed files
cmark-extra/extensions/defl.{c,h},extra-extensions.c— the extension and its registrationQLMarkdown/Settings.swift,Settings+render.swift— the flag and render wiringqlmarkdown_cli/qlmarkdown_cli.swift— the CLI optionQLMarkdown/ViewController.swift,Base.lproj/Main.storyboard— the Preferences checkboxexamples/test-definition-list.md,examples/test1.md— examplesCloses #66.