Afficher la marque en utilisant des composants Swiftui purs. Prendre des avantages de ViewBuilder pour faire des apparences personnalisées pour Text et View .
import Parma
struct ContentView : View {
var markdown = " I'm **Strong**. "
var body : some View {
Parma ( markdown )
}
}Pour plus d'exemples, veuillez vous référer à l'application de démonstration.
Swift Package Manager est un outil pour gérer la distribution du code SWIFT. Il est intégré au système Swift Build pour automatiser le processus de téléchargement, de compilation et de liaison des dépendances sur toutes les plateformes.
Ajoutant Parma comme dépendance en utilisant l'interface graphique de Xcode, l'URL du package est https://github.com/dasautoooo/Parma .
Cocoapods est un gestionnaire de dépendances pour les projets de cacao. Pour les instructions d'utilisation et d'installation, visitez leur site Web. Pour intégrer Parma dans votre projet Xcode à l'aide de cocoapods, spécifiez-le dans votre Podfile :
pod 'Parma' Pour personnaliser les styles Text et les View , créez un nouveau rendu conforme au protocole ParmaRenderable et ne réimplémentez que ceux qui correspondent à vos objectifs. Enfin, attribuez le rendu personnalisé en tant que nouveau rendu lors de la création de la vue Parma .
import Parma
struct ContentView : View {
var markdown = " I'm **Strong**. "
var body : some View {
Parma ( markdown , render : MyRender ( ) )
}
}
struct MyRender : ParmaRenderable {
...
}Il y a un DemoApp qui a modifié certaines de ces méthodes de délégué ci-dessous pour que tout le monde puisse prendre comme référence.
/// 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 Parme est une ville du nord de l'Italie, qui est célèbre pour son architecture, sa musique et son art. La raison de choisir ce nom de la ville comme nom du projet est Giambattista Bodoni, un célèbre typographe, qui a passé la plupart de sa vie à vivre et à travailler dans cette ville.
Bodoni était un typographe italien, un concepteur de type à Parme. Au cours de sa durée de vie, il a conçu de nombreuses polices de caractères connues sous le nom de Bodoni de nos jours. Chaque Mac a une police Bodoni installée et libre d'utiliser.
Le package est construit sur Down, qui est un analyseur de démarque dans Swift.