forked from platypush/platypush
Added utils.rst_to_html
action.
This commit is contained in:
parent
3c83e7f412
commit
5f2d6dfeb5
1 changed files with 19 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue