在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):macteo/Marklight开源软件地址(OpenSource Url):https://github.com/macteo/Marklight开源编程语言(OpenSource Language):Swift 98.3%开源软件介绍(OpenSource Introduction):MarklightMarkdown syntax highlighter for iOS and macOS. DescriptionMarklight is a drop in component to easily add realtime Markdown syntax highlight on any user editable text view in iOS and macOS applications. Marklight doesn't include HTML generation from Markdown, but you can use one of the many other components available like Markingbird. Regular expressions are taken from Markingbird, a Markdown parser and html generator. Features
Requirements
InstallationCocoaPodsCocoaPods is a dependency manager for Cocoa projects. You can install it with the following command: $ gem install cocoapods
To integrate Marklight into your Xcode project using CocoaPods, specify it in your source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Marklight' Then, run the following command: $ pod install CarthageCarthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. You can install Carthage with Homebrew using the following command: $ brew update
$ brew install carthage To integrate Marklight into your Xcode project using Carthage, specify it in your
Run ManuallyAdd the Marklight Xcode project to your own. Then add the UsageIn this repository you can find a sample project with few lines of code in the Sample code is written in Swift but Objective-C should be supported too, if you find an incompatibility please open an issue. IntegrationThe easiest way to crete a user editable Import Marklight modules into your Swift class import Marklight or if you are writing in Objective-C #import <Marklight/Marklight-Swift.h>
In your let textStorage = MarklightTextStorage() Customize the appearance as desired:
As per Apple's documentation it should be enough to assign the textStorage.addLayoutManager(textView.layoutManager) However I'm experiencing some crashes if I want to preload some text instead of letting the user start from scratch with a new text. A workaround is proposed below. For simplicity we assume you have a let string = "# My awesome markdown string" Convert let attributedString = NSAttributedString(string: string) Set the loaded string to the textView.attributedText = attributedString Append the loaded string to the textStorage.appendAttributedString(attributedString) Enjoy. AcknowledgementsMarklight is heavily based on Markingbird, so many thanks to Kristopher Johnson and every previous contribution on which Markingbird is based upon. LicenseMarklight is released under the MIT license. See LICENSE for details. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论