순수한 swiftui 구성 요소를 사용하여 마크 다운을 표시합니다. Text 와 View 에 맞춤형 모양을 만들기 위해 ViewBuilder 의 장점을 취합니다.
import Parma
struct ContentView : View {
var markdown = " I'm **Strong**. "
var body : some View {
Parma ( markdown )
}
}더 많은 예는 데모 앱을 참조하십시오.
Swift Package Manager는 Swift 코드 배포를 관리하는 도구입니다. Swift 빌드 시스템과 통합되어 모든 플랫폼에서 종속성을 다운로드, 컴파일 및 연결하는 프로세스를 자동화합니다.
Xcode의 GUI를 사용하여 Parma 종속성으로 추가하면 패키지 URL은 https://github.com/dasautoooo/Parma 입니다.
Cocoapods는 코코아 프로젝트의 종속성 관리자입니다. 사용 및 설치 지침은 웹 사이트를 방문하십시오. Cocoapods를 사용하여 Parma Xcode 프로젝트에 통합하려면 Podfile 에 지정하십시오.
pod 'Parma' Text 스타일을 사용자 정의하고 S View 보려면 프로토콜 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 Parma는 북부 이탈리아의 도시로 건축, 음악 및 예술로 유명합니다. 이 도시 이름을 프로젝트 이름으로 선택한 이유는 유명한 타이포 그래퍼 인 Giambattista Bodoni 가이 도시에서 평생 동안 생활하고 일하는 것을 보냈습니다.
Bodoni는 Parma의 이탈리아 타이포 그래퍼, Type Designer였습니다. 그의 수명 동안, 그는 요즘 보도니 (Bodoni)로 알려진 많은 서체를 설계했습니다. 각 Mac에는 Bodoni 글꼴이 설치되어 있으며 무료로 사용할 수 있습니다.
패키지는 다운에 구축되었으며 Swift의 Markdown Parser입니다.