Moscho de visualización utilizando componentes puros de Swiftui. Tomando ventajas de ViewBuilder para hacer apariciones personalizadas para Text y View .
import Parma
struct ContentView : View {
var markdown = " I'm **Strong**. "
var body : some View {
Parma ( markdown )
}
}Para más ejemplos, consulte la aplicación de demostración.
Swift Package Manager es una herramienta para administrar la distribución del código Swift. Está integrado con el sistema de compilación Swift para automatizar el proceso de descarga, compilación y vinculación de dependencias en todas las plataformas.
Agregando Parma como dependencia utilizando la GUI de Xcode, la URL del paquete es https://github.com/dasautoooo/Parma .
Cocoapods es un gerente de dependencia para proyectos de cacao. Para obtener instrucciones de uso e instalación, visite su sitio web. Para integrar Parma en su proyecto Xcode con CocoAPods, especifíquelo en su Podfile :
pod 'Parma' Para personalizar los estilos Text y View , cree un nuevo renderizado que se ajuste al protocolo ParmaRenderable , y solo vuelva a implementar a los que se ajustan a sus propósitos. Finalmente, asigne el render personalizado como un nuevo render cuando cree una vista Parma .
import Parma
struct ContentView : View {
var markdown = " I'm **Strong**. "
var body : some View {
Parma ( markdown , render : MyRender ( ) )
}
}
struct MyRender : ParmaRenderable {
...
}Hay una demostración que modificó algunos de estos métodos de delegado a continuación para que todos tomen como referencia.
/// 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 es una ciudad en el norte de Italia, que es famosa por su arquitectura, música y arte. La razón de elegir este nombre de la ciudad como el nombre del proyecto es Giambattista Bodoni, un tipógrafo famoso, que pasó la mayor parte de su vida viviendo y trabajando en esta ciudad.
Bodoni era un tipógrafo italiano, diseñador de tipo en Parma. Durante su vida útil, diseñó muchos tipos de letra conocidos como Bodoni hoy en día. Cada Mac tiene la fuente Bodoni instalada y de forma gratuita.
El paquete se basa en la abajo, que es un analizador de Markdown en Swift.