mgedmin / mgedmin/restview

Passing option --smart-quotes=yes to rst2html

Open
#59 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
224
Forks
36
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the documented restview -e commands with Python 3.9, then inspect restview/restviewhttp.py around handle_command, handle_error, and render_exception, which appear in the traceback. Check how command output and errors are passed through, and consider the rst2html option handling shown in the issue. Done means the requested command behavior is clear and failures no longer produce the reported rendering exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.