/SwiftAsciidoctor

Swift port of Asciidoctor.

Primary LanguageSwiftMIT LicenseMIT

SwiftAsciidoctor

Swift

This is a Swift port of Asciidoctor.

Internally, this calls asciidoctor.js via JavaScriptCore framework so you can use this library on Apple platforms only. Linux or Windows are not supported.

Instration

If you use Swift Package Manager, you can use this library by adding this into Package.swift:

dependencies: [
    .package(url: "https://github.com/mshibanami/SwiftAsciidoctor", from: "1.0.2")
]

Usage

import SwiftAsciidoctor

let asciidoctor = SwiftAsciidoctor()

try asciidoctor.convert("== Hello World")
// <div class="sect1">
// <h2 id="_hello_world">Hello World</h2>
// <div class="sectionbody">
// </div>
// </div>

try asciidoctor.convert(
    "= Document title",
    options: [
        .attributes(["showtitle": true])
    ])
// <h1>Document title</h1>

You can specify Almost all convert options of asciidoctor.js but they may not work because of the limitation of JavaScriptCore.

Development

  • You can directly open this repository on Xcode.

  • If you want to update asciidoctor.js, simply do npm update.

Acknowledgements