Skip to content

Discussion: Markdown correctness and extension points for downstream integrations #37

Description

@RobinDev

This is a discussion about which generally useful behavior belongs in Tempest and which should remain a downstream extension. The examples below were checked against upstream main / 1.2.2 with highlighting disabled.

1. Make configured rules work inside nested tokens

prependRules() and removeRules() affect the outer parser, but paragraph, heading, list, link, and table tokens call forToken() with hard-coded rule lists. A custom ^ rule, for example, fires for ^x at document start but not for a ^x, - ^x, or ## ^x. This prevents downstream syntax from being implemented as an ordinary Tempest rule throughout a document.

This overlaps #13 (configurable rules/tokens) and #18 (removeRules() inside nested contexts). The likely requirement is composable rules per context (block versus inline), rather than blindly copying block rules into every inline parser. It would be useful to know your preferred API before attempting a fix.

2. Correct generic link and image parsing

Input Current result Expected meaning
[x](/a "Title") href="/a "Title"" href="/a" and title="Title"
[x](a b) A link with a space in href Literal text; the unbracketed destination is invalid
[x](<a b>) href="&lt;a b&gt;" A link to a b, with appropriate URL encoding
![alt](/a "Title") Title folded into src Separate image source and title

The general rule should parse destination, optional title, escapes, entities, and balanced parentheses before rendering. A renderer hook for parsed links/images would let integrations use those services without rewriting serialized <a> and <img> tags.

3. Preserve raw HTML and distinguish literal text from markup

<script>const x = "**a**";</script> currently becomes <script>const x = "<strong>a</strong>";</script>. The script body must remain raw. This is separate from #20, which asks whether raw HTML should be allowed, escaped, or stripped.

Other generic inline cases include a\*b retaining its backslash and a_b_c becoming emphasis. Escaping plain text/entities correctly in text tokens, while keeping raw HTML and code opaque, would nice.

4. Finish structural Markdown before adding CMS syntax

Examples still requiring downstream handling include #titre being parsed as a heading without the required separator; 2. First losing its list start number; ~~~ fences being parsed as strikethrough; and nested/loose lists and hard line breaks. Automatic heading IDs should also be optional or render-configurable.

Several narrower issues/PRs already cover parts of this: #27/#29, #28/#30, #31/#32, #33/#34, and #35/#36. I am listing them here for context. GFM task lists (- [x] Done, currently rendered as an empty-URL link) could be an optional extension.

5. Keep application behavior downstream

A small set of stable rule and rendering hooks in Tempest would make cool thing possible without pre-processing Markdown or post-processing HTML (Example).

@brendt, which of these would you want in the core parser, which as optional rules, and which should be solved through extension hooks? In particular, is the rule-configuration direction in #13/#18 the right prerequisite? I will wait for your feedback before opening any further PRs for the items in this discussion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions