1
0

custom_restructured_text.py 547 B

123456789101112
  1. from nicegui import ui
  2. from nicegui.elements.restructured_text import prepare_content
  3. class CustomRestructuredText(ui.restructured_text):
  4. """Custom restructured text element that avoids field lists being interpreted as document-level fields (see #4647)."""
  5. def _handle_content_change(self, content: str) -> None:
  6. html = prepare_content('__PLACEHOLDER__\n\n' + content).replace('<p>__PLACEHOLDER__</p>\n', '')
  7. if self._props.get('innerHTML') != html:
  8. self._props['innerHTML'] = html
  9. self.update()