在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):dreamwieber/AttributedMarkdown开源软件地址(OpenSource Url):https://github.com/dreamwieber/AttributedMarkdown开源编程语言(OpenSource Language):Objective-C 85.9%开源软件介绍(OpenSource Introduction):AttributedMarkdown: Native Markdown Parsing on iOS
This library takes Markdown formatted text and turns it into an NSAttributedString, suitable for rendering in native UIKit components on iOS 6 (UITextView, UILabel, etc). In short, this allows you to apply styling to Markdown without having to use UIWebView and HTML tags. This project is based-upon / modifies a Cocoa fork of peg markdown. Usage:
Check out the HelloMarkdown example app to see it in action. Easy Setup (BETA)A Cocoapod Podspec file has been added that will allow you to do a pod install to get up and running quickly. Eventually we'll post it to the cocoapods repo. For now, here's what your podfile should look like:
(The HelloMarkdown project hasn't been updated or tested against a cocoapod install. If you find any issues please let us know. This should work fine for your new project though.) Requirements & SetupIf you don't want to do Cocoapods, you can build the library yourself. There are some dependencies, which have proven tricky for some. Unless you need/want to modify the parser, it's probably easier to go with Cocoapod install. AttributedMarkdown makes use of a parser-generator called greg. This is included as a submodule, and you'll need to first run this from the command-line (from your project's root directory):
You'll also need to include the CoreText Framework in your project. To use AttributedMarkdown in one of your projects, follow the standard Apple guidelines for linking against a static library Finally, create a group in your project called "Headers" and copy these files into it:
Leave the option to copy the files into your project unselected. (Note that you don't have to call the group "Headers", this is simply a suggestion. The important bit is making sure the header references exist somewhere in your project.) The import statements in your project, wherever you want to make use of the library (eg., in a View Controller) should look like:
Basic Cascading StylesAttributedMarkdown performs some very basic cascading styles, merging the string attributes of parent elements into child elements by extracting their font traits via CoreText. This allows for things like emphasized words within an h1 tag to be bold as well as italicized. PerformanceAlthough I have yet to perform any optimizations, parsing and display of markdown in a UITableView filled with many cells of long-form markdown sample text performs rather well. LimitationsThis is a work in progress. Some tags are not yet supported, like img, etc. CreditAttributedMarkdown was created by Gregory Wieber and Jim Radford. It is based upon peg-markdown. LicenseAttributedMarkdown is released under both the GPL and the MIT license; see LICENSE for details. Peg-Markdown Licensepeg-markdown is written and maintained by John MacFarlane (jgm on github), with significant contributions by Ryan Tomayko (rtomayko). It is released under both the GPL and the MIT license; see LICENSE for details. peg-markdown was adapted for Cocoa by David Whetstone. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论