Swiftpack.co - loopwerk/Parsley as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by loopwerk.
loopwerk/Parsley 0.9.0
A Markdown parser for Swift, using Github Flavored Markdown and Metadata
⭐️ 18
🕓 2 years ago
iOS macOS
.package(url: "https://github.com/loopwerk/Parsley.git", from: "0.9.0")

tag-changelog

A Markdown parser for Swift Package Manager, using Github Flavored Markdown. As such it comes with a bunch of Markdown extensions such as fenced code blocks, tables, strikethrough, hard line breaks and auto links.

Additionally Parsley supports embedded metadata in Markdown documents, and it splits the document title out from the document body.

let input = """
---
author: Kevin
tags: Swift, Parsley
---

# Hello World
This is the body
"""

let document = try Parsley.parse(input)
print(document.title) // Hello World
print(document.body) // <p>This is the body</p>
print(document.metadata) // ["author": "Kevin", "tags": "Swift, Parsley"]

Install

Parsley is available via Swift Package Manager and runs on macOS and Linux.

.package(url: "https://github.com/loopwerk/Parsley", from: "0.5.0"),

Use as a reader in Saga

Parsley can be used as a reader in the static site generator Saga, using SagaParsleyMarkdownReader.

Modifying the generated HTML

Parsley doesn't come with a plugin system, it relies purely on cmark-gfm under the hood to render Markdown to HTML. If you want to modify the generated HTML, for example if you want to add target="blank" to all external links, SwiftSoup is a great way to achieve this.

Adding a plugin system on top of cmark would mean that Parsley could no longer rely on the outstanding output of cmark; instead Parsley would have to parse its AST and generate HTML based on that itself, thus reinventing the (very complex) wheel.

GitHub

link
Stars: 18
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics