ebook fix: remove stray markup from the text #172
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello! Thanks for putting so much work into formatting HPMOR nicely. I'm re-reading it in ebook format in Apple Books right now and really enjoying it.
I noticed some stray markup in chapter 23:
"plus .5minus 1"
clearly doesn't belong there. I looked into it and you can see the source of this markup in the original latex:hpmor/chapters/hpmor-chapter-023.tex
Lines 125 to 140 in 9ecaeba
The problem happens in
step_3.py
, which tries to remove this markup completely:hpmor/scripts/ebook/step_3.py
Lines 53 to 54 in 9ecaeba
But because the regex uses a minimal quantifier instead of a greedy one, it only matches
"\vskip 1\baselineskip"
, stopping at the first"\baselineskip"
instead of the one at the end of the line. This leaves the errant bit of markup in the text:Which, because it does not start with a backslash, ends up inserted into the content.
The fix is simple: remove the
'?'
, turning the".*"
into a greedy match instead of a minimal match. This matches to the end of the last"\baselineskip"
, completely removing this bit of markup from the text as intended.Note: I only made this change because of the issue in chapter 23, but it also comes up in a few other places. Here's the full diff of tmp/hpmor-epub-3-flatten-mod.tex. I think these are all good changes, but I'm not sure. I'm not that familiar with the markup and I haven't figured out how to fully render the ebook yet to check how it looks: