Releases: gonzalezreal/swift-markdown-ui
MarkdownUI 2.4.1
What's Changed
- Replace embedded
cmark-gfm
with swiftlang/swift-cmark by @gonzalezreal in #348
Full Changelog: 2.4.0...2.4.1
MarkdownUI 2.4.0
MarkdownUI 2.3.1
What's Changed
- Fix bullets in visionOS by @tapsandswipes in #308
- Add title bar for code blocks in the Demo app CodeSyntaxHighlightView by @moophis in #249
- Fix circular reference error by @tonyfreeman in #328
- Fix format workflow by @gonzalezreal in #329
- Fix custom font dynamic size by @gonzalezreal in #330
New Contributors
- @tapsandswipes made their first contribution in #308
- @moophis made their first contribution in #249
- @tonyfreeman made their first contribution in #328
Full Changelog: 2.3.0...2.3.1
MarkdownUI 2.3.0
What's Changed
- Added: Mac Catalyst support (#287)
- Added:
FontWidth
, a text style that adjusts the font width (thanks @kirkbig #266) - Changed: Use
#if canImport(...)
instead of#if os(...)
(thanks @MojtabaHs #268) - Fixed: Mac Catalyst build failures (thanks @kirkbig #283)
- Changed: Use
assertSnapshot(of:...)
instead of the deprecatedassertSnapshot(matching:...)
(thanks @kirkbig #284)
Full Changelog: 2.2.0...2.3.0
MarkdownUI 2.2.0
What's Changed
- Fixed: Apply the current text style foreground color to code blocks (#228)
- Fixed: Unexpected code block truncation (#256)
- Added: Support for visionOS (thanks @Rminsh, #252)
- Infra: Adopt gonzalezreal/NetworkImage as the default image provider (#258)
- Added:
MarkdownContent
HTML rendering (thanks @srna, #253) - Infra: Enable text selection in Demo (#259)
New Contributors
Full Changelog: 2.1.0...2.2.0
MarkdownUI 2.1.0
What's Changed
- Infrastructure: Refactor Markdown parsing (#210)
- Infrastructure: Bump CI workflow's Xcode to 14.2 (#212)
- Fixed: Deprecation message (#214)
- Added: Provide access to the language and the content of a code block from the body of the
codeBlock
style (#215) - Added: Provide access to the block's Markdown content from the body of most of the block styles (#220)
- Added: Render HTML line breaks
<br>
(#221) - Changed: Move the
fixedSize
modifier from the paragraph view to the block style in all the bundled themes (#222)
Full Changelog: 2.0.2...2.1.0
MarkdownUI 2.0.2
What's Changed
- Render first level inline images by @gonzalezreal in #193
- Remove
Markdown
view@State
property by @gonzalezreal in #197 - Add
ImageRenderer
demo by @gonzalezreal in #198
Full Changelog: 2.0.1...2.0.2
MarkdownUI 2.0.1
What's Changed
- Fix the image cache in the default image provider by @gonzalezreal in #187
Full Changelog: 2.0.0...2.0.1
MarkdownUI 2.0.0
Overview
MarkdownUI 2 has been rewritten from scratch and brings a ton of new features and improvements
like:
- GitHub Flavored Markdown (tables, task lists, strikethrough text, and autolinks)
- Native SwiftUI rendering
- Customization support via themes, text styles, and block styles.
These new features come with the cost of a few breaking changes that these notes will help you to
address.
Minimum requirements
You can use MarkdownUI 2 on the following platforms:
- macOS 12.0+
- iOS 15.0+
- tvOS 15.0+
- watchOS 8.0+
Some features, like displaying tables or multi-image paragraphs, require macOS 13.0+, iOS 16.0+,
tvOS 16.0+, and watchOS 9.0+.
Updated package name
To reflect the Swift community naming conventions, the package has been renamed from MarkdownUI
to swift-markdown-ui
. So, you may eventually need to update any Xcode projects or Package.swift
files that depend on MarkdownUI.
Rendering
MarkdownUI 2 uses SwiftUI primitives to render Markdown and no longer depends on gonzalezreal/AttributedText.
Creating Markdown content
MarkdownUI 2 introduces a new domain-specific language to create Markdown content and no longer
depends on gonzalezreal/SwiftCommonMark.
One significant difference when using MarkdownUI 2 is that MarkdownContent
replaces Document
by providing similar functionality.
Another thing to be aware of is the different naming of some of the types you use to compose
Markdown content:
- Use
Blockquote
instead ofBlockQuote
. - Use
NumberedList
instead ofOrderedList
. - Use
BulletedList
instead ofBulletList
. - Use
InlineImage
instead ofImage
. - Use
InlineLink
instead ofLink
. - Use
Code
instead ofInlineCode
.
Loading asset images
MarkdownUI 2 introduces the ImageProvider
protocol and its conforming types
DefaultImageProvider
and AssetImageProvider
. These types and the new
markdownImageProvider(_:)
modifier replace the MarkdownImageHandler
type and
the setImageHandler(_:forURLScheme:)
modifier.
The following example shows how to configure the asset image provider to load images from the
main bundle.
Markdown {
"![A dog](dog)"
"― Photo by André Spieker"
}
.markdownImageProvider(.asset)
Customizing link behavior
The onOpenMarkdownLink(perform:)
modifier in MarkdownUI 1.x was provided to enable link behavior
customization in macOS 11.0, iOS 14.0, and tvOS 14.0. This modifier is no longer available in
MarkdownUI 2 since it does not support those platforms. However, you can customize the link
behavior by setting the openURL
environment value with a custom OpenURLAction
.
Styling Markdown
MarkdownUI 1.x offered a few options to customize the content appearance. In contrast, MarkdownUI 2
brings the new Theme
, TextStyle
, and BlockStyle
types that let you apply a custom
appearance to blocks and text inlines in a Markdown view.
Consequently, the MarkdownStyle
type, all of its subtypes, and the markdownStyle(_:)
modifier
are no longer available in MarkdownUI 2.
MarkdownUI 1.1.1
What's Changed
- Update GitHub actions by @gonzalezreal in #110
- Fix custom font resolution by @gonzalezreal in #111
- Fix crash when rendering a code block without a closing fence by @gonzalezreal in #112
- Fix hang when trying to load invalid image by @gonzalezreal in #113
- Fix rendering thematic break with centered or right aligned text by @gonzalezreal in #114
Full Changelog: 1.1.0...1.1.1