From f741e49dec35dbe507ff6345c6b0a397b745bf45 Mon Sep 17 00:00:00 2001 From: Abimael Martell <1450169+abimaelmartell@users.noreply.github.com> Date: Wed, 15 Jul 2026 14:44:46 -0700 Subject: [PATCH] fix(headings): all-bold single words qualify as headings when standalone (#167) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Single-word bold section headings ('Replace', 'Trash', 'Instructions') required a paragraph break before AND after, but headings hug their section's first paragraph — the break-after almost never exists. A standalone all-bold single word (>=4 chars, paragraph break before or page top) now classifies; mixed bold lead-ins ('Note: ...') stay excluded via all_bold. opendataloader-bench: 0.8567 -> 0.8575, MHS 0.773 -> 0.776; docs 145 +0.118, 069 +0.112 (net of one cover-page layout shuffle at -0.066 where the new output is semantically closer to GT). pdf-evals: 66 snapshots, composite 0.5864 -> 0.5883, sole >0.02 mover positive. p1244/thermo fixture snapshots regenerated ('Instructions' un-fuses from its body paragraph — the intended behavior). Co-authored-by: Claude Fable 5 --- src/markdown/convert.rs | 11 +++++++---- tests/snapshots/p1244-1996.md | 4 +++- tests/snapshots/thermo-freon12.md | 4 +++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/markdown/convert.rs b/src/markdown/convert.rs index 21e544e..5a1a8c2 100644 --- a/src/markdown/convert.rs +++ b/src/markdown/convert.rs @@ -877,10 +877,13 @@ pub(super) fn to_markdown_from_lines_with_tables_and_images( // paragraph continuity and minor font-size variation // inflates rarity scores. let has_strong_signal = all_bold || isolated || (rarity >= 0.97 && word_count <= 8); - // Single-word headings ("IMPLEMENTATION", "CONTENTS") are common; - // accept them only with the strongest signal combination. - let enough_words = - word_count >= 2 || (all_bold && isolated && plain_trimmed.len() >= 4); + // Single-word headings ("IMPLEMENTATION", "CONTENTS", + // "Replace") are common. All-bold single words qualify when + // standalone (paragraph break before / page top) — headings + // hug their section's first paragraph, so requiring a break + // after as well missed most of them. Mixed bold lead-ins + // ("Note: ...") are excluded by all_bold. + let enough_words = word_count >= 2 || (all_bold && plain_trimmed.len() >= 4); let numbered_bold = all_bold && starts_with_section_number(plain_trimmed); if numbered_bold || (score >= 0.5 && standalone && enough_words && has_strong_signal) diff --git a/tests/snapshots/p1244-1996.md b/tests/snapshots/p1244-1996.md index be353ed..011b130 100644 --- a/tests/snapshots/p1244-1996.md +++ b/tests/snapshots/p1244-1996.md @@ -22,7 +22,9 @@ Name and address of employee **Publication 1244 (Rev. 7-96)** Cat. No. 44472W -**Instructions** You must keep sufficient proof to show the amount of your tip income for the year. A daily record of your tip income is considered sufficient proof. Keep a daily record for each workday showing the amount of cash and credit card tips received directly from customers or other employees. Also keep a record of the amount of tips, if any, you paid to other employees through tip sharing, tip pooling or other arrangements, and the names of employees to whom you paid tips. Show the date that each entry is made. This date should be on or near the date you received the tip income. You may use **Form 4070A**, Employee’s Daily Record of Tips, or any other daily record to record your tips. **Reporting Tips to Your Employer.—**If you receive tips that total $20 or more for any month while working for one employer, you must report the tips to your employer. Tips include cash left by customers, tips customers add to credit card charges, and tips you receive from other employees. You must report your tips for any one month by the 10th day of the next month. If the 10th day falls on a Saturday, Sunday, or legal holiday, you may give the report to your employer on the next business day that is not a Saturday, Sunday, or legal holiday. You must report tips that total $20 or more every month regardless of your total wages and tips for the year. You may use **Form 4070**, Employee’s Report of Tips to Employer, to report your tips to your employer. See the instructions on the back of Form 4070. You must include all tips, including tips not reported to your employer, as wages on your income tax return. You may use the last page of this publication to total your tips for the year. Your employer must withhold income, social security, and Medicare (or railroad retirement) taxes on tips you report. Your employer usually deducts the withholding due on tips from your regular wages. +### Instructions + +You must keep sufficient proof to show the amount of your tip income for the year. A daily record of your tip income is considered sufficient proof. Keep a daily record for each workday showing the amount of cash and credit card tips received directly from customers or other employees. Also keep a record of the amount of tips, if any, you paid to other employees through tip sharing, tip pooling or other arrangements, and the names of employees to whom you paid tips. Show the date that each entry is made. This date should be on or near the date you received the tip income. You may use **Form 4070A**, Employee’s Daily Record of Tips, or any other daily record to record your tips. **Reporting Tips to Your Employer.—**If you receive tips that total $20 or more for any month while working for one employer, you must report the tips to your employer. Tips include cash left by customers, tips customers add to credit card charges, and tips you receive from other employees. You must report your tips for any one month by the 10th day of the next month. If the 10th day falls on a Saturday, Sunday, or legal holiday, you may give the report to your employer on the next business day that is not a Saturday, Sunday, or legal holiday. You must report tips that total $20 or more every month regardless of your total wages and tips for the year. You may use **Form 4070**, Employee’s Report of Tips to Employer, to report your tips to your employer. See the instructions on the back of Form 4070. You must include all tips, including tips not reported to your employer, as wages on your income tax return. You may use the last page of this publication to total your tips for the year. Your employer must withhold income, social security, and Medicare (or railroad retirement) taxes on tips you report. Your employer usually deducts the withholding due on tips from your regular wages. *(continued on inside of back cover)* diff --git a/tests/snapshots/thermo-freon12.md b/tests/snapshots/thermo-freon12.md index 58c94eb..d27d413 100644 --- a/tests/snapshots/thermo-freon12.md +++ b/tests/snapshots/thermo-freon12.md @@ -10,7 +10,9 @@ # Freon 12 -**(R-12)** **Technical Information Technical Information** +##### (R-12) + +##### Technical Information Technical Information **®** **Thermodynamic Properties of Freon 12 Refrigerant** **(R-12)** **SI Units**