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中的降級解析器。