Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcritz/textbundle
Markdown TextBundle implemented in 100% Swift
https://github.com/mcritz/textbundle
markdown swift textbundle
Last synced: about 1 month ago
JSON representation
Markdown TextBundle implemented in 100% Swift
- Host: GitHub
- URL: https://github.com/mcritz/textbundle
- Owner: mcritz
- License: apache-2.0
- Created: 2020-11-22T03:33:19.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-09T21:19:48.000Z (about 3 years ago)
- Last Synced: 2024-10-10T20:05:06.149Z (2 months ago)
- Topics: markdown, swift, textbundle
- Language: Swift
- Homepage:
- Size: 72.3 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# [mcritz / TextBundle](https://github.com/mcritz/TextBundle)
Swift-first, Swift-best package for [TextBundle](http://textbundle.org). Supports [version 2 of the spec](http://textbundle.org/spec/).
If you’re looking for an alternative implemenetation, try [shinyfrog/TextBundle](https://github.com/shinyfrog/TextBundle).
---
## Installation
In `Package.swift`
```
dependencies: [
.package(url: "https://github.com/mcritz/TextBundle.git", .upToNextMajor(from: "1.0.0")),
],
```... and further down in targets…
```
dependencies: [
.product(name: "TextBundle", package: "TextBundle"),
],
```## Usage
### Reading from Disk
Read a TextBundle as either `.textbundle` or `.textpack` from disk```
let myFileURL: URL = ...
let myTextBundle = try TextBundle.read(myFileURL)
let contents: String = myTextBundle.textContents
```### Creating a bundle
```
let myBundle = TextBundle(name: "HelloWorld", contents: "# Hello, World!")
```### Writing to disk
```
myBundle.bundle(destinationURL: myURL) { bundleFileURL in
print(bundleFileURL.path)
}
```---
Thanks to Guillermo Casales @gcasales for making this photo available freely on Unsplash 🎁
https://unsplash.com/photos/LQfcolSv2M0