feat: add native styling support for fenced div blocks (:::classname)#65
Merged
Conversation
Implements Issue #63. Fenced div blocks (:::classname ... :::) can now be styled via YAML preset configuration without post-processing scripts. ## YAML configuration Styles: FencedDivs: try: BackgroundColor: "F2F2F2" BorderTopColor: "AAAAAA" BorderTopSize: 4 BorderBottomColor: "AAAAAA" BorderBottomSize: 4 hint: BackgroundColor: "EBF5FB" ## Implementation - FencedDivStyle / FencedDivContent models (Core) - FencedDivClassConfig + FencedDivs dict in StyleConfiguration (Styling) - ApplyFencedDivStyle() in StyleApplicator - AddFencedDiv() in OpenXmlDocumentBuilder: - Background shading on all child paragraphs/headings/lists - Top separator border on first block, bottom on last block - Body cell background shading on tables (via TableStyle.BodyCellBackgroundColor) - Spacer paragraphs injected when div starts/ends with a table - CustomContainer case in Program.cs (Markdig UseAdvancedExtensions already includes UseCustomContainers, so no parser change required) - 5 new unit tests: 282 → 287 passing Closes #63
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #65 +/- ##
==========================================
- Coverage 94.21% 89.06% -5.15%
==========================================
Files 25 27 +2
Lines 1209 1372 +163
Branches 142 174 +32
==========================================
+ Hits 1139 1222 +83
- Misses 41 113 +72
- Partials 29 37 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
:::classname ... :::) can now be styled natively via YAML preset configuration, eliminating the need for post-processing scriptsYAML configuration example
Markdown usage
Implementation notes
Markdig.UseAdvancedExtensions()already includesUseCustomContainers()— no parser change neededTableStyle.BodyCellBackgroundColor(nullable) applies div background to table body cellsTest plan
AddFencedDiv_WithParagraphOnly_ShouldApplyBackgroundAndBordersAddFencedDiv_WithMultipleParagraphs_TopBorderOnFirstBottomBorderOnLastAddFencedDiv_WithNoBorderColors_ShouldApplyOnlyBackgroundAddFencedDiv_WithTableBodyCell_ShouldApplyBackgroundShadingAddFencedDiv_WithEmptyContent_ShouldAddNoParagraphsCloses #63