https://github.com/loopwerk/swiftmarkdown
A Swift wrapper for Python-Markdown
https://github.com/loopwerk/swiftmarkdown
markdown markdown-parser markdown-to-html python-markdown swift
Last synced: 19 days ago
JSON representation
A Swift wrapper for Python-Markdown
- Host: GitHub
- URL: https://github.com/loopwerk/swiftmarkdown
- Owner: loopwerk
- License: mit
- Created: 2021-02-05T13:19:39.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-20T18:22:54.000Z (about 5 years ago)
- Last Synced: 2026-01-21T09:58:09.837Z (about 2 months ago)
- Topics: markdown, markdown-parser, markdown-to-html, python-markdown, swift
- Language: Swift
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftMarkdown
A Swift wrapper for [Python-Markdown](https://github.com/Python-Markdown/markdown), using [PythonKit](https://github.com/pvieito/PythonKit).
You'll need to install Python-Markdown (and optionally pygments) yourself.
## Usage
``` swift
import SwiftMarkdown
let markdown = try SwiftMarkdown.markdown("Hello, World!")
print(markdown.html)
let string = """
---
tags: news, swift
date: 2021-02-04
---
# Hello world
This uses metadata
"""
let markdownWithMetadata = try SwiftMarkdown.markdown(string, extensions: [.meta])
print(markdownWithMetadata.metadata) // ["tags": "news, swift", "date": "2021-02-04"]
```
See https://python-markdown.github.io/extensions for documentation on the "extensions".
SwiftMarkdown also comes bundles with its own three extensions:
- `.title`, which removes the first title from the html output and instead makes it available as `result.title`
- `.strikethrough`, which turns `~~text~~` into ~~text~~
- `.urlize`, which turns naked links into clickable links
## Installation
Using Swift Package Manager
```
.package(url: "https://github.com/loopwerk/SwiftMarkdown", from: "0.4.0"),
```