Repository navigation
Conversation
|
✅ DCO Check Passed Thanks @wittjeff, all your commits are properly signed off. 🎉 |
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit This PR omits CI safety: no concern found. A maintainer must still approve CI. Possible duplicates
Reference data changes
Assessment: expected. The HTML reference files now contain The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at da71365027. It read the code and did not run it.
The Markdown change is correct for language and entities. The new catch-all BaseModel branch also drops a standard field, CodeMetaField, so that field can no longer reach Markdown or plain-text output. Decide whether that content loss is intended.
A maintainer makes the merge decision. This review never approves the pull request.
da71365 to
0d7e51f
Compare
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at 0d7e51f5b8. It read the code and did not run it.
The language and entity skip in Markdown and the HTML lang attributes look correct. The new CodeMetaField branch has a fixed three-backtick fence, which can break the Markdown of the whole document. Check that branch against the existing _code_block helper.
Earlier findings
- fixed (question): Catch-all
BaseModelskip removesPictureMeta.codetext from Markdown and plain text
A maintainer makes the merge decision. This review never approves the pull request.
… attributes in HTML `BaseMeta.language` is metadata about the text, but the Markdown meta serializer had no branch for `LanguageMetaField` and fell through to `str(field_val)`, so a document with language metadata gained paragraphs such as `confidence=0.99 created_by='langdetect' code=<HumanLanguageLabel.DE: 'de'>` in Markdown and plain text. `EntitiesMetaField` leaked its repr the same way, and HTML had no way to express the language at all: `HTMLParams.html_lang` was never emitted and elements carried no `lang` attribute. Markdown / plain text: `LanguageMetaField` and `EntitiesMetaField` are skipped unless `mark_meta=True`, where they render as `[Language] de` and `[Entities] IBM, Zurich`. Any other structured field without a renderer is skipped instead of printing its pydantic repr; custom scalar fields keep rendering as before. `CodeMetaField` (`PictureMeta.code`) gets a renderer so the skip does not drop it: a fenced block through `_code_block`, which now takes the language as the info string and sizes the fence past any backtick run in the code, or the bare text when `format_code_blocks` is off (plain text). A marked export puts `[Code]` on the line above the fence, because a fence must start its own line. HTML: the root element is `<html lang="...">`. `html_lang` now defaults to None, which resolves to the document language (`doc.body.meta.language`), else the character-weighted majority of the text items' `meta.language`, else "en". Paragraphs, headings and list items whose `meta.language` differs from the page language (compared by primary subtag) get a `lang` attribute (WCAG 3.1.1 and 3.1.2). The language row in the meta details block is unchanged. Ground-truth HTML files are regenerated for the root element only. Closes docling-project#745 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Jeff Witt <1848307+wittjeff@users.noreply.github.com>
a243c16 to
8837555
Compare
Closes #745. Related: #868 (full BCP 47 tag on
LanguageMetaField), docling-project/docling#4741 and docling-project/docling#4781 (PDF/Langattached tobody.meta, opt-in until this lands).Problem
BaseMeta.languageis metadata about the text, but once set it is treated as content:MarkdownMetaSerializer._serialize_meta_fieldhas noLanguageMetaFieldbranch and falls through tostr(field_val)), so the document gains a paragraph such asconfidence=0.99 created_by='langdetect' code=<HumanLanguageLabel.DE: 'de'>.EntitiesMetaFieldleaks the same way.langattribute on the elements that carry the text.HTMLParams.html_langis declared but never emitted; the root is the hard-coded<html>.Change
Markdown / plain text
LanguageMetaFieldandEntitiesMetaFieldare skipped unlessmark_meta=True, where they render as[Language] deand[Entities] IBM, Zurich.BaseModel) without a renderer is skipped instead of printing its repr. Custom scalar fields keep rendering as before.CodeMetaField(PictureMeta.code, e.g. chart-to-code output) renders like a code item: a fenced block with the language as the info string, or the bare text whenformat_code_blocks=False(plain text). A marked export puts[Code]on the line above the fence. Before, this field printed as a pydantic repr; it is the one standard field the catch-all would otherwise have dropped.HTML
<html lang="...">.html_lang(params andexport_to_html) now defaults toNone, resolved byresolve_document_language():doc.body.meta.language, else the character-weighted majority of the text items'meta.language, else"en". The resolution happens once inHTMLDocSerializer.model_post_init, so every element serializer compares against the same page language.<p>,<h1>..<h6>and<li>getlang="<code>"when the item'smeta.languagediffers from the page language, compared by primary subtag (en-USvsenis the same language). This is WCAG 3.1.1 (page) and 3.1.2 (parts).languagerow in the<details class="docling-meta">block is unchanged: existing tests pin it, and it does no harm.Ground truth
All
.gt.html/.html.gtfiles are regenerated; the only change in each is<html>-><html lang="en">. (The regeneration also rewrote the visualization PNGs through local font drift; those are reverted and not part of this PR.)Tests
tests/test_metadata.py: Markdown and plain text exclude language and entities by default and list them withmark_meta=True; a structured custom field without a renderer is skipped while a scalar one is kept; a picture'scodefield renders fenced (Markdown), labelled (marked), and bare (plain text); HTMLlangattributes with the majority default, an explicithtml_lang="en-US", and a body-level language;<html lang="en">without any language metadata. Full suite and pre-commit (ruff, mypy, pytest, docs) pass.🤖 Generated with Claude Code