GitPedia

MarkdownSyntax

☄️ A Type-safe Markdown parser in Swift.

From hebertialmeida·Updated March 17, 2026·View on GitHub·

MarkdownSyntax is a wrapper on top of the GitHub Flavoured Markdown that conforms to [mdast](https://github.com/syntax-tree/mdast). It parses markdown and creates a normalized AST so you can use it not only for rendering markdown and syntax highlighting. In addition, you can render to standard markdown formats: HTML, XML, Man, LaTeX, Plain Text. The project is written primarily in Swift, distributed under the MIT License license, first published in 2019. Key topics include: ast, cmark, markdown, markdown-parsing, mdast.

Latest release: 1.3.0
October 30, 2025View Changelog →

☄️ MarkdownSyntax


codecov

MarkdownSyntax is a wrapper on top of the GitHub Flavoured Markdown that conforms to mdast. It parses markdown and creates a normalized AST so you can use it not only for rendering markdown and syntax highlighting. In addition, you can render to standard markdown formats: HTML, XML, Man, LaTeX, Plain Text.

If you want to see a real-world usage of MarkdownSyntax, check out https://pinery.app where this framework was designed for.

Usage

swift
let input = "Hi this is **alpha**" let tree = try await Markdown(text: input).parse()

Outputs a normalized tree:

swift
Root( children: [ Paragraph( children: [ Text( value: "Hi this is ", position: Position( start: Point(line: 1, column: 1, offset: 0), end: Point(line: 1, column: 11, offset: 10), indent: nil ) ), Strong( children: [ Text( value: "alpha", position: Position( start: Point(line: 1, column: 14, offset: 13), end: Point(line: 1, column: 18, offset: 17), indent: nil ) ) ], position: Position( start: Point(line: 1, column: 12, offset: 11), end: Point(line: 1, column: 20, offset: 19), indent: nil ) ) ], position: Position( start: Point(line: 1, column: 1, offset: 0), end: Point(line: 1, column: 20, offset: 19), indent: nil ) ) ], position: Position( start: Point(line: 1, column: 1, offset: 0), end: Point(line: 1, column: 20, offset: 19), indent: nil ) )

For more examples checkout the tests MarkdownSyntaxTests.

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding MarkdownSyntax as a dependency is as easy as adding it to the dependencies value of your Package.swift.

swift
dependencies: [ .package(url: "https://github.com/hebertialmeida/MarkdownSyntax", from: "1.3.0") ]

Acknowledgements

Contributors

Showing top 3 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from hebertialmeida/MarkdownSyntax via the GitHub API.Last fetched: 6/23/2026