Repository navigation
Keep inline formatting (italic, bold, sub, sup) in the export - #300
Merged
Merged
Conversation
text[].formatted, metadata.title_formatted and metadata.abstract_formatted carry an HTML-subset markup (<i>, <b>, <sub>, <sup>; only & < > escaped) whose plain form equals the plain field, so eq/url/xref offsets are unchanged. Formatting is read from the PDF text layer (font and baseline per glyph), OCR output (LaTeX, Markdown and HTML marks), JATS, HTML/ePub and DOCX, and aligned onto the final sentence text at export. Export schema 12.5 -> 12.6 (additive).
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #300 +/- ##
==========================================
- Coverage 91.03% 91.00% -0.04%
==========================================
Files 345 349 +4
Lines 74575 75493 +918
Branches 13933 14130 +197
==========================================
+ Hits 67892 68704 +812
- Misses 4115 4176 +61
- Partials 2568 2613 +45 🚀 New features to boost your workflow:
|
Adds supplement, subject, contributor, review and review_text, plus metadata.article_type, affiliation.ror and funding.funder_doi, to export schema 12.6, as metacheck's publisher-XML reader keeps them. All are omitted when there is nothing to write, so bibr's own exports are unchanged and a 12.5 export is still a valid 12.6 reader input.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Keeps italics, bold, subscripts and superscripts in the export (schema 12.6, additive).
What changes
text[].formattednow carries the row's text marked up with<i>,<b>,<sub>,<sup>whenever the row has any inline formatting. Only&,<and>are escaped, so stripping the tags and unescaping givestextback exactly.textstays plain, soeq[],url[]andxref[]offsets are untouched.metadata.title_formattedandmetadata.abstract_formatted, same markup, omitted when there is nothing to mark.Where the formatting comes from
bibr/ocr/char_styles.py). About 20-35 ms per page.^{}/_{}and\textit-style commands, Markdown**/*, HTML tags in the model output (bibr/ocr/markup_styles.py), run through the same late cleaning as the text.<italic>,<bold>,<sup>,<sub>, MathMLmsup/msub/msubsupand one-lettermi(bibr/input/inline_styles.py).i em var cite b strong sup sub+ MathML.vertAlign.Each parser records a styled source per paragraph/region/caption/title. At export,
StyleAligner(bibr/utils/inline_markup.py) aligns each final, cleaned sentence onto that source and transfers per-character styles; a row whose source aligns on less than 60% of its characters gets noformattedvalue rather than a wrong one.Testing
tests/test_inline_formatting.py(44 tests): markup round-trip, alignment edge cases, a generated PDF with italic/bold/raised text through both text-layer routes, OCR markers, and JATS/HTML/DOCX parsers through to the export.bibr chewend to end on a GPU machine.Not part of 0.9.3; meant for the release after it.
Generated by Claude Code