แสดง markdown โดยใช้ส่วนประกอบ Swiftui บริสุทธิ์ รับข้อได้เปรียบของ ViewBuilder เพื่อให้ปรากฏตัวที่กำหนดเองสำหรับ Text และ View
import Parma
struct ContentView : View {
var markdown = " I'm **Strong**. "
var body : some View {
Parma ( markdown )
}
}สำหรับตัวอย่างเพิ่มเติมโปรดดูแอพสาธิต
Swift Package Manager เป็นเครื่องมือในการจัดการการกระจายรหัส Swift มันรวมเข้ากับระบบการสร้าง Swift เพื่อทำให้กระบวนการดาวน์โหลดรวบรวมและเชื่อมโยงการพึ่งพาในทุกแพลตฟอร์มโดยอัตโนมัติ
การเพิ่ม Parma เป็นการพึ่งพาโดยใช้ GUI ของ Xcode URL แพ็คเกจคือ https://github.com/dasautoooo/Parma
Cocoapods เป็นผู้จัดการการพึ่งพาสำหรับโครงการโกโก้ สำหรับคำแนะนำการใช้งานและการติดตั้งเยี่ยมชมเว็บไซต์ของพวกเขา หากต้องการรวม Parma เข้ากับโครงการ Xcode ของคุณโดยใช้ cocoapods ให้ระบุใน 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 {
...
}มีการสาธิตที่แก้ไขวิธีการที่ได้รับมอบหมายเหล่านี้บางส่วนด้านล่างเพื่อให้ทุกคนใช้เป็นข้อมูลอ้างอิง
/// 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 ปาร์มาเป็นเมืองทางตอนเหนือของอิตาลีซึ่งมีชื่อเสียงในด้านสถาปัตยกรรมดนตรีและศิลปะ เหตุผลในการเลือกชื่อเมืองนี้เป็นชื่อโครงการคือ Giambattista Bodoni นักพิมพ์ที่มีชื่อเสียงซึ่งใช้ชีวิตและทำงานในเมืองนี้มากที่สุด
Bodoni เป็นนักพิมพ์อิตาลีผู้ออกแบบประเภทในปาร์มา ในช่วงอายุการใช้งานของเขาเขาได้ออกแบบรูปแบบหลายอย่างที่รู้จักกันในชื่อ Bodoni ทุกวันนี้ MAC แต่ละตัวมีการติดตั้งตัวอักษร Bodoni และใช้งานฟรี
แพ็คเกจถูกสร้างขึ้นเมื่อลงซึ่งเป็นตัวแยกวิเคราะห์ Markdown ใน Swift