-
I have a string that is being build on the go and should be displayed in a container. my code @rio.event.periodic(0.5)
async def update_log_box(self) -> None:
# Move the pointer to the end of the file
self.log_file.seek(self.log_file_ptr)
while True:
line = self.log_file.readline()
if not line:
self.log_file_ptr = self.log_file.tell()
break
self.log_content = f'{line.strip()}<br> ' + self.log_content
await self.force_refresh()
def build(self) -> rio.Component:
# The navbar should appear above all other components. This is easily
# done by using a `rio.Overlay` component.
logger = logging.getLogger("Logger")
return rio.Overlay(
# Use a rectangle for visual separation
rio.Revealer(
header='',
content=
rio.Card( content = rio.ScrollContainer(rio.Markdown(
default_language='python',
text=self.log_content),
min_height=10,
)),
header_style="text",
align_y = 1,
margin_y = 1,
margin_x = 5,
),
) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hey! What you're seeing is just standard markdown behavior. An example should clear this up: Linebreaks are ignored in markdown. For example, even though this text spans
two lines, it is displayed as a single one in the final output.
To force a linebreak, markdown requires you to leave a completely empty line.
Notice how due to the empty line above the text is displayed as two paragraphs. Above text as rendered by markdown ^^^ While we're at it, another common gotcha is that indented code is rendered as code block in markdown. So if generating a string in Python, make sure you don't have a bunch of spaces at the start of it. |
Beta Was this translation helpful? Give feedback.
-
Didn't mean to close the discussion - feel free to close it yourself if you consider your problem resolved |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
Thanks guys, I took the "empty line" suggestions. its not the most elegant at I am getting gaps between my lines, but it's sufficient for now. ' |
Beta Was this translation helpful? Give feedback.
Hey!
What you're seeing is just standard markdown behavior. An example should clear this up:
Above text as rendered by markdown ^^^
While we're at it, another common gotcha is that indented code is rendered as code block in markdown. So if generating a string in Python, make sure you don't have a bunch of spaces at the start of it.