Closed willmcgugan closed 2 years ago
yeah I would like some assistance with the rich API. The line that adds those text is this line
def visit_Text(self, node):
style = self.console.get_style("restructuredtext.text", default="none")
self.renderables.append(Text(node.astext().replace("\n", " "), end="", style=style))
https://github.com/wasi-master/rich-rst/blob/main/rich_rst/__init__.py#L124-L126
And the code for showing the renderables is as follows
for renderable in visitor.renderables:
yield from console.render(renderable, options)
https://github.com/wasi-master/rich-rst/blob/main/rich_rst/__init__.py#L525-L526
So what should I do to fix that issue 🤔
I just tested it a bit and it seems a bit weird. The text in the blue rectangle is truncated but the text in the red one isn't
I suspect the root of the problem is that the way you yield Text objects with end=""
. This may render them 0from the end, but it won't allow them to wrap.
To wrap text, you will need to extend the Text objects. i.e. by calling Text.append. Then when you have all the text you can yield it.
Oh I noticed another thing, in my screenshot, there isn't one text element in the blue region, there is actually 3+. one for the part before print
one for the print
since it is a different element (literal), and the part after the print
. and therefore it isn't wrapped. in the red region it's a whole text element so it is wrapped. I'll fix this
So I've fixed the problem locally. Gonna release it within version 1.1.4
Fantastic, Rich-CLI should pick the latest release so no update required :)
\:)
Here is the same document as above but with the fix:
Rich-rst seems to truncate text at the right edge for some reason. I've attached a screenshot.
Let me know if you need any assistance re the Rich API.
.