Commit 9456e79
authored
Replace attribute_manager with a new rdoc-inline-format parser (#1559)
## 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 .1 parent 6d3ac98 commit 9456e79
File tree
33 files changed
+1335
-1819
lines changed- lib/rdoc
- markup
- test/rdoc
- markup
33 files changed
+1335
-1819
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
| |||
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
36 | | - | |
| 34 | + | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
| 113 | + | |
| 114 | + | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
152 | | - | |
| 151 | + | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | 156 | | |
173 | 157 | | |
174 | 158 | | |
| |||
178 | 162 | | |
179 | 163 | | |
180 | 164 | | |
181 | | - | |
| 165 | + | |
182 | 166 | | |
183 | 167 | | |
184 | 168 | | |
| |||
197 | 181 | | |
198 | 182 | | |
199 | 183 | | |
| 184 | + | |
200 | 185 | | |
201 | 186 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | 187 | | |
210 | 188 | | |
211 | 189 | | |
| |||
This file was deleted.
This file was deleted.
0 commit comments