Skip to content

Fix Apple notes heading conversion#6

Open
craditsch wants to merge 3 commits into
shakedlokits:masterfrom
craditsch:fix/apple-notes-heading-conversion
Open

Fix Apple notes heading conversion#6
craditsch wants to merge 3 commits into
shakedlokits:masterfrom
craditsch:fix/apple-notes-heading-conversion

Conversation

@craditsch
Copy link
Copy Markdown

@craditsch craditsch commented Apr 20, 2026

This pull request updates the Apple Notes HTML-to-Markdown conversion to better recognize and convert Apple Notes heading patterns into proper Markdown headings. It also introduces new tests and fixtures to cover these heading cases.

Apple Notes heading conversion improvements:

  • The _convert_apple_headings function in html_to_markdown.sh now detects and converts Apple Notes H1 (font-size: 24px) and H2 (font-size: 18px) styled headings to <h1> and <h2> HTML tags, respectively. H3 and bold text remain indistinguishable and are handled as bold.
  • Test fixtures (apple_notes_sample.html, apple_notes_headings.html) and approval files have been updated to use Apple Notes’ styled heading patterns, ensuring the conversion logic is tested against real-world samples. [1] [2] [3] [4]
  • The test suite (unit_html_to_markdown_spec.sh) now includes a dedicated test for Apple Notes heading styles, verifying correct conversion to Markdown headings.
  • The approval output for the sample file has been updated to reflect that H3 headings, which are just bold text in Apple Notes, are now converted to Markdown bold instead of heading syntax.

Summary by CodeRabbit

  • New Features

    • Enhanced Apple Notes document conversion to properly handle both title and section-level headings in markdown output
    • Added cleanup of formatting artifacts for cleaner markdown conversion
  • Tests

    • Added test coverage for Apple Notes heading conversion scenarios

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fe2327d0-5f3d-48a0-97c2-effe3ed0e4c8

📥 Commits

Reviewing files that changed from the base of the PR and between e083a2e and 38e8c40.

📒 Files selected for processing (6)
  • src/lib/html_to_markdown.sh
  • test/approvals/html_to_markdown_apple_notes_headings
  • test/approvals/html_to_markdown_apple_notes_sample
  • test/cases/unit_html_to_markdown_spec.sh
  • test/fixtures/apple_notes_headings.html
  • test/fixtures/apple_notes_sample.html

📝 Walkthrough

Walkthrough

Enhanced Apple Notes HTML to Markdown conversion by generalizing heading conversion to process both H1 and H2 styled patterns, adding hard-break removal post-processing, and introducing corresponding test fixtures and approval tests.

Changes

Cohort / File(s) Summary
Core Library Updates
src/lib/html_to_markdown.sh
Replaced Apple Notes title-specific converter with generalized _convert_apple_headings() function supporting both H1 and H2 patterns. Added _remove_hard_breaks() to strip hard-break markers from blank lines. Updated html_to_markdown() pipeline to use new converters.
Test Fixtures
test/fixtures/apple_notes_headings.html, test/fixtures/apple_notes_sample.html
Added new HTML fixture with styled divs/spans representing H1 (24px) and H2 (18px) headings. Simplified existing sample fixture by replacing multi-line semantic heading divs with single-line inline-styled markup while preserving list structures.
Test Cases & Approvals
test/cases/unit_html_to_markdown_spec.sh, test/approvals/html_to_markdown_apple_notes_headings, test/approvals/html_to_markdown_apple_notes_sample
Added unit approval test for new apple_notes_headings fixture. Updated approval output for sample fixture by converting "Additional Notes" from H3 header syntax to bold text.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Apple Notes styles now aligned so neat,
H1 and H2 headings dance in sync,
Bold new tests ensure the flow's complete,
Hard breaks vanish—cleaner than you'd think!
Markdown conversion hops along with glee. 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: expanding Apple Notes heading conversion from H1-only to multi-level headings (H1 and H2) with a new helper function and post-processing step.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@shakedlokits
Copy link
Copy Markdown
Owner

Hey @craditsch, it looks good! Sorry for the delay, I'm on vacation for the next week. Will test it manually when I get back.

And great job on the tests and code rabbit. You made me realize I should add contribution guidelines and CI, etc. 🙏🏽

Copy link
Copy Markdown
Owner

@shakedlokits shakedlokits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall, also tested it locally manually (how pristine has manual work become) for integration.
Just left a few small questions🙏

<div>
<h1>Sample Project Notes</h1>
</div>
<div><b><span style="font-size: 24px">Sample Project Notes</span></b></div>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this fetched from Apple Notes directly?

}

# Helper: Remove standalone hard breaks from Apple Notes blank lines
_remove_hard_breaks() {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this effect and why?
I mean, like what would be different without it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants