swift-markdown-ui

Display and customize Markdown text in SwiftUI

MIT License

Stars
2.1K
Committers
9

Bot releases are hidden (Show)

swift-markdown-ui - MarkdownUI 2.3.0 Latest Release

Published by gonzalezreal 10 months ago

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 deprecated assertSnapshot(matching:...) (thanks @kirkbig #284)

Full Changelog: https://github.com/gonzalezreal/swift-markdown-ui/compare/2.2.0...2.3.0

swift-markdown-ui - MarkdownUI 2.2.0

Published by gonzalezreal about 1 year ago

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: https://github.com/gonzalezreal/swift-markdown-ui/compare/2.1.0...2.2.0

swift-markdown-ui - MarkdownUI 2.1.0

Published by gonzalezreal over 1 year ago

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: https://github.com/gonzalezreal/swift-markdown-ui/compare/2.0.2...2.1.0

swift-markdown-ui - MarkdownUI 2.0.2

Published by gonzalezreal over 1 year ago

What's Changed

Full Changelog: https://github.com/gonzalezreal/swift-markdown-ui/compare/2.0.1...2.0.2

swift-markdown-ui - MarkdownUI 2.0.1

Published by gonzalezreal over 1 year ago

What's Changed

Full Changelog: https://github.com/gonzalezreal/swift-markdown-ui/compare/2.0.0...2.0.1

swift-markdown-ui - MarkdownUI 2.0.0

Published by gonzalezreal over 1 year ago

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 of BlockQuote.
  • Use NumberedList instead of OrderedList.
  • Use BulletedList instead of BulletList.
  • Use InlineImage instead of Image.
  • Use InlineLink instead of Link.
  • Use Code instead of InlineCode.

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.

swift-markdown-ui - MarkdownUI 1.1.1

Published by gonzalezreal about 2 years ago

What's Changed

Full Changelog: https://github.com/gonzalezreal/MarkdownUI/compare/1.1.0...1.1.1

swift-markdown-ui - MarkdownUI 1.1.0

Published by gonzalezreal over 2 years ago

What's Changed

Full Changelog: https://github.com/gonzalezreal/MarkdownUI/compare/1.0.0...1.1.0

swift-markdown-ui - 1.0.0

Published by gonzalezreal almost 3 years ago

What's Changed

  • Breaking change: New stable API and simplified customization appearance
  • Changed: New rendering implementation.
  • Added: Enable loading images from bundles
  • Added: Render thematic breaks
  • Added: Enable custom markdown link handling
  • Added: Make text not selectable on iOS
  • Changed: Improved list rendering.
  • Removed: NSAttributedString based HTML block rendering
  • Infrastructure: Remove watchOS scheme, remove unnecessary availability attributes and replace SwiftFormat with swift-format.
  • Infrastructure: Use Xcode 13.2 for CI
  • Infrastructure: New demo app with tvOS and Catalyst targets
  • Infrastructure: Improved README and documentation
  • Bug fixed: View update issues on iOS 15
swift-markdown-ui - MarkdownUI 0.5.2

Published by gonzalezreal about 3 years ago

  • Set platform requirements
  • Add snapshot test for markdown images
  • Fix an issue with image loading
swift-markdown-ui - MarkdownUI 0.5.1

Published by gonzalezreal over 3 years ago

  • Fix #39
swift-markdown-ui - MarkdownUI 0.5.0

Published by gonzalezreal over 3 years ago

Breaking change

MarkdownStyle is now a protocol with a default implementation DefaultMarkdownStyle. This new protocol has methods to customise the attributes of each of the different blocks and inlines in a markdown file.

To customise the font, foreground color, code font or heading font sizes you can use the markdownStyle(_:) view modifier:

Markdown(
    #"""
    ## Inline code
    If you have inline code blocks, wrap them in backticks: `var example = true`.
    """#
)
.markdownStyle(
    DefaultMarkdownStyle(
        font: .system(.body, design: .serif),
        codeFontName: "Menlo",
        codeFontSizeMultiple: 0.88
    )
)
swift-markdown-ui - MarkdownUI 0.4.0

Published by gonzalezreal over 3 years ago

  • CommonMark parsing moved to gonzalezreal/SwiftCommonMark

  • SwiftCommonMark adds an embedded DSL to create CommonMark documents. This allows a new syntax when constructing Markdown views:

    Markdown {
        Heading(level: 2) {
            "Result builders are cool!"
        }
        "Sometimes you want bullet points:"
        List {
            "Start a line with a star"
            "Profit!"
        }
        "Sometimes you want numbered lists:"
        List(start: 1) {
            "One"
            "Two"
            "Three"
        }
    }
    
swift-markdown-ui - MarkdownUI 0.3.4

Published by gonzalezreal over 3 years ago

  • Update AttributedText dependency
swift-markdown-ui - MarkdownUI 0.3.3

Published by gonzalezreal almost 4 years ago

  • Add support for macCatalyst
  • Update view when document changes
swift-markdown-ui - MarkdownUI 0.3.2

Published by gonzalezreal almost 4 years ago

  • Update NetworkImage dependency to 2.1.0
swift-markdown-ui - MarkdownUI 0.3.1

Published by gonzalezreal almost 4 years ago

  • Update NetworkImage dependency to 2.0.0
swift-markdown-ui - MarkdownUI 0.3.0

Published by gonzalezreal almost 4 years ago

  • Scale images to fit the Markdown view
  • Fix build for Mac Catalyst environment
  • Update AttributedText dependency to 0.2.1. This fixes the layout issues in macOS.
  • Add support for relative URLs in markdown images, using the markdownBaseURL view modifier.
  • Add initializers to create a Document with the content of the file at a given path.
swift-markdown-ui - MarkdownUI 0.2.0

Published by gonzalezreal almost 4 years ago

  • Use AttributedText 0.2.0, which improves how the view height adapt to its contents
  • Add Markdown snapshot tests, replacing the renderer tests (and thus fixing #20)
swift-markdown-ui - MarkdownUI 0.1.1

Published by gonzalezreal almost 4 years ago

  • Use a version-based requirement for cmark dependency to fix package resolution
  • Use AttributedText 0.1.6
Package Rankings
Top 5.66% on Swiftpackageindex.com
Badges
Extracted from project README
CI