You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Added
Added fontSizes to CDMarkdownHeader and CDMarkdownTheme.HeaderTheme, an optional array of absolute point sizes indexed by heading level (index 0 = h1 through index 5 = h6). When set to a non-empty array it fully drives heading sizing and fontIncrease is ignored, letting callers express an arbitrary non-linear size curve rather than the single fixed ratio fontIncrease allows. A shorter array clamps deeper levels to its last entry; nil (the default) and an empty array leave existing behavior unchanged.
Added caller-supplied syntax highlighting for fenced code blocks. CDMarkdownTheme.codeSyntaxColors (and CDMarkdownSyntax.syntaxColors) take a map from semantic token type — keyword, type, string, comment, number, function, attribute — to colour; when set, the parser writes matching foregroundColor runs across the block, so every renderer (UIKit, AppKit, and both SwiftUI views) picks it up with no additional work. A small built-in tokenizer covers Swift and common C-family languages; supply a custom CDMarkdownSyntaxHighlighter via CDMarkdownSyntax.syntaxHighlighter for other languages or a different engine. Blocks with no language hint, or an unrecognised one, keep rendering as plain monospace, and leaving the colour map empty (the default) keeps output byte-for-byte identical to before.
Added an intrinsicContentSize override to CDMarkdownTextView and CDMarkdownNSTextView, so a text view used directly under UIKit or AppKit Auto Layout — with scrolling disabled and no explicit height constraint — grows to fit its content. On CDMarkdownTextView this reports a measured height only when isScrollEnabled is false; the default scroll-enabled view keeps UITextView's behavior, so existing callers are unaffected. Both views re-invalidate the intrinsic size when their attributed text is set and when their width changes.
Changed
Aligned .swiftformat, .swiftlint.yml, and CI conventions with this project's established tooling standards, including bumping .swiftformat's target Swift version to 6.0 to match swiftLanguageModes: [.v6], and adding an Example-app build to CI.
Tightened the file_length, function_body_length, and type_body_length SwiftLint limits to the tool's own default thresholds. Every violation this surfaced was fixed by restructuring the affected code — splitting CDMarkdownParser and CDMarkdownLabel into per-concern extension files and extracting oversized functions into named helpers — rather than raising the limits or disabling the rules.
Refactored the two built-in syntax lexers to share their common scanning scaffolding — comment, sigil, number, and identifier consumption — through a single internal seam, so they can no longer drift in how they classify the same construct. Purely internal; token output is unchanged.
Fixed
Fixed CDMarkdownView rendering its content outside, or independent of, the frame SwiftUI assigns it when placed in a ScrollView. The SwiftUI representable now reports a measured content size for the proposed width, so the view lays out within its assigned bounds and scrolls with the enclosing ScrollView like CDMarkdownText already did. CDMarkdownTextView gains a sizeThatFits(_:) override (used when scrolling is disabled) and CDMarkdownNSTextView a fittingHeight(forWidth:) method, so both also size correctly under UIKit and AppKit Auto Layout.
Loosened two test-only wall-clock timing budgets (catastrophic-backtracking guards for an unterminated inline-code span and an unterminated fenced code block) from 2 seconds to 10, fixing intermittent failures on a loaded visionOS CI simulator.
Improved language fidelity in the built-in fenced-code syntax highlighter. match now keyword-colours in Rust and def in Scala and Groovy, without those words colouring in the other C-family languages that share the highlighter. A C++ digit separator such as 1'000'000 and a Rust lifetime such as &'a are no longer scanned as a string. A lone @ or # with no identifier after it no longer emits a stray one-character attribute token. In Swift, a string interpolation segment that itself contains a quoted string or parenthesis — "\("a ) b")" — no longer truncates the surrounding literal.