Skip to content

Conversation

@luandro
Copy link
Contributor

@luandro luandro commented Oct 23, 2025

Summary

This PR fixes two related content rendering issues to improve consistency between Notion and published documentation:

  1. Issue Preserve manual line breaks from Notion in generated Markdown #47: Preserve manual line breaks from Notion in generated Markdown
  2. Issue Match paragraph and list spacing with Notion layout #48: Match paragraph and list spacing with Notion layout

Changes

Issue #47: Manual Line Breaks

  • Modified scripts/notion-fetch/exportDatabase.ts to preserve manual line breaks (Shift+Enter) from Notion
  • Converts newline characters (\n, \u2028, \u2029) to HTML <br /> tags
  • Applied to rich_text arrays, title blocks, captions, and code blocks
  • Ensures consistent line break preservation across all block types

Issue #48: Spacing Adjustments

  • Updated src/css/custom.css to reduce paragraph and list spacing
  • Reduced paragraph margin-bottom from ~1rem to 0.5rem
  • Reduced list margin-bottom to 0.75rem
  • Added nested list spacing adjustments
  • Scoped to .theme-doc-markdown to avoid affecting other components

Testing

  • ✅ All existing Vitest tests pass (13/13 in runFetchPipeline.test.ts)
  • ✅ Linting and formatting applied with no errors
  • ✅ Pre-commit hooks passed successfully
  • ✅ No breaking changes to existing functionality

Manual Testing Needed

  • Visual verification of CSS spacing on docs pages with paragraphs and lists
  • Before/after screenshots for CSS changes (to be added to PR comments)
  • Test with a Notion page containing manual line breaks to verify they render correctly

Notes

  • CSS changes are scoped to avoid affecting landing pages, admonitions, tables, and other components
  • The manual line break feature works with MDX/Docusaurus which supports inline HTML (<br />)
  • Pre-existing ESLint security warnings in exportDatabase.ts are unrelated to these changes

Closes #47
Closes #48

@luandro
Copy link
Contributor Author

luandro commented Oct 23, 2025

Testing Update

Added comprehensive test coverage for line break preservation in commit f4e7f66:

  • ✅ 6 new test cases covering all line break scenarios
  • ✅ Tests for \n, \u2028, and \u2029 character conversion
  • ✅ Tests for rich_text, captions, and code blocks
  • ✅ All tests passing (8/8 in exportDatabase.test.ts)

Visual Comparison Needed

The CSS spacing changes in src/css/custom.css (Issue #48) require before/after screenshots for visual verification.

To capture screenshots:

1. Revert CSS changes temporarily:

git stash
# Or checkout the CSS file from main:
# git checkout main -- src/css/custom.css

2. Start dev server:

bun run dev

3. Capture BEFORE screenshots:

# Example for a docs page with paragraphs and lists
bun scripts/screenshot-prs.ts --url /docs/overview --name before-spacing

4. Re-apply CSS changes:

git stash pop
# Or re-checkout this branch's version:
# git checkout fix/preserve-line-breaks-and-spacing -- src/css/custom.css

5. Capture AFTER screenshots:

# Same page as before
bun scripts/screenshot-prs.ts --url /docs/overview --name after-spacing

6. Upload screenshots:

  • Edit this comment
  • Drag and drop screenshots/before-spacing.png and screenshots/after-spacing.png
  • Preview to verify images display correctly
  • Save comment

Expected Changes

The CSS modifications reduce vertical spacing to match Notion's layout:

  • Paragraph spacing: ~1rem → 0.5rem
  • List spacing: reduced to 0.75rem
  • List item spacing: reduced to 0.25rem
  • Nested list spacing: 0.25rem top/bottom margins

The visual difference should show more compact, readable content that better matches the source Notion pages.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2025

🚀 Preview Deployment

Your documentation preview is ready!

Preview URL: https://pr-57.comapeo-docs.pages.dev

This preview will update automatically when you push new commits to this PR.


Built with commit 4c90b1b

@digidem digidem deleted a comment from github-actions bot Oct 31, 2025
@luandro
Copy link
Contributor Author

luandro commented Oct 31, 2025

Code Review Summary

What This PR Does

This PR addresses two separate but related issues in the content rendering pipeline:

Issue #47 - Manual Line Breaks Preservation:

  • Modifies extractTextFromBlock() in exportDatabase.ts to convert newline characters (\n, \u2028, \u2029) to HTML <br /> tags
  • Applied consistently across rich_text arrays, title blocks, captions, and code blocks
  • Adds 6 comprehensive test cases covering various line break scenarios including Unicode separators

Issue #48 - Spacing Alignment:

  • Updates custom.css to reduce paragraph spacing from ~1rem to 0.5rem
  • Reduces list margins to better match Notion's visual rhythm
  • All changes scoped to .theme-doc-markdown to avoid affecting other components

How It Solves the Issues

  1. Line Breaks: The regex replacement .replace(/[\n\u2028\u2029]/g, "<br />\n") ensures Shift+Enter line breaks in Notion are preserved through the export pipeline and render correctly in the final documentation
  2. Spacing: CSS margin adjustments align the visual spacing between paragraphs and lists with Notion's tighter layout, improving consistency between authoring and published experience

Potential Issues & Considerations

Strengths:

  • ✅ Comprehensive test coverage (224 lines of new tests)
  • ✅ Proper scoping with .theme-doc-markdown to avoid side effects
  • ✅ Handles Unicode line separators (U+2028, U+2029) correctly
  • ✅ All existing tests pass (13/13)

Areas to Watch:

  • ⚠️ PR fix(docs): align docs spacing with notion #51 Duplicate: This PR includes spacing changes that overlap with PR fix(docs): align docs spacing with notion #51 (also about spacing). If both merge, there could be conflicting CSS rules
  • ⚠️ Manual Testing Needed: As noted in the PR description, visual verification of spacing changes should be performed with screenshots
  • ⚠️ Security Warning: Pre-existing ESLint security warnings in exportDatabase.ts are noted as unrelated but should be addressed separately

Code Quality:

  • Clean, focused changes with good test coverage
  • Follows existing code patterns
  • Proper error handling for edge cases (multiple consecutive line breaks)

Recommendation:Approve - Good implementation with solid test coverage. Just coordinate with PR #51 to avoid CSS conflicts.

@luandro luandro marked this pull request as draft November 5, 2025 13:36
@luandro
Copy link
Contributor Author

luandro commented Nov 5, 2025

@codex pull from main resolving conflicts and review this PR making sure it's ready for merge.

@chatgpt-codex-connector
Copy link

Summary

Testing

  • ⚠️ bunx vitest run scripts/notion-fetch/__tests__/exportDatabase.test.ts (fails: npm registry returned 504 while fetching vitest)

View task →

@luandro luandro marked this pull request as ready for review November 5, 2025 20:27
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

function analyzeBlock(block: Record<string, any>): BlockAnalysis {
const blockType = block.type || "unknown";
const textContent = extractTextFromBlock(block);
const hasContent = textContent.length > 0 && textContent.trim() !== "";
const hasChildren =
block.has_children || (block.children && block.children.length > 0);
const childrenCount = hasChildren ? block.children?.length || 0 : 0;
return {
type: blockType,
hasContent,
contentLength: textContent.length,

P1 Badge Avoid counting HTML <br /> in content scoring

Manual line breaks are now converted to "<br />\n" inside extractTextFromBlock, but analyzeBlock immediately uses the mutated string to compute contentLength. Each former newline now contributes six extra characters, so blocks with many line breaks (especially code blocks) will score much higher than before and can exceed thresholds like >50 or >100 characters without having additional textual content. This inflates the contentScore, totalTextLength, and related analytics emitted by exportNotionDatabase, defeating the purpose of those metrics. Consider measuring length before injecting <br /> or strip the HTML tags when calculating scores.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@luandro luandro force-pushed the fix/preserve-line-breaks-and-spacing branch from 7fe544a to d63c759 Compare November 5, 2025 22:42
@luandro luandro merged commit bb8f021 into main Nov 6, 2025
4 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

🧹 Preview Deployment Cleanup

The preview deployment for this PR has been cleaned up.

Preview URL was: https://pr-57.comapeo-docs.pages.dev


Note: Cloudflare Pages deployments follow automatic retention policies. Old previews are cleaned up automatically.

@luandro luandro deleted the fix/preserve-line-breaks-and-spacing branch November 6, 2025 00:42
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.

Match paragraph and list spacing with Notion layout Preserve manual line breaks from Notion in generated Markdown

2 participants