Parma
v0.3.0
使用纯SwiftUI组件显示标记。利用ViewBuilder的优势进行Text和View的自定义外观。
import Parma
struct ContentView : View {
var markdown = " I'm **Strong**. "
var body : some View {
Parma ( markdown )
}
}有关更多示例,请参阅演示应用程序。
Swift软件包管理器是管理Swift代码分布的工具。它与Swift Build System集成在一起,以自动化下载,编译和链接所有平台的依赖关系的过程。
通过使用Xcode的GUI添加Parma作为依赖关系,包含url是https://github.com/dasautoooo/Parma 。
Cocoapods是可可项目的依赖性经理。有关使用和安装说明,请访问其网站。要使用Cocoapods将Parma集成到您的Xcode项目中,请在您的Podfile中指定:
pod 'Parma' 要自定义Text样式并View S,请创建一个符合协议ParmaRenderable的新渲染,并且仅重新成真那些适合您的目的。最后,在创建Parma视图时,将自定义渲染分配为新渲染。
import Parma
struct ContentView : View {
var markdown = " I'm **Strong**. "
var body : some View {
Parma ( markdown , render : MyRender ( ) )
}
}
struct MyRender : ParmaRenderable {
...
}有一个DemoApp修改了下面的某些代表方法,以便每个人都以参考为参考。
/// Define the heading text style.
/// - Parameters:
/// - level: The level of heading.
/// - textView: The textView generated from captured heading string.
func heading ( level : HeadingLevel ? , textView : Text ) -> Text
/// Define the paragraph text style.
/// - Parameter text: The text string captured from paragraph.
func paragraph ( text : String ) -> Text
/// Define the text style for plain text. Do NOT recommend to alter this if there's no special purpose.
/// - Parameter text: The text string captured from markdown.
func plainText ( _ text : String ) -> Text
/// Define the strong text style.
/// - Parameter textView: The textView generated from captured strong string.
func strong ( textView : Text ) -> Text
/// Define the emphasis text style.
/// - Parameter textView: The textView generated from captured emphasis string.
func emphasis ( textView : Text ) -> Text
/// Define the link text style.
/// - Parameters:
/// - textView: The textView generated from captured link string.
/// - destination: The destination of the link.
func link ( textView : Text , destination : String ? ) -> Text
/// Define the code text style.
/// - Parameter text: The text string captured from code.
func code ( _ text : String ) -> Text
/// Define the style of heading view.
/// - Parameters:
/// - level: The level of heading.
/// - view: The view contains heading text.
func headingBlock ( level : HeadingLevel ? , view : AnyView ) -> AnyView
/// Define the style of paragraph view.
/// - Parameter view: The view contains view(s) which belong(s) to this paragraph.
func paragraphBlock ( view : AnyView ) -> AnyView
/// Define the style of list item.
/// - Parameter attributes: Attributes of the list containing the item. Those must be considered for proper item rendering.
/// - Parameter index: Normalized index of the list item. For exemple, the index of the third item of a one level list would be `[2]` and the second item of a sublist appearing fourth in it's parent list would be `[3, 1]`.
/// - Parameter view: The view contains view(s) which belong(s) to this item.
func listItem ( attributes : ListAttributes , index : [ Int ] , view : AnyView ) -> AnyView
/// Define the style of image view.
/// - Parameter urlString: The url string for this image view.
/// - Parameter altTextView: The view contains alt text.
func imageView ( with urlString : String , altTextView : AnyView ? ) -> AnyView 帕尔马(Parma)是意大利北部的城市,该城市以其建筑,音乐和艺术而闻名。选择这个城市名称为项目名称的原因是Giambattista Bodoni,他是一位著名的版式印刷作者,他一生都在这个城市生活和工作。
Bodoni是一位意大利印刷师,帕尔马(Parma)的类型设计师。在他的寿命中,他设计了许多如今被称为Bodoni的字体。每个Mac都安装了Bodoni字体,可以免费使用。
该软件包是在向下构建的,这是Swift中的降级解析器。