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

epub 3 validation error regarding to entity reference (this issue is also of html5 builder) #2985

Closed
hhsprings opened this issue Sep 30, 2016 · 5 comments

Comments

@hhsprings
Copy link
Contributor

hhsprings commented Sep 30, 2016

For now, EpubCheck 4.0.1 complains sphinx epub(3) builder's output is invalid for entity references (even if PR#2805 was applied):

FATAL(RSC-016): Fatal Error while parsing file 'The entity "copy" was referenced, but not declared.'

Currently, in the sphinx code tree, there are many embeded entity references (in locales and themes), so, we can take two approaches:

  1. change all embeded entity reference to numeric reference (or literal)
  2. replace those in writer or builder

Latter approach can be reached using htmlentityrefs of standard python library, for example, like this:

import re
from htmlentitydefs import name2codepoint  # python 2.7
_name2codepoint4html5rgx = re.compile(r"&({});".format("|".join(
    (n for n in name2codepoint if n not in ("amp", "lt", "gt", "quot", "apos")))))

def _unescape_for_html5(s):
    def _sub(m):
        n = m.group(1)
        #return chr(name2codepoint[n])
        return "&#{};".format(name2codepoint[n])
    return _name2codepoint4html5rgx.sub(_sub, s)
@hhsprings
Copy link
Contributor Author

update:

import re
from six.moves import html_entities
_name2codepoint4html5rgx = re.compile(r"&({});".format("|".join(
    (n for n in html_entities.name2codepoint if n not in ("amp", "lt", "gt", "quot", "apos")))))

def _unescape_for_html5(s):
    def _sub(m):
        n = m.group(1)
        #return chr(name2codepoint[n])
        return "&#{};".format(html_entities.name2codepoint[n])
    return _name2codepoint4html5rgx.sub(_sub, s)

@tk0miya tk0miya added this to the 1.5 milestone Sep 30, 2016
@tk0miya tk0miya modified the milestones: 1.6, 1.5 Nov 5, 2016
@tk0miya
Copy link
Member

tk0miya commented Nov 20, 2016

Sorry, I can't reproduce the problem.
Could you show me any reproducible example?

@tk0miya tk0miya modified the milestones: 1.5.1, 1.5 Dec 3, 2016
@tk0miya tk0miya modified the milestones: 1.5.2, 1.5.1 Dec 10, 2016
@tk0miya
Copy link
Member

tk0miya commented Jan 7, 2017

@hhsprings ping

@tk0miya tk0miya modified the milestones: 1.5.2, 1.5.3 Jan 9, 2017
@tk0miya
Copy link
Member

tk0miya commented Feb 15, 2017

@hhsprings ping

@tk0miya tk0miya modified the milestones: 1.5.4, 1.5.3 Feb 15, 2017
@tk0miya tk0miya modified the milestones: 1.6, 1.5.4 Mar 18, 2017
@tk0miya
Copy link
Member

tk0miya commented Mar 18, 2017

Unfortunately, I can't reproduce this yet. So I close this now.
Please let me know if you still get same error.

Thanks,

@tk0miya tk0miya closed this as completed Mar 18, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants