Render Markdown text in SwiftUI, preview based on the Marked implementation

Overview

Markdown

CI SwiftUI Support

Render Markdown text in SwiftUI. It is a preview based on the Marked implementation.

swiftui-markdown.mov

Markdown Package Screenshot

Markdown Package Screenshot

Markdown Package Screenshot

Installation

You can add MarkdownUI to an Xcode project by adding it as a package dependency.

  1. From the File menu, select Add Packages…
  2. Enter https://github.com/jaywcjlove/markdown the Search or Enter Package URL search field
  3. Link Markdown to your application target

Or add the following to Package.swift:

.package(url: "https://github.com/jaywcjlove/markdown", from: "1.0.0")

Or add the package in Xcode.

Usage

import SwiftUI
import Markdown

struct ContentView: View {
  @State private var mdStr: String = """
    ## Hello World
    
    Render Markdown text in SwiftUI.
    """
  var body: some View {
    VStack {
      Markdown(content: $mdStr)
      TextEditor(text: $mdStr)
    }
  }
}

.markdownStyle()

Setting markdown related styles.

Markdown(content: $mdStr)
  .markdownStyle(
      MarkdownStyle(
        padding: 0, paddingTop: 115, paddingBottom: 2, paddingLeft: 130, paddingRight: 5
      )
  )
Markdown(content: $mdStr)
  .markdownStyle(MarkdownStyle(padding: 35 ))

Configure

image

License

Licensed under the MIT License.

You might also like...
Notepad - A fully themeable iOS markdown editor with live syntax highlighting.
Notepad - A fully themeable iOS markdown editor with live syntax highlighting.

Notepad is just like any other UITextView, but you need to use the convenience initializer in order to use the themes. To create a new theme, copy one of the existing themes and edit the JSON.

Markdown parser for iOS

Marky Mark Marky Mark is a parser written in Swift that converts markdown into native views. The way it looks it highly customizable and the supported

Swift markdown library
Swift markdown library

Markdown ![Swift version](https://img.shields.io/badge/Swift-2.1 | 2.2-blue.svg) ![GitHub license](https://img.shields.io/badge/license-LGPL v3-green.

`resultBuilder` support for `swift-markdown`

SwiftMarkdownBuilder resultBuilder support for swift-markdown. The default way to build Markdown in swift-markdown is to use varargs initializers, e.g

AttributedString Markdown initializer with custom styling
AttributedString Markdown initializer with custom styling

AttributedString Markdown initializer with custom styling AttributedString in iOS 15 and macOS 12 comes with a Markdown initializer. But: There is no

An Objective-C framework for converting Markdown to HTML.

MMMarkdown MMMarkdown is an Objective-C framework for converting Markdown to HTML. It is compatible with OS X 10.7+, iOS 8.0+, tvOS, and watchOS. Unli

Markdown syntax highlighter for iOS
Markdown syntax highlighter for iOS

Marklight Markdown syntax highlighter for iOS and macOS. Description Marklight is a drop in component to easily add realtime Markdown syntax highlight

Rich Markdown editing control for iOS
Rich Markdown editing control for iOS

MarkdownTextView Rich Markdown Editing for iOS MarkdownTextView is an iOS framework for adding rich Markdown editing capabilities. Support for Markdow

Converts Markdown files and strings into NSAttributedStrings with lots of customisation options.
Converts Markdown files and strings into NSAttributedStrings with lots of customisation options.

SwiftyMarkdown 1.0 SwiftyMarkdown converts Markdown files and strings into NSAttributedStrings using sensible defaults and a Swift-style syntax. It us

Comments
  • Configure Renovate

    Configure Renovate

    WhiteSource Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • .github/workflows/ci.yml (github-actions)
    • .github/workflows/tag.yml (github-actions)

    Configuration Summary

    Based on the default config's presets, Renovate will:

    • Start dependency updates only once this onboarding PR is merged
    • Enable Renovate Dependency Dashboard creation
    • If semantic commits detected, use semantic commit type fix for dependencies and chore for all others
    • Ignore node_modules, bower_components, vendor and various test/tests directories
    • Autodetect whether to pin dependencies or maintain ranges
    • Rate limit PR creation to a maximum of two per hour
    • Limit to maximum 10 open PRs at any time
    • Group known monorepo packages together
    • Use curated list of recommended non-monorepo package groupings
    • Fix some problems with very old Maven commons versions
    • Ignore spring cloud 1.x releases
    • Ignore web3j 5.0.0 release
    • Ignore http4s digest-based 1.x milestones
    • Use node versioning for @types/node
    • Limit concurrent requests to reduce load on Repology servers until we can fix this properly, see issue 10133
    • Do not upgrade from Alpine stable to edge

    🔡 Would you like to change the way Renovate is upgrading your dependencies? Simply edit the renovate.json in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.


    What to Expect

    With your current configuration, Renovate will create 1 Pull Request:

    chore(deps): update actions/checkout action to v3
    • Schedule: ["at any time"]
    • Branch name: renovate/actions-checkout-3.x
    • Merge into: main
    • Upgrade actions/checkout to v3

    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 0
  • How to use it offline?

    How to use it offline?

    It works fine when there is a network connection, but it doesn't display correctly when there is no network connection at all. Another is that text other than code blocks cannot be selected?

    Hope you can help me, thanks.

    opened by Charliego93 0
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    Other Branches

    These updates are pending. To force PRs open, click the checkbox below.

    • [ ] chore(deps): update jaywcjlove/changelog-generator action to v1.6.2
    • [ ] chore(deps): update actions/checkout action to v3

    Detected dependencies

    github-actions
    .github/workflows/ci.yml
    • actions/checkout v2
    • jaywcjlove/changelog-generator v1.5.0
    • peaceiris/actions-gh-pages v3
    .github/workflows/tag.yml
    • actions/checkout v2
    • jaywcjlove/changelog-generator v1.5.0
    • peaceiris/actions-gh-pages v3
    • jaywcjlove/changelog-generator v1.5.0
    • ncipollo/release-action v1

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
Releases(v1.0.8)
  • v1.0.8(May 13, 2022)

    Documentation v1.0.8: https://raw.githack.com/jaywcjlove/markdown/47e4993/index.html Comparing Changes: https://github.com/jaywcjlove/swiftui-markdown/compare/v1.0.7...v1.0.8

    • 📖 doc: Update README.md 98c59dd @jaywcjlove
    • 💄 chore(deps): add renovate.json (#1) 65ec741 @renovate-bot
    • 🐞 fix: Fix openURL only works on iOS 14.0 or later (#4). 6d8b7eb @jaywcjlove
    Source code(tar.gz)
    Source code(zip)
  • v1.0.7(Mar 16, 2022)

    Documentation v1.0.7: https://raw.githack.com/jaywcjlove/markdown/79827f4/index.html Comparing Changes: https://github.com/jaywcjlove/markdown/compare/v1.0.6...v1.0.7

    • 💄 chore: Removed DEVELOPMENT_TEAM configuration. 1c07701 @jaywcjlove
    • 💄 chore: add .gitattributes file. 6287058 @jaywcjlove
    • 💄 chore: update .gitattributes 87a8a0c @jaywcjlove
    • 🎨 style: Modify view style. 916a870 @jaywcjlove
    • 💄 chore: Update example project.pbxproj a9b2d31 @jaywcjlove
    Source code(tar.gz)
    Source code(zip)
  • v1.0.6(Mar 13, 2022)

    Documentation v1.0.6: https://raw.githack.com/jaywcjlove/markdown/79827f4/index.html Comparing Changes: https://github.com/jaywcjlove/markdown/compare/v1.0.5...v1.0.6

    • 📖 doc: Update README.md 3935a6c @jaywcjlove
    • 📖 doc: Update README.md afec849 @jaywcjlove
    • 🌟 feat: Support KaTeX. 9911664 @jaywcjlove
    • 💊 clean: clean console log. 1afea16 @jaywcjlove
    • 📖 doc: Update README.md 2ab7fdf @jaywcjlove
    • 🎨 style: Modify task checkbox style. 443984c @jaywcjlove
    Source code(tar.gz)
    Source code(zip)
  • v1.0.5(Mar 12, 2022)

    Documentation v1.0.5: https://raw.githack.com/jaywcjlove/markdown/bc317bc/index.html Comparing Changes: https://github.com/jaywcjlove/markdown/compare/v1.0.4...v1.0.5

    • 📖 doc: Update README.md 5c91ab3 @jaywcjlove
    • 📖 doc: Update README.md 5443f04 @jaywcjlove
    • 🐞 fix: Fix diff code errors. 295e3e6 @jaywcjlove
    • 🌟 feat: add code block lnline-color feature. 9094c4e @jaywcjlove
    • 💄 chore: update example. 4fb0e66 @jaywcjlove
    Source code(tar.gz)
    Source code(zip)
  • v1.0.4(Mar 12, 2022)

    Documentation v1.0.4: https://raw.githack.com/jaywcjlove/markdown/53197a7/index.html Comparing Changes: https://github.com/jaywcjlove/markdown/compare/v1.0.3...v1.0.4

    • 🐞 fix: Fix markdown list style. 107d057 @jaywcjlove
    • 🐞 fix: Fix open links in browsers. d74ddfd @jaywcjlove
    • 💄 chore: Update web.bundle 6a7b8e7 @jaywcjlove
    • 🐞 fix: disable right-click menu. 90ba7d7 @jaywcjlove
    • 🌟 feat: add copy code button. e277a99 @jaywcjlove
    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Mar 11, 2022)

    Documentation v1.0.3: https://raw.githack.com/jaywcjlove/markdown/53197a7/index.html Comparing Changes: https://github.com/jaywcjlove/markdown/compare/v1.0.2...v1.0.3

    • 💄 chore: update workflows config. 98805b2 @jaywcjlove
    • 📖 doc: Update README.md 9ff02de @jaywcjlove
    • 🌟 feat: Add syntax highlighting. 0449e94 @jaywcjlove
    Source code(tar.gz)
    Source code(zip)
  • v1.0.2(Mar 11, 2022)

    Documentation v1.0.2: https://raw.githack.com/jaywcjlove/markdown/b787c19/index.html Comparing Changes: https://github.com/jaywcjlove/markdown/compare/v1.0.1...v1.0.2

    • 📖 doc: Update README.md 72dd4cd @jaywcjlove
    • 💄 chore: update example. c3184fa @jaywcjlove
    • 🌟 feat: add .markdownStyle() options. a7c3c9c @jaywcjlove

    .markdownStyle()

    Setting markdown related styles.

    Markdown(content: $mdStr)
      .markdownStyle(
          MarkdownStyle(
            padding: 0, paddingTop: 115, paddingBottom: 2, paddingLeft: 130, paddingRight: 5
          )
      )
    
    Markdown(content: $mdStr)
      .markdownStyle(MarkdownStyle(padding: 35 ))
    
    Source code(tar.gz)
    Source code(zip)
  • v1.0.1(Mar 10, 2022)

    Documentation v1.0.1: https://raw.githack.com/jaywcjlove/markdown/79a96d6/index.html Comparing Changes: https://github.com/jaywcjlove/markdown/compare/v1.0.0...v1.0.1

    • 💄 chore: update workflows config. 0edd166 @jaywcjlove
    • 📖 doc: Update README.md c76ce72 @jaywcjlove
    • 💄 chore: update workflows config. bc916bf @jaywcjlove
    • 🌟 feat: Add light & dark theme. 54ace48 @jaywcjlove
    • 💄 chore: update workflows config. b6e7738 @jaywcjlove
    • 🎨 style: update markdown style. a9aa348 @jaywcjlove
    Source code(tar.gz)
    Source code(zip)
Owner
小弟调调™
(͡·̮̃·̃) 如今撸码,像是早上起来需要刷牙一样的习惯。
小弟调调™
Rendering Markdown text natively in SwiftUI.

MarkdownView MarkdownView is a Swift Package for rendering Markdown text natively in SwiftUI. Thanks to apple/swift-markdown, it can fully compliant w

LiYanan2004 13 Oct 22, 2022
A Pure Swift implementation of the markdown mark-up language

SmarkDown A pure Swift markdown implementation consistent with Gruber's 1.0.1 version. It is released under the BSD license so please feel free to use

Swift Studies 67 Jan 24, 2022
MarkdownView is a WKWebView based UI element, and internally use bootstrap, highlight.js, markdown-it.

MarkdownView is a WKWebView based UI element, and internally use bootstrap, highlight.js, markdown-it.

Keita Oouchi 1.8k Dec 21, 2022
Leverages Apple's Swift-based Markdown parser to output NSAttributedString.

Markdownosaur ?? Markdownosaur uses Apple's excellent and relatively new Swift Markdown library to analyze a Markdown source, and then takes that anal

Christian Selig 232 Dec 20, 2022
Markdown in SwiftUI, and some other interesting components.

RoomTime RoomTime is a bundle of tools developed in my app RoomTime Lite. ( ?? RoomTime Lite is still in development) Features TextArea AutoWrap Markd

Chen SiWei 56 Dec 20, 2022
An iOS app to turn typed text into images of handwritten text in your own handwriting style.

Text-to-Handwritting © 2021 by Daniel Christopher Long An iOS app to turn typed text into images of handwritten text in your own handwriting style. ht

Daniel Long 11 Dec 29, 2022
Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform.

twitter-text This repository is a collection of libraries and conformance tests to standardize parsing of Tweet text. It synchronizes development, tes

Twitter 2.9k Dec 27, 2022
Powerful text framework for iOS to display and edit rich text.

YYText Powerful text framework for iOS to display and edit rich text. (It's a component of YYKit) Features UILabel and UITextView API compatible High

null 8.8k Jan 4, 2023
A simple and customizable Markdown Parser for Swift

MarkdownKit MarkdownKit is a customizable and extensible Markdown parser for iOS and macOS. It supports many of the standard Markdown elements through

Bruno Oliveira 687 Dec 18, 2022
Marky Mark is a parser written in Swift that converts markdown into native views.

Marky Mark is a parser written in Swift that converts markdown into native views. The way it looks it highly customizable and the supported markdown syntax is easy to extend.

M2mobi 287 Nov 29, 2022