Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing option --smart-quotes=yes to rst2html #59

Open
maxigaz opened this issue Apr 2, 2021 · 1 comment
Open

Passing option --smart-quotes=yes to rst2html #59

maxigaz opened this issue Apr 2, 2021 · 1 comment

Comments

@maxigaz
Copy link

maxigaz commented Apr 2, 2021

I‘m trying to pass the option --smart-quotes=yes to rst2html through restview, and I’m not sure how to do that.

I’ve tried using restview -e "rst2html --smart-quotes=yes restructuredtext.rst", thinking that --execute might be the answer, but that produces error messages (see below) and the page opened in Firefox looks like raw HTML code with rst2html error boxes with the same messages that are in the terminal output.

Output 1
Listening on http://localhost:34011/
<string>:17: (WARNING/2) Inline emphasis start-string without end-string.
<string>:23: (ERROR/3) Unexpected indentation.
<string>:21: (WARNING/2) Inline emphasis start-string without end-string.
<string>:27: (WARNING/2) Inline emphasis start-string without end-string.
<string>:28: (WARNING/2) Definition list ends without a blank line; unexpected unindent.
<string>:31: (WARNING/2) Inline emphasis start-string without end-string.
<string>:60: (WARNING/2) Definition list ends without a blank line; unexpected unindent.
<string>:64: (ERROR/3) Unexpected indentation.
<string>:65: (WARNING/2) Block quote ends without a blank line; unexpected unindent.
<string>:65: (WARNING/2) Inline emphasis start-string without end-string.
<string>:76: (ERROR/3) Unexpected indentation.
<string>:83: (ERROR/3) Unexpected indentation.
<string>:89: (ERROR/3) Unexpected indentation.
<string>:100: (WARNING/2) Definition list ends without a blank line; unexpected unindent.
<string>:100: (WARNING/2) Inline emphasis start-string without end-string.
<string>:161: (ERROR/3) Unexpected indentation.
<string>:186: (WARNING/2) Definition list ends without a blank line; unexpected unindent.
<string>:191: (WARNING/2) Definition list ends without a blank line; unexpected unindent.
<string>:205: (ERROR/3) Unexpected indentation.
<string>:203: (WARNING/2) Inline emphasis start-string without end-string.
<string>:207: (WARNING/2) Inline emphasis start-string without end-string.
<string>:278: (WARNING/2) Inline emphasis start-string without end-string.
<string>:308: (WARNING/2) Inline emphasis start-string without end-string.
<string>:328: (ERROR/3) Unexpected indentation.
<string>:340: (ERROR/3) Unexpected indentation.
<string>:338: (WARNING/2) Inline emphasis start-string without end-string.

I’ve also tried adding extra parameters to the command just in case, but that produced different terminal errors without any webpage that could be opened:

restview -e "rst2html --smart-quotes=yes restructuredtext.rst /tmp/rst2html-temp.html" -w /tmp/rst2html-temp.html
Output 2
Listening on http://localhost:34849/
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 55218)
Traceback (most recent call last):
  File "/usr/lib/python3.9/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.9/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.9/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/lib/python3.9/http/server.py", line 427, in handle
    self.handle_one_request()
  File "/usr/lib/python3.9/http/server.py", line 415, in handle_one_request
    method()
  File "/usr/lib/python3.9/site-packages/restview/restviewhttp.py", line 69, in do_GET
    content = self.do_GET_or_HEAD()
  File "/usr/lib/python3.9/site-packages/restview/restviewhttp.py", line 94, in do_GET_or_HEAD
    return self.handle_command(command, watch)
  File "/usr/lib/python3.9/site-packages/restview/restviewhttp.py", line 211, in handle_command
    return self.handle_error(command, p.returncode, stderr, mtime=mtime)
  File "/usr/lib/python3.9/site-packages/restview/restviewhttp.py", line 233, in handle_error
    html = self.server.renderer.render_exception(
  File "/usr/lib/python3.9/site-packages/restview/restviewhttp.py", line 528, in render_exception
    source = source.decode('UTF-8', 'replace')
AttributeError: 'str' object has no attribute 'decode'

I’m using Restview v2.9.2 installed from AUR, and Python 3.9.2 with Manjaro Linux x86-64.

Any help is appreciated.

@mgedmin
Copy link
Owner

mgedmin commented Apr 3, 2021

Ah, sorry, no, restview doesn't use rst2html, it uses the docutils API directly. The --exec option is for specifying a command to produce the ReST source, not a command to convert ReST to HTML.

I suspect the smart quotes thing is a setting you can pass to docutils.core.publish_string() via settings_overrides maybe? Like

settings_overrides['syntax_highlight'] = 'short'

Currently there's no way of specifying additional settings on the restview command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants