Render headings via Spectre.Console FigletText (IHeaderStyle, default H1)#113
Render headings via Spectre.Console FigletText (IHeaderStyle, default H1)#113Copilot wants to merge 10 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #113 +/- ##
==========================================
+ Coverage 95.37% 95.64% +0.27%
==========================================
Files 27 28 +1
Lines 1512 1606 +94
Branches 160 171 +11
==========================================
+ Hits 1442 1536 +94
Misses 46 46
Partials 24 24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
boxofyellow
left a comment
There was a problem hiding this comment.
@copilot please check out these comments.
Please also double check https://github.com/boxofyellow/ConsoleMarkdownRenderer/blob/main/docs/adding_a_new_renderer.md to make sure there are no relevant steps missed.
All comments addressed in ae3efc5. Re:
|
boxofyellow
left a comment
There was a problem hiding this comment.
@copilot Please see address these comment.
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
…s via resource test Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
…README tidy Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
bab9607 to
76c99a8
Compare
boxofyellow
left a comment
There was a problem hiding this comment.
@copilot Please look at these comments
Additionally as expected this change breaks binary compatibility. All though it seems unlikely to affect must consumers
So we release this change as 0.11.0 Please prepare a migration guide you can file multiple examples in docs directory
EffectiveHeaderbeing public was a mistake, consumers should not need it- Changing type of
HeaderandHeadersshould be a minimal impact since consumers are not really expected to read those properties only set them.
However this change does have a size able functional change. Swopping out the default used for the top leave header. This should be called out and detail a long with example output of before an after for a simple markdown file that details shows this difference.
Please also provide details for consumers where that to obtain the old behavior they only need to clear the Headers list.
…age, consolidate ToSpectreStyle Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
All addressed.
|
boxofyellow
left a comment
There was a problem hiding this comment.
@copilot Please checkout these comments.
…Async, doc trim Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
boxofyellow
left a comment
There was a problem hiding this comment.
@copilot Please checkout these comments.
…ileManager in tests Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
boxofyellow
left a comment
There was a problem hiding this comment.
@copilot Please address this comment.
…factories Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
boxofyellow
left a comment
There was a problem hiding this comment.
@copilot please address this comment.
…uctor Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
New Feature
Adds support for rendering Markdown headings as large FIGlet ASCII art via Spectre.Console's
FigletTextwidget. Heading styles are plumbed through a newIHeaderStyleinterface implemented by both the existingTextStyle(styled markup) and a new peerFigletTextStyle(FIGlet ASCII art), so any heading level can independently choose either rendering path.What does this feature do?
DisplayOptions.HeaderandDisplayOptions.Headersare typed asIHeaderStyle. Assigning aFigletTextStyleto a level causes that level to be rendered as aFigletTextrenderable; assigning aTextStylekeeps the original styled,#-wrapped markup. By defaultHeaders[0]is a centered, blueFigletTextStyle, so#headings render as FIGlet ASCII art out of the box. Deeper levels continue to fall through to the styledHeader.Why is this feature needed?
A prominent ASCII-art title makes the top of a document immediately distinguishable from body text in terminal output. Making it the H1 default surfaces the feature without configuration; existing callers can opt back into the original behavior with a single assignment.
Implementation details
IHeaderStyleinterface with a singleTextJustification? Justificationmember. BothTextStyleandFigletTextStyleimplement it;TextStyle.Justificationis an explicit interface implementation hard-coded tonull.TextStyleremainssealedand is otherwise unchanged.TextJustificationenum (Left/Right/Center) mirrorsSpectre.Console.Justify, modeled on the existingTextDecorationpattern (including an enum-coverage test).FigletTextStyleis asealedpeer ofTextStyle(not a subclass), exposing onlyJustificationandForeground—FigletTextdoes not support decoration or background, so those properties are intentionally absent.DisplayOptionstypedHeader/Headers/EffectiveHeaderagainstIHeaderStyle; defaultHeadersis[new FigletTextStyle(justification: TextJustification.Center, foreground: TextColor.Blue)].WrapHeaderstill applies toTextStyleentries and is ignored forFigletTextStyle.TextStyleExtensionsgains an internalToSpectreJustify;ToSpectreColoris exposed internally for reuse by the new renderer path.ConsoleHeadingBlockRendererswitches on the runtimeIHeaderStyletype and dispatches to aWriteFigletorWriteStyledhelper. The FIGlet path walks the heading's inline tree to collect plain text (FIGlet takes no markup), handlingLiteralInline,CodeInline, and nestedContainerInline(emphasis, etc.), then emits aFigletTextvia a newConsoleRendererBase<T>.AddRenderablehelper that drops an arbitraryIRenderableonto the current frame. The styled path is unchanged.IHeaderStyle, both implementations, the new default, how to opt back into styled markup, and explicit when-to-use / when-to-avoid guidance.Tests
TextJustificationTests— enum coverage againstJustify+ conversion round-trip.FigletTextStyleTests— defaults, property preservation, equality,IHeaderStyleinterface contract (including the explicitTextStyle.Justification => nullguarantee).RendererTestscases:Assert.DoesNotContain("#", output)).## … ##/### … ###wrapping.Headers[0]with a plainTextStylerestores the styled#-wrapped markup for H1.headingBlock.md/headingBlock.txtresource pair extended to cover every FIGlet branch — literal text, inline code, inline emphasis (container), and an empty#heading — plus the existing H2/H3 styled cases. The regenerated.txtlets the FIGlet output be visually inspected in the PR diff.bracketEscaping.mdH1 changed to H2 (FIGlet would obscure the bracket characters under test);bracketEscaping.txtregenerated.DisplayTests_NonInteractiveTerminalWithNoLinksExitsCleanlyAsyncupdated to use H2 so its expected output reflects the new default.