Skip to content

Commit

Permalink
Merge pull request #2 from brokenhandsio/master
Browse files Browse the repository at this point in the history
Update for GFM
  • Loading branch information
0xTim authored Apr 25, 2017
2 parents ffe2600 + 9c0a6ff commit ac02865
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 62 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
/.build
/Packages
/*.xcodeproj
Package.pins
DerivedData/
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

27 changes: 19 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
os:
- linux
- osx
- linux
- osx
language: generic
sudo: required
dist: trusty
osx_image: xcode8
install:
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/02090c7ede5a637b76e6df1710e83cd0bbe7dcdf/swiftenv-install.sh)"

osx_image: xcode8.3
before_install:
- if [ $TRAVIS_OS_NAME == "osx" ]; then
brew tap vapor/tap;
brew update;
brew install vapor;
else
eval "$(curl -sL https://apt.vapor.sh)";
sudo apt-get install vapor;
sudo chmod -R a+rx /usr/;
fi

script:
- swift build
- swift test
- swift build
- swift build -c release
- swift test

notifications:
email:
on_success: never
on_failure: change

7 changes: 2 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import PackageDescription

let package = Package(
name: "cmark.swift",
targets: [
Target(name: "cmark.swift-example", dependencies: ["cmark.swift"])
],
name: "SwiftMarkdown",
dependencies: [
.Package(url: "https://github.com/czechboy0/cmark.git", "0.26.1")
.Package(url: "https://github.com/brokenhandsio/cmark-gfm.git", majorVersion: 1)
]
)
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
# cmark.swift
# SwiftMarkdown

[![Build Status](https://travis-ci.org/czechboy0/cmark.swift.svg?branch=master)](https://travis-ci.org/czechboy0/cmark.swift)
[![Latest Release](https://img.shields.io/github/release/czechboy0/cmark.swift.svg)](https://github.com/czechboy0/cmark.swift/releases/latest)
![Platforms](https://img.shields.io/badge/platforms-Linux%20%7C%20OS%20X-blue.svg)
![Package Managers](https://img.shields.io/badge/package%20managers-SwiftPM-yellow.svg)
[![Language](https://img.shields.io/badge/Swift-3-brightgreen.svg)](http://swift.org)
[![Build Status](https://travis-ci.org/vapor-community/markdown.svg?branch=master)](https://travis-ci.org/vapor-community/markdown)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/vapor-community/markdown/master/LICENSE)

[![Blog](https://img.shields.io/badge/blog-honzadvorsky.com-green.svg)](http://honzadvorsky.com)
[![Twitter Czechboy0](https://img.shields.io/badge/twitter-czechboy0-green.svg)](http://twitter.com/czechboy0)

> Swift cmark wrapper for SwiftPM
Very simple Swift wrapper of [cmark](https://github.com/jgm/cmark). Uses a [fork](https://github.com/czechboy0/cmark) of cmark which has been adapted for building with SwiftPM.
Very simple Swift wrapper of Github's fork of [cmark](https://github.com/github/cmark). Uses a [fork](https://github.com/brokenhandsio/cmark-gfm) of cmark which has been adapted for building with SwiftPM.

# Usage

## markdown -> HTML

```swift
let markdown = "# Hello"
let html = try markdownToHTML(markdown, options: [])
print(html) //"<h1>Hello</h1>\n"
let html = try markdownToHTML(markdown)
print(html) // This will return "<h1>Hello</h1>\n"
```

# Installation
## Options

## Swift Package Manager
You can pass different options to the underlying `cmark` library. By default `safe` is passed, but this can be explicitly done with:

```swift
.Package(url: "https://github.com/czechboy0/cmark.swift.git", majorVersion: 0, minor: 1)
let html = try markdownToHTML(markdown, options: [.safe])
```

:gift_heart: Contributing
------------
Please create an issue with a description of your problem or open a pull request with a fix.
The available options are:

* sourcePosition
* hardBreaks
* safe
* noBreaks
* normalize
* validateUTF8
* smartQuotes

:v: License
-------
MIT
For more information on the available options, see [`cmark`](https://github.com/github/cmark).

:alien: Author
------
Honza Dvorsky - https://honzadvorsky.com, [@czechboy0](http://twitter.com/czechboy0)
# Installation

## Swift Package Manager

```swift
.Package(url: "https://github.com/vapor-community/markdown.git", majorVersion: 0, minor: 1)
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ccmark
import cmark

public enum MarkdownError: Error {
case conversionFailed
Expand All @@ -20,7 +20,7 @@ public struct MarkdownOptions: OptionSet {
static public let smartQuotes = MarkdownOptions(rawValue: 1 << 10)
}

public func markdownToHTML(_ str: String, options: MarkdownOptions = []) throws -> String {
public func markdownToHTML(_ str: String, options: MarkdownOptions = [.safe]) throws -> String {
var buffer: String?
try str.withCString {
guard let buf = cmark_markdown_to_html($0, Int(strlen($0)), options.rawValue) else {
Expand Down
5 changes: 0 additions & 5 deletions Sources/cmark.swift-example/main.swift

This file was deleted.

4 changes: 2 additions & 2 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import XCTest
@testable import cmark_swiftTests
@testable import SwiftMarkdownTests

XCTMain([
testCase(cmark_swiftTests.allTests),
testCase(SwiftMarkdownTests.allTests),
])
13 changes: 13 additions & 0 deletions Tests/SwiftMarkdownTests/SwiftMarkdownTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import XCTest
import SwiftMarkdown

class SwiftMarkdownTests: XCTestCase {

static var allTests = [
("testMDtoHTML", testMDtoHTML),
]

func testMDtoHTML() {
XCTAssertEqual(try markdownToHTML("# Hello"), "<h1>Hello</h1>\n")
}
}
14 changes: 0 additions & 14 deletions Tests/cmark.swiftTests/cmark_swiftTests.swift

This file was deleted.

0 comments on commit ac02865

Please sign in to comment.