Repository navigation
Optimize string concatenation - #10
Merged
Merged
Conversation
timonv
referenced
this pull request
in bosun-ai/swiftide
Jun 28, 2024
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [htmd](https://togithub.com/letmutex/htmd) | dependencies | patch | `0.1.3` -> `0.1.5` | --- ### Release Notes <details> <summary>letmutex/htmd (htmd)</summary> ### [`v0.1.5`](https://togithub.com/letmutex/htmd/releases/tag/v0.1.5) [Compare Source](https://togithub.com/letmutex/htmd/compare/v0.1.4...v0.1.5) #### What's Changed - Change all fields of Element to references by [@​letmutex](https://togithub.com/letmutex) in [https://github.com/letmutex/htmd/pull/13](https://togithub.com/letmutex/htmd/pull/13) - Support resolving code block language from pre tag by [@​letmutex](https://togithub.com/letmutex) in [https://github.com/letmutex/htmd/pull/15](https://togithub.com/letmutex/htmd/pull/15) **Full Changelog**: letmutex/htmd@v0.1.4...v0.1.5 ### [`v0.1.4`](https://togithub.com/letmutex/htmd/releases/tag/v0.1.4) [Compare Source](https://togithub.com/letmutex/htmd/compare/v0.1.3...v0.1.4) #### What's Changed - Add a benchmark for `convert()` by [@​letmutex](https://togithub.com/letmutex) in [https://github.com/letmutex/htmd/pull/9](https://togithub.com/letmutex/htmd/pull/9) - Optimize string concatenation, this makes htmd **~20%** faster! by [@​letmutex](https://togithub.com/letmutex) in [https://github.com/letmutex/htmd/pull/10](https://togithub.com/letmutex/htmd/pull/10) - Optimize get_node_tag_name(), this makes htmd **~23%** faster! by [@​letmutex](https://togithub.com/letmutex) in [https://github.com/letmutex/htmd/pull/11](https://togithub.com/letmutex/htmd/pull/11) - Handle spaces in the URL by [@​letmutex](https://togithub.com/letmutex) in [https://github.com/letmutex/htmd/pull/12](https://togithub.com/letmutex/htmd/pull/12) **Full Changelog**: letmutex/htmd@v0.1.3...v0.1.4 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bosun-ai/swiftide). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjAuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQyMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
letmutex
pushed a commit
that referenced
this pull request
Sep 3, 2026
A raw HTML inline sits inside a leaf block, and a line ending ends the block holding it: a blank line ends a paragraph, and a single line ending ends an ATX heading or a table row, truncating the element. Every line ending in one is therefore written as ` `/` `, which the CommonMark parser decodes back to the line ending it replaced. This is the safe over-generalization of the blank-line rule in unsupported_html.md, which needs it only for a blank line. An HTML block gains the converse exemption. `escape_html_block_blank_lines` exists because a type 6 block ends at a blank line, but a type 1 block — `pre`, `script`, `style`, `textarea` — ends at the line holding its closing tag, so its blank lines can stand as they are; escaping them would rewrite the script, stylesheet, or preformatted text itself. `TYPE_1_ELEMENTS` names that half of `BLOCK_ELEMENTS`. Both escapes take their argument by value and return it untouched when it holds no line ending, which is the common case. Co-Authored-By: Claude Opus 5 <[email protected]>
letmutex
pushed a commit
that referenced
this pull request
Sep 4, 2026
A link title and an image alt end up inside a CommonMark inline, where a line ending ends the leaf block holding it: written literally, `# [t](u "a<LF>b")` parses as the heading `[t](u "a` followed by the paragraph `b")`. CommonMark recognizes character references in both places, so each line ending becomes ` `, the same encoding a raw HTML inline gets. A lone carriage return, which `lines()` does not treat as a break, becomes ` `. This deviates from turndown, which writes the line ending literally; four expectations in the turndown index change to match, and the harness gains a `<!-- line feed -->` placeholder because writing the reference into the index would only have it decoded when the index is parsed. Co-Authored-By: Claude Opus 5 <[email protected]>
letmutex
pushed a commit
that referenced
this pull request
Sep 4, 2026
A comment was emitted the same way everywhere. It is a type 2 HTML block, which ends at its own `-->` rather than at a blank line, so in a block context it is framed as a block with its line endings left alone, and in an inline context it becomes a raw HTML inline. Escaping the line endings of that inline is knowingly non-conforming: an HTML parser decodes no character reference inside a comment, so the ` ` comes back as five characters. It is kept because the alternative is worse — a bare line ending would end the leaf block holding the comment. The comment on `walk_comment` records the trade and points at the "Special case" of unsupported_html.md which would resolve it. Co-Authored-By: Claude Opus 5 <[email protected]>
letmutex
pushed a commit
that referenced
this pull request
Sep 9, 2026
A CommonMark link destination may not hold a line ending at all: written literally, `a[t](u<LF><LF>v)b` is two paragraphs and no link. CommonMark does decode a character reference there, so `<CR>` and `<LF>` are written as ` ` and ` `, the same encoding `normalize_title` already applies to a title. `escape_link_destination` moves from `anchor` to `text_util` so `img` can use it too, replacing the `replace('(', ...)` pair which escaped the parentheses but left the line endings. The line ending encoding itself becomes `push_encoding_line_ending`, shared with `normalize_title`, and `has_line_ending` moves alongside it from `element_util`. Co-Authored-By: Claude Opus 5 <[email protected]>
bjones1
referenced
this pull request
in bjones1/htmd
Sep 9, 2026
Only the tags of a raw HTML inline are HTML; what sits between them is CommonMark text. Three kinds of element did not follow that rule: - `<script>` and `<style>` were serialized whole, so the Markdown in them went out unescaped and `a*b*c` in a script came back as `a<em>b</em>c`. - A `<pre>` in an inline context took the same verbatim path, and its `<code>` child then tried to write a code block where only inline content may appear. - A comment, and every raw HTML inline, had its line endings written as ` `. That encoding only works where the HTML parser decodes character references, and it decodes none inside a comment or a raw text element, so those five characters came back as themselves. `Handlers::walk_raw_html_inline_children` now walks the children of a serialized element as inline CommonMark, whatever the element's own tag, and the "Translating HTML nodes" section of `unsupported_html.md` collapses the whitespace of the result — the one treatment which needs no parser to decode anything. `RAW_TEXT_ELEMENTS`, `serialize_inline_verbatim` and `escape_inline_line_endings` go with the old path. The collapse is scoped to the contents, so an attribute value keeps its whitespace; a bare line ending there would still end the leaf block holding the element, so `escape_attribute_line_endings` encodes the open tag alone. `Context::is_inline` names the test the macros and handlers were all spelling out, and `is_pre_content` keeps a `<pre>` or `<code>` which is being written as HTML from claiming its content is literal text. Co-Authored-By: Claude Opus 5 <[email protected]>
letmutex
pushed a commit
that referenced
this pull request
Sep 12, 2026
Only the tags of a raw HTML inline are HTML; what sits between them is CommonMark text. Three kinds of element did not follow that rule: - `<script>` and `<style>` were serialized whole, so the Markdown in them went out unescaped and `a*b*c` in a script came back as `a<em>b</em>c`. - A `<pre>` in an inline context took the same verbatim path, and its `<code>` child then tried to write a code block where only inline content may appear. - A comment, and every raw HTML inline, had its line endings written as ` `. That encoding only works where the HTML parser decodes character references, and it decodes none inside a comment or a raw text element, so those five characters came back as themselves. `Handlers::walk_raw_html_inline_children` now walks the children of a serialized element as inline CommonMark, whatever the element's own tag, and the "Translating HTML nodes" section of `unsupported_html.md` collapses the whitespace of the result — the one treatment which needs no parser to decode anything. `RAW_TEXT_ELEMENTS`, `serialize_inline_verbatim` and `escape_inline_line_endings` go with the old path. The collapse is scoped to the contents, so an attribute value keeps its whitespace; a bare line ending there would still end the leaf block holding the element, so `escape_attribute_line_endings` encodes the open tag alone. `Context::is_inline` names the test the macros and handlers were all spelling out, and `is_pre_content` keeps a `<pre>` or `<code>` which is being written as HTML from claiming its content is literal text. Co-Authored-By: Claude Opus 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.
~20% faster in the built-in benchmark!