|
@@ -3,11 +3,10 @@ from functools import lru_cache
|
|
|
|
|
|
from docutils.core import publish_parts
|
|
|
|
|
|
-from .markdown import remove_indentation
|
|
|
-from .mixins.content_element import ContentElement
|
|
|
+from .markdown import Markdown, remove_indentation
|
|
|
|
|
|
|
|
|
-class ReStructuredText(ContentElement, component='restructured_text.js'):
|
|
|
+class ReStructuredText(Markdown):
|
|
|
|
|
|
def __init__(self, content: str = '') -> None:
|
|
|
"""ReStructuredText
|
|
@@ -17,7 +16,6 @@ class ReStructuredText(ContentElement, component='restructured_text.js'):
|
|
|
:param content: the ReStructuredText content to be displayed
|
|
|
"""
|
|
|
super().__init__(content=content)
|
|
|
- self._classes.append('nicegui-markdown')
|
|
|
|
|
|
def _handle_content_change(self, content: str) -> None:
|
|
|
html = prepare_content(content)
|
|
@@ -29,5 +27,9 @@ class ReStructuredText(ContentElement, component='restructured_text.js'):
|
|
|
@lru_cache(maxsize=int(os.environ.get('RST_CONTENT_CACHE_SIZE', '1000')))
|
|
|
def prepare_content(content: str) -> str:
|
|
|
"""Render ReStructuredText content to HTML."""
|
|
|
- html = publish_parts(remove_indentation(content), writer_name='html5')
|
|
|
- return html["html_body"]
|
|
|
+ html = publish_parts(
|
|
|
+ remove_indentation(content),
|
|
|
+ writer_name='html4',
|
|
|
+ settings_overrides={'syntax_highlight': 'short'},
|
|
|
+ )
|
|
|
+ return html["html_body"].replace('<div class="document"', '<div class="codehilite"')
|