Thin, faithful, but Swift-y wrappers for cmark.
Swift 5.3 |
---|
Swift Package Manager:
.package(url: "https://github.com/dduan/Scmark", .branch("main"))
Scmark is a wrapper around the library part of cmark. It provides:
- Simple CommonMark-to-HTML translation.
- Syntax-tree-based traversal and manipulation.
- Procedural input parsing.
- Tree-to CommonMark/XML/HTML/Groff(man page)/LaTeX translation.
Scmark strives to provide good ergonomics for Swift users, while staying as close cmark's original interface as possible. Examples where APIs were adapted for Swift are:
- Names following Swift's API Design Guidelines.
- Tree
Node
,Parser
, andTreeIterator
has object-oriented interfaces instead of C-style free functions for ergonomics as well as memory safety. Tree
is aSequence
interface (syntax sugar) for usingTreeIterator
.- Enhancement with type-safety: Whereas C uses an special enum case (e.g.
CMARK_EVENT_NONE
) to represent errors, Scmark replaces it withOptional
.Bool
in place ofint
s from C when it's appropriate, etc.
Scmark ships with a copy of cmark 0.29.0. It has no further dependencies.
cmark's license is included as Sources/Ccmark/COPYING
Scmark is released under MIT license. See LICENSE.md.