Conversation
Create a single print.css file in Extensions directory that loads universally for all themes, instead of modifying 6 theme files individually. This provides cleaner architecture and consistent PDF export behavior. Changes: - Add MacDown/Resources/Extensions/print.css with @media print rules for code block wrapping and overflow handling - Modify MPRenderer.m to load print.css last in stylesheet cascade, ensuring it overrides theme defaults with proper specificity - CSS includes comprehensive selectors: pre, pre code, code, p code, td code, etc. with !important declarations - Includes overflow-wrap: break-word for edge cases (URLs, no-space strings) Technical approach: - print.css loads LAST in cascade (critical for overriding themes) - Uses matching specificity (0-0-2) with theme CSS - @media print ensures no impact on preview rendering - Single source of truth for all 6 themes Related to #28
Add resolution sections to investigation documents clarifying that the approach of modifying 6 individual theme files was abandoned in favor of a universal print.css solution. Changes: - ISSUE_28_INVESTIGATION.md: Add resolution section with final solution details - PDF_EXPORT_CSS_DEBUG_REPORT.md: Note that proposed fix was superseded - CSS_SPECIFICITY_ISSUE.md: Clarify alternative implementation approach These updates prevent confusion about which files were actually modified and provide complete narrative of the investigation and resolution. Related to #28
Contributor
Code Coverage ReportCurrent Coverage: 39.53% Coverage Details (Summary) |
Add table-specific CSS using :has() selector to fix Test 4 failure where long code in table cells was not wrapping properly. IMPORTANT: Uses :has() selector to target ONLY tables containing code. Regular data tables keep natural column sizing (table-layout: auto). This avoids breaking changes to existing PDF table layouts. Graceful degradation: If :has() is not supported by WebKit PDF rendering, the fix won't apply (code may overflow) but regular tables remain unaffected. This is preferable to breaking all existing table layouts. Changes: - Add table:has(code) selector with table-layout: fixed and width: 100% - Add max-width: 0 on cells ONLY in tables containing code (CSS hack) - Use overflow-wrap: break-word for long identifiers without spaces - All properties use !important to override theme CSS Technical details: - table-layout: fixed distributes columns evenly (only for tables with code) - max-width: 0 forces content to wrap while fixed layout determines actual width - :has() selector is CSS4 - surgical targeting of specific tables - Graceful degradation if :has() unsupported Expected result: Test 4 (Tables with Long Code) passes if :has() supported Success rate: 8/8 tests (100%) if :has() works, 7/8 (87.5%) if not No breaking changes to existing table layouts either way Manual testing needed: Verify :has() works in WebKit PDF rendering Related to #28
5faeea3 to
22c482c
Compare
Owner
Author
|
Manual testing worked. |
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.
Summary
Fixes code blocks with long lines being cut off when exporting to PDF. Uses an elegant architecture: a single universal
print.cssfile instead of modifying 6 individual theme CSS files.Changes
New File:
MacDown/Resources/Extensions/print.cssUniversal print stylesheet with
@media printrules for code overflow handling:pre,pre code,code,p code,li code,td code,th codewhite-space: pre-wrap !importantandoverflow-wrap: break-word !importantModified:
MacDown/Code/Document/MPRenderer.m(lines 503-505)Loads
print.cssLAST in stylesheet cascade (after all theme CSS):Updated Documentation
Added resolution sections to investigation docs in
plans/:ISSUE_28_INVESTIGATION.md- Documents final solution vs. abandoned approachPDF_EXPORT_CSS_DEBUG_REPORT.md- Notes proposed fix was supersededCSS_SPECIFICITY_ISSUE.md- Clarifies alternative implementationArchitecture
Why This Approach (vs. PR #125):
Technical Details:
pre code(0-0-2) matches theme CSS specificity!importantdeclarations force override when specificity is equal@media printensures no impact on preview renderingPrevious Investigation (PR #125):
Code Review
Chico (Code Reviewer): ✅ APPROVED
!importantusage is justified for print contextGroucho (Architect): ✅ APPROVED
show-information.css)Harpo (Documentation): ✅ UPDATED
Testing
CI Status
✅ All unit tests passed - Workflow run 19522611904 completed successfully in 2m8s
Manual Testing Required
macOS + Xcode required - PDF rendering cannot be automated
Test Files:
plans/test-pdf-export-samples/00-comprehensive-test.md- All 8 scenarios in one file01-long-single-line.mdthrough05-edge-cases.md- Individual scenariosTest Matrix (8 scenarios × 6 themes):
Themes to Test:
Target Success Rate: 8/8 scenarios passing (vs. previous 2/8 = 300% improvement)
Manual Testing Instructions
Quick Test (15 min):
plans/test-pdf-export-samples/00-comprehensive-test.mdDetailed Test Plan: See Zeppo's comprehensive testing guide in MANUAL_TESTING.md (includes debugging steps, edge cases, success criteria)
Key Things to Verify:
Related Issue
Related to #28
Follow-up Recommendations
From code review:
printURL(consistent with codebase patterns, but not critical)@media printrules from theme CSS files to reduce duplicationNotes
plans/test-pdf-export-samples/