Added `utils.rst_to_html` action.

This commit is contained in:
Fabio Manganiello 2023-05-14 15:05:24 +02:00
parent 3c83e7f412
commit 5f2d6dfeb5
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
1 changed files with 19 additions and 0 deletions

View File

@ -344,5 +344,24 @@ class UtilsPlugin(Plugin):
return plugins
@action
def rst_to_html(self, text: str):
"""
Utility action to convert RST to HTML.
It is mostly used by the frontend to render the docstring of the
available plugins and actions.
"""
try:
import docutils.core # type: ignore
except ImportError:
self.logger.warning(
"docutils is not installed. "
"Please install docutils to convert RST to HTML."
)
return text
return docutils.core.publish_parts(text, writer_name='html')['html_body']
# vim:sw=4:ts=4:et: