sphinx-doc / sphinx-doc/sphinx

Quotes and m-dashes are not properly escaped in epub

Open
#5,869 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

builder:epub
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Subject: missing escapes in epub builder

Problem
  • I'm trying to go from sphinx to mobi for Kindle. I'm using the epub builder with the epub theme on sphinx 1.8.3 and then passing to kindlegen
  • Most stuff works but all the "smart quotes" and m-dashes and whatnot are coming out as goofy characters in mobi, like ’ instead of an apostrophe and – instead of m-dash.
  • If I turn off smartquotes the apostrophe's work but not the m-dashes.

The rst looks like:

*****                                                                                                                                                                                            
Intro
*****
Computers are everywhere. They're in our purses, our offices, our TV's, our hobby-dens,
our cars, and our toasters. Many of us spend significant parts of our days operating these

The xhtml source for the epub looks like this:

<h1>Intro</h1>
<p>Computers are everywhere. They’re in our purses, our offices, our TV’s, our hobby-dens,
our cars, and our toasters. Many of us spend significant parts of our days operating these
Procedure to reproduce the problem
make epub

# epub viewers sometimes show these characters ok, but once 
# you run kindlegen they go to the weird chars
kindlegen _build/epub/book.epub
Expected results

I'd expect it to be They&rsquo;re in our purses instead of the special apostrophe or something like that in the xhtml source on the way into the epub.

Environment info
  • OS: Ubuntu 18.10
  • Python version: 3.6.7
  • Sphinx version: 1.8.3
  • KindleGen v2.9 for Linux 2.6 i386

Contributor guide

Open the contributing guide

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

Reproduce the issue with the mentioned epub builder using make epub, then pass _build/epub/book.epub to kindlegen and inspect the generated XHTML. Trace the epub builder's character handling and add a regression check for smart quotes and m-dashes; done means KindleGen no longer produces mojibake.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.