Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/loopwerk/Parsley
A Markdown parser for Swift, using Github Flavored Markdown and Metadata
https://github.com/loopwerk/Parsley
github-flavored-markdown markdown markdown-parser markdown-to-html swift swift-package-manager
Last synced: 3 months ago
JSON representation
A Markdown parser for Swift, using Github Flavored Markdown and Metadata
- Host: GitHub
- URL: https://github.com/loopwerk/Parsley
- Owner: loopwerk
- License: mit
- Created: 2021-02-09T11:42:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-05T18:08:56.000Z (over 2 years ago)
- Last Synced: 2024-07-11T09:09:43.563Z (4 months ago)
- Topics: github-flavored-markdown, markdown, markdown-parser, markdown-to-html, swift, swift-package-manager
- Language: Swift
- Homepage:
- Size: 61.5 KB
- Stars: 18
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- project-awesome - loopwerk/Parsley - A Markdown parser for Swift, using Github Flavored Markdown and Metadata (Swift)
README
A Markdown parser for Swift Package Manager, using [Github Flavored Markdown](https://github.github.com/gfm/). 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.
``` swift
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) //This is the body
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](https://github.com/loopwerk/Saga), using [SagaParsleyMarkdownReader](https://github.com/loopwerk/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](https://github.com/scinfu/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.