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

semanticate: i inside a tag is not a Roman numeral #752

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

gvtulder
Copy link
Contributor

se semanticate has a regexp that wraps lowercase i to a Roman numeral <span>. The regexp also does this to is inside attributes:

<a href="appendix-i.xhtml">

becomes

<a href="appendix-<span epub:type="z3998:roman">i</span>.xhtml">

This patch adds a lookahead clause to check that the i is not inside an open tag.

@alerque
Copy link

alerque commented Sep 23, 2024

Shouldn't this sort of RegEx only be run on the content of tags via an XML parser that then iterates through the AST, not run directly on the raw XML?

@gvtulder
Copy link
Contributor Author

Shouldn't this sort of RegEx only be run on the content of tags via an XML parser that then iterates through the AST, not run directly on the raw XML?

That might be better, yes. I noticed that the raw XML-regex also adds <abbr> tags inside alt attributes, for example, so this happens to other rules as well.

@acabal
Copy link
Member

acabal commented Sep 23, 2024

Shouldn't this sort of RegEx only be run on the content of tags via an XML parser that then iterates through the AST, not run directly on the raw XML?

Yes, but that becomes extremely complicated to implement extremely quickly. Regex is simple and fast, and has acceptable results 95% of the time for this narrow use case. When it does get something wrong, it's easy to undo.

@acabal acabal merged commit bdce342 into standardebooks:master Sep 23, 2024
1 check passed
@gvtulder gvtulder deleted the f-semanticate branch September 23, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants