fix: detect bold/italic/underline from semantic HTML tags (<b>, <strong>, <i>, <em>, <u>)#94
Open
vibeyclaw wants to merge 1 commit intoalphanome-ai:mainfrom
Open
Conversation
…ng>, <i>, <em>, <u>) The HighlightedTextClassifier was not detecting text styled via semantic HTML tags such as <b> and <strong>. The _compute_effective_style function only examined inline CSS style attributes, missing the implied font-weight that <b> and <strong> carry by default. Fix: Extend _compute_effective_style to map semantic tag names to their implied CSS properties before falling back to inline styles. Inline styles still take precedence (processed first with setdefault semantics). Supported tag → CSS property mappings added: <b>, <strong> → font-weight: bold <i>, <em> → font-style: italic <u> → text-decoration: underline Adds tests covering <b>, <strong>, <i>, <em>, inline-style override, and end-to-end HighlightedTextClassifier / TitleClassifier integration. Fixes alphanome-ai#61
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.
Problem
Fixes #61
The
HighlightedTextClassifierwas silently skipping text styled via semantic HTML tags like<b>and<strong>. As shown in the issue, many SEC filings use bare<b>tags rather thanstyle="font-weight:bold"to apply bold formatting, so those text elements were never classified asHighlightedTextElementor promoted toTitleElement.Root cause:
_compute_effective_styleintext_styles_metrics.pyonly walked the tag tree looking atstyle="..."attributes. It had no knowledge of the implied CSS properties that HTML semantic tags carry.Fix
Extended
_compute_effective_styleto recognise a small set of semantic tags and map them to their implied CSS properties after any inlinestyleattribute is processed (so inline styles still win):<b>,<strong>font-weight: bold<i>,<em>font-style: italic<u>text-decoration: underlineThe
setdefaultpattern already used throughout the function ensures correct cascade precedence: an explicit inline style always wins over the implied tag style.Tests added
test_should_detect_bold_from_b_tagtest_should_detect_bold_from_strong_tagtest_should_detect_italic_from_i_tagtest_should_detect_italic_from_em_tagtest_inline_style_should_override_semantic_tag(precedence check)test_title_stepparametrize cases (bold via <b> tagandbold via <strong> tag) verifying end-to-end promotion toTitleElementAll 12 tests pass. No existing tests were modified.