Conversation
kou
left a comment
There was a problem hiding this comment.
+1
Can we improve alignment in ri --format=ansi? It seems that we should not count invisible ANSI escape characters for width.
|
@kou |
|
I think widths = header.zip(*body).map do |cols|
cols.map(&:size).max # Use `calculate_text_width instead of size
end
...
# a is :rjust | :ljust | :center, w is width
t.__send__(a, w)
↓
t.__send__(a, w + calculate_text_width(t) - t.size)And each formatter can override it if it needs special width calculation logic. ToRDoc#calculate_text_widthSimply return ToAnsi#calculate_text_widthRemove escape sequences before calculating width ToBs#calculate_text_widthI think ToBS also need another custom width calculation logic. |
|
@tompng |
|
🚀 Preview deployment available at: https://4ba19a13.rdoc-6cd.pages.dev (commit: 45a8180) |
In the documentation for methods like
test, backtick are used within table cells.While each parser handles backquotes within table cells, the generator does not.
As a result, the tags are displayed literally without being processed.
To resolve this, I propose that tag expressions should be properly handled within table cells as well.
Before
ri --format=bs test
ri --format=markdown test
ri --format=ansi
After
ri --format=bs test
ri --format=markdown test
ri --format=ansi