Skip to content

Conversation

@tompng
Copy link
Member

@tompng tompng commented Dec 26, 2025

The logic of newline handling to make html <span> tag pretty does not need to be restricted to comment token.
Remove comment-specific condition and make it simple.

What this code is doing

Moves trailing "\n" outside of closing </span> tag to make generated HTML pretty.

<pre>
<span># comment1
</span><span># comment2
<span><span>42</span>
</pre>

<pre>
<span># comment1</span>
<span># comment2</span>
<span>42</span>
</pre>

Background

In most case, only :on_comment token (and weird percent literal string token) might end with "\n" because RDoc::Parser::Ruby has token-squashing.
I'm writing a new syntax highlighter for RDoc and want to make this pretty-html generation applied to other tokens too.
Removing token-squashing will generate more tokens that ends with "\n".

The logic of newline handling to make html <span> tag pretty does not need to be restricted to comment token.
Remove comment-specific condition and make it simple.
@tompng tompng temporarily deployed to fork-preview-protection December 26, 2025 15:41 — with GitHub Actions Inactive
@matzbot
Copy link
Collaborator

matzbot commented Dec 26, 2025

🚀 Preview deployment available at: https://64804086.rdoc-6cd.pages.dev (commit: a9c8214)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants