Skip to content

[pull] master from ruby:master#128

Merged
pull[bot] merged 2 commits intosysfce2:masterfrom
ruby:master
Jan 19, 2026
Merged

[pull] master from ruby:master#128
pull[bot] merged 2 commits intosysfce2:masterfrom
ruby:master

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Jan 19, 2026

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 : )

st0012 and others added 2 commits January 19, 2026 12:22
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>&lt;b&gt;&lt;c&gt;</a>`
  - `{<a><b>}[url]` will be a tidylink with label `&lt;a&gt;&lt;b&gt;`
- Unmatched closing tags and braces will be treated as plain text
  - `<a></b>}</a>` will be `<a>&lt;/b&gt;}</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*_`+&lt;b&gt;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 .
@pull pull Bot locked and limited conversation to collaborators Jan 19, 2026
@pull pull Bot added the ⤵️ pull label Jan 19, 2026
@pull pull Bot merged commit 9456e79 into sysfce2:master Jan 19, 2026
2 of 5 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants