[pull] master from ruby:master#128
Merged
pull[bot] merged 2 commits intosysfce2:masterfrom Jan 19, 2026
Merged
Conversation
The current bash command code blocks are highlighted inconsistently because some code blocks got detected as Ruby, so Ruby highlighting is applied. This has been addressed in #1538. <img width="60%" alt="Screenshot 2026-01-04 at 18 31 29" src="https://github.com/user-attachments/assets/8c6bec3f-f90b-4f39-b8bd-045c277ef5b6" /> But after the PR, we don't have any highlighting for bash, which I think we can provide rather simply. With this PR, we can highlight code blocks tagged as `sh`, `shell`, `bash`, and `console` with a simple JS highlighter. <img width="60%" alt="Screenshot 2026-01-04 at 18 30 02" src="https://github.com/user-attachments/assets/34090a4e-6323-4856-90ea-ac16153b7ab1" />
## RDoc::Markup::AttributeManager
RDoc parses block-level structure in `RDoc::Markup::Parser` and parses
inline styling in `RDoc::Markup::AttributeManager`.
`RDoc::Markup::AttributeManager` is a string-replacing/macro based
parser.
It's very complicated, and its mechanism are the root cause of many
bugs. We need to remove and replace it.
It converts to a flow/stream of string and styling changing operation.
Unfortunately, inline styles are structured data, output format (HTML)
is also a structured data. There's an architecture mismatch.
Tidylink `{label}[url]` should be a syntax rule, but it is currently
handled in a
regexp-based macro called `regexp_handling`.
Of course parsing nested structure such as styled tidylink label
frequently fails. It's uncontrollable.
## Solution
- Eliminate `RDoc::Markup::AttributeManager`
- Create a parser that generates structured data
- Traverse structured data to generate output instead of string
replacing
- Use controllable regexp-handling macro: only apply to text nodes
## New inline styling syntax
### Tokens
- Word pairs `+word+` `*word*` `_word_` `` `word` `` and so on
- Standalone tags `<br>`, `<tt>code_text</tt>`, `<code>code_text</code>`
- Open and close tags `<i>` `</i>`, `<b>` `</b>`, `<em>` `</em>`, `<s>`
`</s>`, `<del>` `</del>`
- Tidy link opening `{` and closing `}[url_part]`
- Simplified tidylink `word[url_part]`
- Text nodes
### Regexp handling macro
Matching with CROSSREF, RDOCREF, HYPERLINK regexp should be applied only
to text nodes after parsing phase.
Parsed tree modication instead of text-node gsub is also another option
to implement this.
### Error recovery
RDoc format doesn't have syntax error. We need to make the behavior as
similar before.
- Closing tags and braces will invalidate unclosed tags, and unclosed
tags are treated as plain text
- `<a><b><c></a>` will be `<a><b><c></a>`
- `{<a><b>}[url]` will be a tidylink with label `<a><b>`
- Unmatched closing tags and braces will be treated as plain text
- `<a></b>}</a>` will be `<a></b>}</a>`
- Tidylink inside tidylink will invalidate outside tidylinks
- `{{inner}[url]}[<b>]</b>` will be `"{" + inner_tidylink + "}[" +
bold("]")`
### Simplified tidylink
RDoc was converting ``a*_`+<b>c[foo]`` to ``<a
href="foo">a*_`+<b>c</a>``. This is terrible, it can't coexist
with other syntaxes like `*word*` `_word_` `+word+`.
We should restrict characters and recommend `{label}[url]`.
In this pull request, only `Alphanumeric[url]` (should start with
alphabet) is supported .
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )