1. Products
  2.   Word Processing
  3.   Swift
  4.   Swift Markdown
 
  

Free Swift Library to Read & Parse Markdown Documents

Open Source Swift Package enables iOS and macOS Developers to Parse, Build, Modify, Analyze, Read, & Render Markdown Documents in Swift applications.

What is Swift Markdown?

In the modern era, having clear and organized documentation is vital for any software project. Markdown is a favored simple markup language that streamlines the creation of formatted text, helping developers convey their thoughts clearly. Swift, a robust programming language from Apple, has become widely liked by developers working on iOS, macOS, and Linux apps. Combining the strengths of both Markdown and Swift, open source Swift Markdown libraries provide a convenient and efficient way to generate richly formatted documentation.

Swift Markdown stands out as an excellent Swift package designed to help you, software developers, craft robust applications for managing Markdown documents. This community-driven project equips developers with a comprehensive toolkit to work with Markdown text efficiently, making it easier to integrate Markdown features into your iOS and macOS apps.

The Swift Markdown library gives software developers the freedom to adjust how their app looks. You can change things like fonts, colors, and alignment to match your app’s style. This helps the output blend well with your overall design. Plus, it includes features for accessibility, like VoiceOver, which makes it easy for visually impaired users to use Markdown content without any trouble. Its comprehensive feature set, customization options, accessibility support, and ease of use make it a compelling choice for simplifying document formatting and enhancing the user experience.

Previous Next

Getting Started with Swift Markdown

The recommended way Swift Markdown into your project is by using GitHub. Please use the following command for a smooth installation.

Install Swift Markdown via GitHub

$ go get https://github.com/apple/swift-markdown.git  

In your Package.swift Swift Package Manager manifest, add the following dependency to your dependencies argument

Add the following Dependency to the Dependencies Argument

 .package(url: "https://github.com/apple/swift-markdown.git", .branch("main")),

// Add the dependency to any targets you've declared in your manifest:

.target(name: "MyTarget", dependencies: ["Markdown"]),
 

Parse Markdown Documents via Swift API

The open source Swift Markdown library gives software developers the capability to open and parse Markdown documents inside Swift applications. The library offers comprehensive support for parsing and rendering Markdown syntax. It handles various elements such as headings, paragraphs, lists, links, images, and code blocks, allowing computer programmers to effortlessly convert Markdown text into formatted HTML or attributed strings. Create an instance of the Markdown parser, feed it the Markdown input, and obtain the rendered output as an attributed string or HTML. The following example shows how users can provide a text string or file via URL and convert it to a documents using Swift code.

How to Parse Markdown Documents using Swift API?

import Markdown

let source = "This is a markup *document*."
let document = Document(parsing: source)
print(document.debugDescription())

# Or build trees of your choice

let document = Document(
    Paragraph(
        Text("This is a "),
        Emphasis(
            Text("paragraph."))))

Convert Markdown Text into HTML via Swift

Swift Markdown libraries seamlessly integrate into your existing Swift projects, enabling you to generate formatted documentation without any hassle. By using the library's simple API, you can effortlessly convert Markdown text into various formats, such as HTML, PDF, or even plain text.

 English