Skip to content

Commit

Permalink
fix TypeError when rendering reST to HTML
Browse files Browse the repository at this point in the history
docutils.core.publish_string() returns bytes object by default.
  • Loading branch information
yuuki0xff committed Sep 28, 2023
1 parent 4a53918 commit 909bf14
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nvpy/nvpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,17 +711,17 @@ def helper_rest_to_html(self):
if self.config.rest_css_path:
settings['stylesheet_path'] = self.config.rest_css_path
# this gives the whole document
html = docutils.core.publish_string(c, writer_name='html', settings_overrides=settings)
html: bytes = docutils.core.publish_string(c, writer_name='html', settings_overrides=settings)
# publish_parts("*anurag*",writer_name='html')['body']
# gives just the desired part of the tree

else:
html = "<p>python docutils not installed, required for rendering reST to HTML.</p>"
html += "<p>Please install with \"pip install docutils\".</p>"
html = b"<p>python docutils not installed, required for rendering reST to HTML.</p>"
html += b"<p>Please install with \"pip install docutils\".</p>"

# create filename based on key
fn = os.path.join(self.config.db_path, key + '_rest.html')
with open(fn, mode='w', encoding='utf-8') as f:
with open(fn, mode='wb') as f:
f.write(html)
return fn

Expand Down

0 comments on commit 909bf14

Please sign in to comment.