Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/EFPrefix/EFMarkdown
DEPRECATED
https://github.com/EFPrefix/EFMarkdown
ios markdown swift
Last synced: 6 days ago
JSON representation
DEPRECATED
- Host: GitHub
- URL: https://github.com/EFPrefix/EFMarkdown
- Owner: EFPrefix
- License: wtfpl
- Archived: true
- Created: 2017-08-17T12:28:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-31T14:23:08.000Z (over 5 years ago)
- Last Synced: 2024-12-05T13:42:45.522Z (7 days ago)
- Topics: ios, markdown, swift
- Language: Swift
- Homepage: https://cocoapods.org/pods/EFMarkdown
- Size: 1.63 MB
- Stars: 380
- Watchers: 11
- Forks: 25
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ios-star - EFMarkdown - A lightweight Markdown library for iOS. (Text / Other Testing)
- awesome-ios - EFMarkdown - A lightweight Markdown library for iOS. (Text / Other Testing)
README
![](https://raw.githubusercontent.com/EFPrefix/EFMarkdown/master/Assets/EFMarkdown.png)
EFMarkdown is a lightweight Markdown library in Swift, based on [EFCMark](https://github.com/EFPrefix/EFCMark), inspired by [markdown](https://github.com/vapor-community/markdown) and [Markoff](https://github.com/thoughtbot/Markoff).
> [中文介绍](https://github.com/EFPrefix/EFMarkdown/blob/master/README_CN.md)
## Overview
sample1|sample2|sample3|sample4
:---------------------:|:---------------------:|:---------------------:|:---------------------:
![](https://raw.githubusercontent.com/EFPrefix/EFMarkdown/master/Assets/sample1.png)|![](https://raw.githubusercontent.com/EFPrefix/EFMarkdown/master/Assets/sample2.jpg)|![](https://raw.githubusercontent.com/EFPrefix/EFMarkdown/master/Assets/sample3.png)|![](https://raw.githubusercontent.com/EFPrefix/EFMarkdown/master/Assets/sample4.jpg)## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
| Version | Needs |
|:---------|:------------------------------------------------|
| 0.x | XCode 8.0+
Swift 3.0+
iOS 8.0+ |
| 4.x | XCode 9.0+
Swift 4.0+
iOS 8.0+ |
| 5.x | XCode 10.2+
Swift 5.0+
iOS 8.0+ |## Installation
EFMarkdown is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "EFMarkdown"
```## Usage
### 1. Markdown to HTML
You can use `EFMarkdown` to make Markdown string to HTML string easily:
```swift
let markdown = "# Hello"
var html = ""
do {
html = try EFMarkdown().markdownToHTML(markdown, options: EFMarkdownOptions.safe)
print(html) // This will return "Hello
\n"
} catch let error as NSError {
print ("Error: \(error.domain)")
}
```### 2. View Markdown
You can use `EFMarkdownView` to make a preview of Markdown:
```swift
let screenSize = UIScreen.main.bounds
let markView = EFMarkdownView()
markView.frame = CGRect(x: 0, y: 20, width: screenSize.width, height: screenSize.height - 20)
markView.onRendered = {
[weak self] (height) in
if let _ = self {
// Optional: you can know the change of height in this block
print("onRendered height: \(height ?? 0)")
}
}
self.view.addSubview(markView)
markView.load(markdown: testMarkdownFileContent(), options: [.default]) {
[weak self] (_, _) in
if let _ = self {
// Optional: you can change font-size with a value of percent here
markView.setFontSize(percent: 128)
printLog("load finish!")
}
}
```### 3. Options
You can pass different options to the underlying `cmark` library. By default `safe` is passed.
The available options are:
* default
* sourcePos
* hardBreaks
* safe
* noBreaks
* validateUTF8
* smart
* githubPreLang
* liberalHtmlTagFor more information on the available options, see [`cmark`](https://github.com/github/cmark).
## Author
EyreFree, [email protected]
## License
EFMarkdown is available under the WTFPL license. See the LICENSE file for more info.