Skip to content

Determine the Unicode class of a mathematical character.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt
Notifications You must be signed in to change notification settings

satzlich/swift-unicode-math

Repository files navigation

swift-unicode-math

Platform Compatibility Swift Version

Swift equivalent of typst/unicode-math-class plus latex3/unicode-math table.

Add Dependency

let package = Package(
    // ...
    dependencies: [
        .package(url: "https://github.com/satzlich/swift-unicode-math", branch: "main"),
    ],

    // ...
    // .target(
    dependencies: [
        .product(name: "unicode_math", package: "swift-unicode-math"),
        .product(name: "unicode_math_class", package: "swift-unicode-math"),
    ],
)

Example

XCTAssertEqual(math_class("0"), MathClass.Normal)
XCTAssertEqual(math_class("a"), MathClass.Alphabetic)
XCTAssertEqual(math_class("𝔸"), MathClass.Alphabetic)
XCTAssertEqual(math_class("+"), MathClass.Vary)
XCTAssertEqual(math_class("×"), MathClass.Binary)
XCTAssertEqual(math_class("("), MathClass.Opening)
XCTAssertEqual(math_class(","), MathClass.Punctuation)
XCTAssertEqual(math_class("|"), MathClass.Fence)
XCTAssertEqual(math_class("😃"), nil)
let symbol = MATH_SYMBOLS[0]

XCTAssertEqual(symbol.codepoint, "!")
XCTAssertEqual(symbol.command, "mathexclam") // not "\\mathexclam"
XCTAssertEqual(symbol.description, "exclamation mark")

// LaTeX unicode-math marks it as `\mathclose`
// Unicode MathClass marks it as `Normal`
XCTAssertEqual(math_class(symbol.codepoint), MathClass.Normal)

Reference

License

This package is dual-licensed under the MIT and Apache 2.0 licenses.

About

Determine the Unicode class of a mathematical character.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt

Stars

Watchers

Forks

Packages

No packages published