Releases: gewill/swiftui-markdown
Release list
v2.0.1
Fixes the box that 2.0.0 drew behind the preview, and adds documentation for
the public API, hosted on Swift Package Index. A patch release: the public API
is unchanged, and the Swift sources gain only documentation comments.
Added
- DocC documentation for the public API, with a landing page and an article on
bundling fonts..spi.ymllets Swift Package Index build and host it (#18).
Changed
- Strip the README down to this fork. It carried the upstream author's app
promotion banner, sponsor and social badges, a CI badge reporting another
repository's builds, and installation instructions pointing at the upstream
package — following them installed something else. The platform badge said
macOS 10.15 and iOS 13, where the package requires macOS 11, iOS 14 and
visionOS 1. The example pages carried copies of the same badges and URL
(#19). - Reshoot the README's video and screenshots. They dated from 2022 and showed
the old renderer text, the upstream package URL and the old platforms, with
none of the font support. The video now switches fonts and appearance in a
running preview. The media is uploaded as attachments rather than committed,
since SwiftPM clones the whole repository for every package that depends on
it. The contributors image, which pointed at a GitHub Pages site this
repository has never had and so never loaded, now comes from the gh-pages
branch (#22).
Fixed
- The preview is transparent again, so the host app's background shows through.
The stylesheet synced in 2.0.0 paints.markdown-bodywith its own canvas
colour, which drew a box that stopped where the content ended: dark grey on
black in iOS dark mode, and white on a grey window in macOS light mode
(#21). - Links to
markdownStyle(_:)in the documentation resolve. They named the
SwiftUImodule, butViewlives inSwiftUICorein current SDKs, so all
four rendered as plain text. The build that produced them reported no
problems only because DocC was reusing cached output (#20).
Internal
- Documentation is built on every pull request with warnings as errors, so a
link that stops resolving fails CI (#20). - The site workflow no longer asks GitHub for the latest release. It did so only
to word a commit message, and failed on every push tomainuntil the first
release existed. It is renamed from "CI" to "Deploy Site", since the tests
live in their own workflow (#20). - Only the site workflow publishes the gh-pages branch; the release workflow
duplicated that build and now only creates the release, linking to the
documentation on Swift Package Index (#20).
Full diff: v2.0.0...v2.0.1
Documentation: https://swiftpackageindex.com/gewill/swiftui-markdown/documentation/markdown
v2.0.0
Custom font support for the Markdown preview, plus the correctness, performance
and API work that followed from reviewing it, and the renderer sync that came
out of asking where the HTML actually comes from. Major because of the two
public API changes marked Breaking below; the renderer also crossed two of
its own major versions.
Added
- Font configuration on
MarkdownStyle:fontFamily,fontSize,lineHeight
andcodeFontFamily. Every field is optional on its own, so changing only the
size keeps the default typeface (#2, #10). MarkdownFontFaceandMarkdownFontSourcefor loading a face from a file URL,
an app resource, or an explicitBundle. Faces are injected as@font-face
rules carrying a base64 data URL, so the WebView never reads across bundles
(#2).- Style changes made through
.markdownStyle(_:)now reach a live WebView.
Previously they only applied when the view was created (#2). - A Fonts page in the example app covering system stacks and the bundled
Atkinson Hyperlegible and Merriweather four-face families (#2). - Continuous integration: the test suite plus the macOS and iOS example builds
run on every pull request. The only previous workflow rendered the README into
a site on pushes tomain, so nothing ran the tests (#2).
Changed
-
Breaking.
MarkdownFontFacetakesMarkdownFontWeightand
MarkdownFontStyleinstead ofString?. They cover what@font-face
accepts —.normal,.bold,.value(700),.range(400, 700),.italic,
.oblique,.obliqueAngle(14)— and a value CSS would reject is dropped with
a log rather than written into the rule. Migration:fontWeight: "700"becomes
.boldor.value(700),fontStyle: "italic"becomes.italic(#10). -
Breaking.
MarkdownStylehas one initialiser instead of five. Three of the
old ones differed only in which padding arguments they accepted, and the two
that took font settings requiredfontFamily. Padding behaviour is unchanged:
per-edge values apply overpadding, so passing onlypaddingTopleaves the
other three edges at the default. Call sites that pass only padding, or a full
font configuration, compile unchanged (#10). -
Custom properties are written directly to
documentElement.style, and
@font-facerules live in their own element that is rebuilt only when the
faces change, with the encoding done off the main thread. Previously every
style change rewrote a single sheet holding both: for the four-face
Merriweather family that meant re-sending and re-parsing 1.4 MB, which dropped
every loaded font back tounloaded— changing only the font size flashed
fallback text. A style update now ships 201 bytes instead of 1.5 MB, and
escaping it on the main thread went from 9.6 ms to 0.08 ms (#6). -
Encoded faces are held in a bounded
NSCacheinstead of a static dictionary
that was never reclaimed (#6). -
@font-facedeclaresformat(), inferred from the file extension and omitted
for unknown ones so WebKit can still sniff them (#6). -
The example ships its fonts as woff2: 1.3 MB of TrueType became 398 KB, and
the OFL texts are in the built app, which previously shipped the fonts without
the license the OFL asks to accompany them (#9). -
Sync the bundled renderer,
@wcj/markdown-to-html, from 1.0.0 (2022) to 3.0.6.
Its public surface is unchanged —markdown.default(),getCodeString()and
therewriteoption all behave the same — and the minified bundle drops from
3.2 MB to 1.2 MB. The stylesheet it ships was re-patched with this fork's font
variables rather than overwritten (#14).
Fixed
-
Theme switching works.
setThemewas addingtheme-lightandtheme-dark
classes that no stylesheet has ever read; light and dark actually came from
theprefers-color-schemequeries in the old stylesheet, so thetheme
argument had no effect. 3.0.6 keys its colour variables off a
data-color-modeattribute instead, which is now set on the document element
— without it every colour variable would be undefined (#14). -
Drop the
.math.math-inlinerule. It existed to clear the grey background of
the<code>element that used to wrap inline KaTeX; 3.0.6 emits the KaTeX
span directly, so the rule matched nothing (#14). -
Fenced code blocks keep their monospace stack when only
fontFamilyis set.
A single custom property fed both inline code and code blocks, so setting a
body typeface turned code blocks into it and destroyed column alignment.
Inline code still inherits the body font (#2). -
An
appResourcewhosebundleIdentifierdoes not resolve drops the face
instead of quietly searching the main bundle, where it could pick up an
unrelated font with the same name. The missing-resource and unreadable-file
paths log in debug builds (#2). -
The preview recovers when the web content process is terminated. The view kept
believing the page was live, so every later update was dropped and the preview
stayed blank until the view was recreated (#8). -
@font-facedescriptors can no longer inject CSS. The rule is assembled as
text, so afont-weightorfont-stylecarrying;or}could close it and
append rules of its own. Restricted in #8 and made unrepresentable by the
typed descriptors in #10. Family names were already safe: the escaped value
parses as a single font name (#8, #10). -
Calls issued before the page is ready are no longer silently discarded from
paths that could reach them: the padding helpers are private, since they are
only ever driven at the right time (#8). -
Name the renderer correctly. The preview has always been rendered by
@wcj/markdown-to-html, built on unified/remark/rehype, not by
marked;marked.cssis github-markdown-css
under a misleading name. The README and three example pages said otherwise
(#13, #12).
Removed
doc/custom-font-development-plan.md, a progress table with every row marked
done (#9).
Internal
- Test coverage went from 8 to 23 cases.
javascriptStringLiteral— the only
thing between a Markdown style and arbitrary JavaScript, since the CSS it
escapes is interpolated into an evaluated script — had none; its new cases were
checked against a deliberately broken version of it. Reverting to the default
style, the replay of updates queued before the page is ready, and the numeric
bounds of the font descriptors are covered too (#9, #10). - The encoded-font cache can be reset, so a test asserting on encoding no longer
reads an entry left by an earlier run (#9). /build/is anchored in.gitignore; the unanchored pattern ignored any file
or directory with that name at any depth (#9).
Full diff: v1.1.0...v2.0.0
Documentation: https://raw.githack.com/gewill/swiftui-markdown/gh-pages/index.html