Render Markdown text in SwiftUI

Overview

Markdown

CI SwiftUI Support

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

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...
A beautiful and flexible text field control implementation of
A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift.

SkyFloatingLabelTextField SkyFloatingLabelTextField is a beautiful, flexible and customizable implementation of the space saving "Float Label Pattern"

Handles some of the base configuration to make creating a UIAlertController with text entry even easier. Plus validation!
Handles some of the base configuration to make creating a UIAlertController with text entry even easier. Plus validation!

🍅 FancyTextEntryController A simpler/easier API for adding text fields to UIAlertControllers. Not a custom view, just uses good ol' UIAlertController

Changes the color of the label text when the button is pressed and also prints hello to the console
Changes the color of the label text when the button is pressed and also prints hello to the console

MY FIRST APP App Description This app changes the color of the label text when the button is pressed and also prints "hello" to the console. App Walk-

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time
ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time. This is perfect for automatically suggesting the domain as a user types an email address, #hashtag or @alexruperez.

UITextField and UITextView subclasses with placeholders that change into floating labels when the fields are populated with text.
UITextField and UITextView subclasses with placeholders that change into floating labels when the fields are populated with text.

Deprecated Please use JVFloatLabeledTextField instead or feel free to chime in on an issue if you'd like to take over the repo. RPFloatingPlaceholders

UITextField that automatically formats text to display in the currency format
UITextField that automatically formats text to display in the currency format

CurrencyTextField The numbers that the user enters in the field are automatically formatted to display in the dollar amount format. For example, if th

A text view that supports selection and expansion
A text view that supports selection and expansion

The Problem UILabel and UITextView offer unsatisfying support for text selection. Existing solutions like TTTAttributedLabel are great but offer a som

Declarative text styles and streamlined Dynamic Type support for iOS
Declarative text styles and streamlined Dynamic Type support for iOS

StyledText StyledText is a library that simplifies styling dynamic text in iOS applications. Instead of having to use attributed strings every time yo

Lightweight set of text fields with nice animation and functionality
Lightweight set of text fields with nice animation and functionality

TweeTextField This is lightweight library that provides different types of Text Fields based on your needs. I was inspired by Jan Henneberg. Features

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
小弟调调™
(͡·̮̃·̃) 如今撸码,像是早上起来需要刷牙一样的习惯。
小弟调调™
A SwiftUI view for displaying Markdown with customizable appearances.

Parma Display Markdown using pure SwiftUI components. Taking advantages of ViewBuilder to make custom appearances for Text and View. Example import Pa

DasAuto 735 Jan 3, 2023
SwiftUI TextEdit View - A proof-of-concept text edit component in SwiftUI & CoreText.

A proof-of-concept text edit component in SwiftUI & CoreText. No UIKit, No AppKit, no UITextView/NSTextView/UITextField involved.

Marcin Krzyzanowski 80 Dec 1, 2022
A SwiftUI TextField with a prompt (or placeholder) that floats above the text field when active or not empty. Requires iOS 15.

FloatingPromptTextField A prompt is the label in a text field that informs the user about the kind of content the text field expects. In a default Tex

Emilio Peláez 43 Nov 3, 2022
Focus text field in SwiftUI dynamically and progress through form using iOS keyboard.

Focuser Focuser allows to focus SwiftUI text fields dynamically and implements ability move go through the form using Keyboard for iOS 13 and iOS 14.

Art Technologies 118 Dec 25, 2022
Autocomplete for a text field in SwiftUI using async/await

Autocomplete for a text field in SwiftUI using async/await

Dmytro Anokhin 13 Oct 21, 2022
Currency text field formatter available for UIKit and SwiftUI 💶✏️

CurrencyText provides lightweight libraries for formating text field text as currency, available for both UIKit and SwiftUI. Its main core, the Curren

Felipe Lefèvre Marino 183 Dec 15, 2022
ExpandableText 😎 (SwiftUI) Expand the text with the "more" button

ExpandableText ?? (SwiftUI) Expand the text with the "more" button Get Started import SwiftUI import ExpandableText struct ExpandableText_Test: View

null 35 Dec 26, 2022
Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen in Apple's TV & TestFlight iOS apps.

SwiftUI Matched Inline Title Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen i

Seb Jachec 19 Oct 9, 2022
RichTextKit is a Swift-based library for working with rich text in UIKit, AppKit and SwiftUI.

About RichTextKit RichTextKit is a Swift-based library that lets you work with rich text in UIKit, AppKit and SwiftUI. RichTextKit is under developmen

Daniel Saidi 282 Dec 28, 2022
AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.

AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.

Abdelrhman Kamal 79 Jan 3, 2023