### Installation
Source: https://github.com/bmoliveira/markdownkit/blob/master/README.md
Instructions for installing MarkdownKit using CocoaPods, Carthage, and Swift Package Manager.
```APIDOC
## Installation
### CocoaPods
Add the following to your Podfile:
```ruby
pod "MarkdownKit"
```
Then run:
```ruby
pod install
```
### Carthage
Add the following to your Cartfile:
```ruby
github "ivanbruel/MarkdownKit"
```
Then run:
```ruby
carthage update --use-xcframeworks
```
### Swift Package Manager
Add the following to your `Package.swift` file:
```swift
.package(url: "https://github.com/bmoliveira/MarkdownKit.git", from: "1.7.2")
```
```
--------------------------------
### Install MarkdownKit via CocoaPods
Source: https://github.com/bmoliveira/markdownkit/blob/master/README.md
Commands and configuration to install MarkdownKit using the CocoaPods dependency manager.
```bash
gem install cocoapods
```
```ruby
pod "MarkdownKit"
```
```bash
pod install
```
--------------------------------
### Install MarkdownKit via Carthage
Source: https://github.com/bmoliveira/markdownkit/blob/master/README.md
Commands and configuration to install MarkdownKit using the Carthage dependency manager.
```bash
brew update
brew install carthage
```
```text
github "ivanbruel/MarkdownKit"
```
```bash
carthage update --use-xcframeworks
```
--------------------------------
### Install MarkdownKit via Swift Package Manager
Source: https://github.com/bmoliveira/markdownkit/blob/master/README.md
Configuration to add MarkdownKit as a dependency in a Package.swift file.
```swift
.package(url: "https://github.com/bmoliveira/MarkdownKit.git", from: "1.7.2")
```
--------------------------------
### Carthage Installation for MarkdownKit
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Adds MarkdownKit to your Cartfile for Carthage-based dependency management. After updating the Cartfile, build the framework using 'carthage update --use-xcframeworks'.
```ruby
# Cartfile
github "ivanbruel/MarkdownKit"
```
```bash
# Build the framework
carthage update --use-xcframeworks
```
--------------------------------
### CocoaPods Installation for MarkdownKit
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Integrates MarkdownKit into your project using CocoaPods by adding the 'MarkdownKit' pod to your Podfile. Ensure you run 'pod install' after updating your Podfile.
```ruby
platform :ios, '15.6'
use_frameworks!
target 'MyApp' do
pod 'MarkdownKit'
end
```
```bash
# Install dependencies
pod install
```
--------------------------------
### Customize Strikethrough Styling in MarkdownKit
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Provides a simple example of how to apply custom colors and fonts to text marked with strikethrough syntax.
```swift
import MarkdownKit
import UIKit
let parser = MarkdownParser()
// Customize strikethrough color
parser.strikethrough.color = UIColor.red
// Customize strikethrough font
parser.strikethrough.font = UIFont.systemFont(ofSize: 16)
let markdown = """
This is ~~deleted text~~ that should be struck through.
Compare: normal text vs ~~strikethrough text~~
"""
let attributedString = parser.parse(markdown)
```
--------------------------------
### Swift Package Manager Installation for MarkdownKit
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Integrates MarkdownKit into your project using Swift Package Manager by adding the dependency to your Package.swift file. This is the recommended method for managing dependencies in modern Swift projects.
```swift
let package = Package(
name: "MyApp",
platforms: [
.macOS(.v12),
.iOS(.v15),
],
dependencies: [
.package(url: "https://github.com/bmoliveira/MarkdownKit.git", from: "1.7.2")
],
targets: [
.target(
name: "MyApp",
dependencies: ["MarkdownKit"])
]
)
```
--------------------------------
### Replace Default Markdown Elements in Swift
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Shows how to replace default Markdown elements with custom implementations in MarkdownKit. This allows modifying the behavior of standard elements like bold text, for example, by adding a background color. Dependencies include MarkdownKit and UIKit.
```swift
import MarkdownKit
import UIKit
// Create a custom bold element with different behavior
class CustomBold: MarkdownBold {
override func match(_ match: NSTextCheckingResult, attributedString: NSMutableAttributedString) {
// Call parent implementation
super.match(match, attributedString: attributedString)
// Add additional attributes (e.g., background color)
let range = match.range(at: 3)
let adjustedRange = NSRange(location: range.location - 2, length: range.length)
attributedString.addAttribute(.backgroundColor, value: UIColor.yellow, range: adjustedRange)
}
}
let parser = MarkdownParser()
let customBold = CustomBold(color: .red)
// Replace the default bold element
parser.replaceDefaultElement(parser.bold, with: customBold)
let markdown = "Normal text **highlighted bold text** more text"
let attributedString = parser.parse(markdown)
```
--------------------------------
### Basic Usage
Source: https://github.com/bmoliveira/markdownkit/blob/master/README.md
Demonstrates how to use MarkdownKit to parse a Markdown string into an attributed string.
```APIDOC
## Basic Usage
To parse Markdown into an `NSAttributedString`, create an instance of `MarkdownParser` and use its `parse(_:)` method.
### Request
```swift
let markdownParser = MarkdownParser()
let markdown = "I support a *lot* of custom Markdown **Elements**, even `code`!"
label.attributedText = markdownParser.parse(markdown)
```
```
--------------------------------
### Extensibility
Source: https://github.com/bmoliveira/markdownkit/blob/master/README.md
Explains how to add custom Markdown elements by implementing the `MarkdownElement` protocol.
```APIDOC
## Extensibility
Extend MarkdownKit by implementing the `MarkdownElement` protocol (or its descendants) and adding your custom elements to the `MarkdownParser`.
### Custom Element Example (MarkdownSubreddit)
```swift
import MarkdownKit
class MarkdownSubreddit: MarkdownLink {
private static let regex = "(^|\\s|\\W)(/?r/(\\w+)/?)"
override var regex: String {
return MarkdownSubreddit.regex
}
override func match(match: NSTextCheckingResult,
attributedString: NSMutableAttributedString) {
let subredditName = attributedString.attributedSubstringFromRange(match.rangeAtIndex(3)).string
let linkURLString = "http://reddit.com/r/\(subredditName)"
formatText(attributedString, range: match.range, link: linkURLString)
addAttributes(attributedString, range: match.range, link: linkURLString)
}
}
```
### Usage with Custom Element
```swift
let markdownParser = MarkdownParser(customElements: [MarkdownSubreddit()])
let markdown = "**/r/iosprogramming** can be *markdown* as well!"
label.attributedText = markdownParser.parse(markdown)
```
```
--------------------------------
### MarkdownParser Initialization with Custom Font and Color
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Shows how to initialize MarkdownParser with custom base fonts and colors, which are then applied to all parsed text. It also demonstrates parsing an existing NSAttributedString, preserving some of its attributes.
```swift
import MarkdownKit
import UIKit
// Initialize with custom font
let parser = MarkdownParser(font: UIFont.systemFont(ofSize: 18))
let attributedText = parser.parse("# Custom Font Header\n\nRegular text with **bold** parts.")
// Initialize with custom font and color
let customParser = MarkdownParser(
font: UIFont(name: "Helvetica Neue", size: 16)!,
color: UIColor.darkGray
)
let result = customParser.parse("Text will be dark gray with custom font.")
// Parse existing NSAttributedString (preserves some existing attributes)
let existingAttributedString = NSAttributedString(string: "**Bold** and *italic*")
let parsedFromAttributed = parser.parse(existingAttributedString)
```
--------------------------------
### Customize Link Styling and Behavior
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Sets custom link colors and fonts, and demonstrates how to handle link interactions within a UITextView.
```swift
import MarkdownKit
import UIKit
let parser = MarkdownParser()
// Customize link color
parser.link.color = UIColor.systemBlue
// Customize link font
parser.link.font = UIFont.systemFont(ofSize: 16, weight: .medium)
let markdown = """
Click [here](https://github.com) to visit GitHub.
Documentation at [MarkdownKit](https://github.com/bmoliveira/MarkdownKit).
"""
let attributedString = parser.parse(markdown)
// Display in UITextView with tappable links
let textView = UITextView()
textView.attributedText = attributedString
textView.isEditable = false
textView.isSelectable = true
class MyViewController: UIViewController, UITextViewDelegate {
func textView(_ textView: UITextView, shouldInteractWith URL: URL,
in characterRange: NSRange) -> Bool {
UIApplication.shared.open(URL, options: [:])
return true
}
}
```
--------------------------------
### Integrate MarkdownKit with UITextView
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
This snippet demonstrates how to initialize a MarkdownParser, customize its styling for various Markdown elements, and render the parsed output into a non-editable UITextView. It also includes the implementation of the UITextViewDelegate to handle URL interactions.
```swift
import UIKit
import MarkdownKit
class MarkdownViewController: UIViewController, UITextViewDelegate {
private lazy var textView: UITextView = {
let tv = UITextView()
tv.isEditable = false
tv.isSelectable = true
tv.delegate = self
tv.translatesAutoresizingMaskIntoConstraints = false
return tv
}()
private lazy var markdownParser: MarkdownParser = {
let parser = MarkdownParser(
font: UIFont.systemFont(ofSize: 16),
color: UIColor.label
)
parser.header.color = UIColor.systemBlue
parser.header.fontIncrease = 3
parser.bold.color = UIColor.systemRed
parser.code.font = UIFont(name: "Menlo", size: 14)
parser.code.textBackgroundColor = UIColor.systemGray6
parser.link.color = UIColor.systemTeal
parser.addCustomElement(MarkdownSubreddit())
return parser
}()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
displayMarkdown()
}
private func setupUI() {
view.backgroundColor = .systemBackground
view.addSubview(textView)
NSLayoutConstraint.activate([
textView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 16),
textView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
textView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16),
textView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -16)
])
}
private func displayMarkdown() {
let markdown = "# Welcome to MarkdownKit\n\nThis is a **powerful** Markdown parser for *iOS* and *macOS*.\n\n## Features\n\n- Bold and ~~strikethrough~~ text\n- *Italic* styling\n- `Inline code` support\n\n> Blockquotes for emphasis\n\n### Links\n\nVisit [GitHub](https://github.com) or check out /r/swift"
textView.attributedText = markdownParser.parse(markdown)
}
func textView(_ textView: UITextView, shouldInteractWith URL: URL,
in characterRange: NSRange) -> Bool {
UIApplication.shared.open(URL, options: [:])
return true
}
}
```
--------------------------------
### Customize List Styling in MarkdownKit
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Demonstrates how to configure list indicators, separators, nesting levels, colors, and fonts for the MarkdownList element. It shows how these settings affect the final attributed string output.
```swift
import MarkdownKit
import UIKit
let parser = MarkdownParser()
// Customize list indicator (default: "•")
parser.list.indicator = "→"
// Customize separator between indicator and text
parser.list.separator = " "
// Customize maximum nesting level (default: 6)
parser.list.maxLevel = 4
// Customize list color
parser.list.color = UIColor.darkGray
// Customize list font
parser.list.font = UIFont.systemFont(ofSize: 14)
let markdown = """
Shopping list:
* Apples
* Oranges
- Bread
- Milk
+ Eggs
+ Butter
Nested lists:
* Level 1
* Level 2
* Level 3
"""
let attributedString = parser.parse(markdown)
```
--------------------------------
### Customize Header Styling
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Configures header appearance including font, color, font size scaling, and maximum header level constraints.
```swift
import MarkdownKit
import UIKit
let parser = MarkdownParser()
// Customize header font
parser.header.font = UIFont.systemFont(ofSize: 24, weight: .bold)
// Customize header color
parser.header.color = UIColor.purple
// Adjust font size increase per header level
parser.header.fontIncrease = 4
// Limit maximum header level
parser.header.maxLevel = 3
let markdown = """
# Header 1 (Largest)
## Header 2
### Header 3
#### Header 4 (Won't be parsed if maxLevel = 3)
##### Header 5
###### Header 6 (Smallest)
"""
let attributedString = parser.parse(markdown)
```
--------------------------------
### Customization
Source: https://github.com/bmoliveira/markdownkit/blob/master/README.md
Shows how to customize the appearance of Markdown elements, such as fonts, colors, and header sizes.
```APIDOC
## Customization
MarkdownKit allows customization of fonts, colors, and other attributes for various Markdown elements.
### Request
```swift
let markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 18))
markdownParser.enabledElements = .disabledAutomaticLink
markdownParser.bold.color = UIColor.red
markdownParser.italic.font = UIFont.italicSystemFont(ofSize: 300)
markdownParser.header.fontIncrease = 4
```
```
--------------------------------
### Manage Custom Markdown Elements in Swift
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Demonstrates how to dynamically add and remove custom Markdown elements from a MarkdownParser instance. Elements can be added during initialization or after, and existing elements can be removed. Dependencies include MarkdownKit and UIKit.
```swift
import MarkdownKit
import UIKit
// Method 1: Add custom elements at initialization
let subredditElement = MarkdownSubreddit()
let underlineElement = MarkdownUnderline()
let parser = MarkdownParser(customElements: [subredditElement, underlineElement])
// Method 2: Add custom elements after initialization
let parser2 = MarkdownParser()
parser2.addCustomElement(MarkdownSubreddit())
parser2.addCustomElement(MarkdownUnderline(color: .purple))
// Remove a custom element
parser2.removeCustomElement(subredditElement)
// Access custom elements array
print("Custom elements count: \(parser2.customElements.count)")
```
--------------------------------
### Customize Bold Text Styling
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Demonstrates how to modify the color and font of bold text elements using the MarkdownBold configuration. It also shows support for nested styling.
```swift
import MarkdownKit
import UIKit
let parser = MarkdownParser()
// Customize bold color
parser.bold.color = UIColor.red
// Customize bold font (overrides default bold transformation)
parser.bold.font = UIFont.boldSystemFont(ofSize: 20)
let markdown = """
This is normal text.
This is **bold text** that will appear red.
This is also __bold with underscore syntax__.
"""
let attributedString = parser.parse(markdown)
// Bold supports nested styling (bold + italic)
let nestedMarkdown = "***Bold and italic*** text"
let nested = parser.parse(nestedMarkdown)
```
--------------------------------
### Create Custom Subreddit Link Element
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Extends MarkdownKit by subclassing MarkdownLink to detect and format subreddit references as clickable URLs. This demonstrates regex matching and attribute application.
```swift
import Foundation
import MarkdownKit
class MarkdownSubreddit: MarkdownLink {
fileprivate static let regex = "(^|\\s|\\W)(/?r/(\\w+)/?)"
override var regex: String {
return MarkdownSubreddit.regex
}
override func match(_ match: NSTextCheckingResult,
attributedString: NSMutableAttributedString) {
let subredditName = attributedString.attributedSubstring(from: match.range(at: 3)).string
let linkURLString = "http://reddit.com/r/\(subredditName)"
formatText(attributedString, range: match.range, link: linkURLString)
addAttributes(attributedString, range: match.range)
}
}
let parser = MarkdownParser(customElements: [MarkdownSubreddit()])
let markdown = "Check out **/r/iosprogramming** for Swift tips! Also r/swift"
let attributedString = parser.parse(markdown)
```
--------------------------------
### Configuring Enabled Markdown Elements
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Illustrates how to control which Markdown elements are parsed using the 'enabledElements' option set. This allows selective enabling or disabling of features like automatic link detection, headers, lists, and more.
```swift
import MarkdownKit
import UIKit
// Disable automatic link detection (URLs must use [text](url) syntax)
let parserNoAutoLink = MarkdownParser()
parserNoAutoLink.enabledElements = .disabledAutomaticLink
// Enable all elements (default)
let parserAll = MarkdownParser(enabledElements: .all)
// Enable only specific elements
let parserLimited = MarkdownParser()
parserLimited.enabledElements = [.bold, .italic, .header]
// Available element options:
// .automaticLink - Auto-detect URLs without markdown syntax
// .header - # Header 1 through ###### Header 6
// .list - * - + list items
// .quote - > blockquotes
// .link - [text](url) links
// .bold - **bold** or __bold__
// .italic - *italic* or _italic_
// .code - `code` or ```code```
// .strikethrough - ~~strikethrough~~
let strictMarkdown = MarkdownParser()
strictMarkdown.enabledElements = [
.header,
.list,
.quote,
.link,
.bold,
.italic,
.code,
.strikethrough
] // Same as .disabledAutomaticLink
let result = strictMarkdown.parse("Visit https://example.com won't become a link")
```
--------------------------------
### Customize Markdown Elements
Source: https://github.com/bmoliveira/markdownkit/blob/master/README.md
Configuring font and color attributes for specific Markdown elements within the parser.
```swift
let markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 18))
markdownParser.enabledElements = .disabledAutomaticLink
markdownParser.bold.color = UIColor.red
markdownParser.italic.font = UIFont.italicSystemFont(ofSize: 300)
markdownParser.header.fontIncrease = 4
```
--------------------------------
### Extend MarkdownKit with Custom Elements
Source: https://github.com/bmoliveira/markdownkit/blob/master/README.md
Implementing a custom Markdown element by subclassing MarkdownLink and registering it with the parser.
```swift
import MarkdownKit
class MarkdownSubreddit: MarkdownLink {
private static let regex = "(^|\\s|\\W)(/?r/(\\w+)/?)"
override var regex: String {
return MarkdownSubreddit.regex
}
override func match(match: NSTextCheckingResult,
attributedString: NSMutableAttributedString) {
let subredditName = attributedString.attributedSubstringFromRange(match.rangeAtIndex(3)).string
let linkURLString = "http://reddit.com/r/\(subredditName)"
formatText(attributedString, range: match.range, link: linkURLString)
addAttributes(attributedString, range: match.range, link: linkURLString)
}
}
let markdownParser = MarkdownParser(customElements: [MarkdownSubreddit()])
let markdown = "**/r/iosprogramming** can be *markdown* as well!"
label.attributedText = markdownParser.parse(markdown)
```
--------------------------------
### MarkdownList Customization
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Configure the appearance and behavior of list elements, including indicators, separators, and nesting levels.
```APIDOC
## MarkdownList Customization
### Description
Configures the styling of list elements within the MarkdownParser.
### Parameters
- **indicator** (String) - Optional - The character used for list bullets.
- **separator** (String) - Optional - String between the indicator and text.
- **maxLevel** (Int) - Optional - Maximum nesting depth for lists.
- **color** (UIColor) - Optional - Text color for list items.
- **font** (UIFont) - Optional - Font styling for list items.
### Request Example
```swift
parser.list.indicator = "→"
parser.list.maxLevel = 4
```
```
--------------------------------
### Create Custom Underline Element in Swift
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Implements a custom MarkdownElement to support HTML-style underline tags (text). It uses regular expressions to find and style underlined text, allowing customization of font and color. Dependencies include Foundation and MarkdownKit.
```swift
import Foundation
import MarkdownKit
class MarkdownUnderline: MarkdownElement {
// Regex to match text HTML-style underline
internal let regex = "()(.+?)()"
let font: MarkdownFont?
let color: MarkdownColor?
public init(font: MarkdownFont? = nil, color: MarkdownColor? = nil) {
self.font = font
self.color = color
}
public func regularExpression() throws -> NSRegularExpression {
try NSRegularExpression(pattern: regex)
}
public func match(_ match: NSTextCheckingResult, attributedString: NSMutableAttributedString) {
// Delete closing tag
attributedString.deleteCharacters(in: match.range(at: 3))
// Apply underline style to text content
attributedString.addAttribute(
.underlineStyle,
value: NSNumber(value: NSUnderlineStyle.single.rawValue),
range: match.range(at: 2)
)
attributedString.addAttribute(
.underlineColor,
value: color ?? MarkdownColor.black,
range: match.range(at: 2)
)
// Delete opening tag
attributedString.deleteCharacters(in: match.range(at: 1))
}
}
// Usage
let parser = MarkdownParser()
parser.addCustomElement(MarkdownUnderline(color: .blue))
let markdown = "This has underlined text in it."
let attributedString = parser.parse(markdown)
```
--------------------------------
### Custom Element Extension
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Extend the MarkdownKit parser by creating custom elements that inherit from existing base classes.
```APIDOC
## Custom Element Creation
### Description
Create custom parsing logic by subclassing base elements like MarkdownLink.
### Method
Subclassing `MarkdownLink` and overriding `regex` and `match` methods.
### Implementation Example
```swift
class MarkdownSubreddit: MarkdownLink {
override var regex: String { return "(^|\\s|\\W)(/?r/(\\w+)/?)" }
override func match(_ match: NSTextCheckingResult, attributedString: NSMutableAttributedString) {
// Custom logic here
}
}
```
```
--------------------------------
### Basic Markdown Parsing with MarkdownKit
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Demonstrates the basic usage of MarkdownParser to convert a Markdown string into an NSAttributedString. The resulting attributed string can be applied to UIKit elements like UILabel and UITextView.
```swift
import MarkdownKit
import UIKit
// Basic usage - parse markdown to attributed string
let markdownParser = MarkdownParser()
let markdown = "I support a *lot* of custom Markdown **Elements**, even `code`!"
let attributedString = markdownParser.parse(markdown)
// Apply to UILabel
let label = UILabel()
label.attributedText = attributedString
// Apply to UITextView
let textView = UITextView()
textView.attributedText = markdownParser.parse("""
# Welcome to MarkdownKit
This is a **bold** statement with *italic* emphasis.
> Blockquotes are supported too!
- List item one
- List item two
Check out [our website](https://github.com/bmoliveira/MarkdownKit)
""")
```
--------------------------------
### Customize Blockquote Styling in MarkdownKit
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Shows how to modify the appearance of blockquotes by changing the indicator, separator, nesting depth, color, and font properties.
```swift
import MarkdownKit
import UIKit
let parser = MarkdownParser()
// Customize quote indicator (default: ">")
parser.quote.indicator = "|"
// Customize separator
parser.quote.separator = " "
// Customize maximum nesting level (default: 0 = unlimited)
parser.quote.maxLevel = 3
// Customize quote color
parser.quote.color = UIColor.systemGray
// Customize quote font
parser.quote.font = UIFont.italicSystemFont(ofSize: 14)
let markdown = """
> This is a blockquote.
> It can span multiple lines.
>> Nested quote level 2
>>> Nested quote level 3
"""
let attributedString = parser.parse(markdown)
```
--------------------------------
### Configure Automatic Link Detection
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Enables or disables the automatic detection of URLs within plain text, independent of markdown link syntax.
```swift
import MarkdownKit
import UIKit
// Automatic links enabled by default
let parser = MarkdownParser()
let markdown = """
Visit https://github.com for more info.
Email us at support@example.com
Or use markdown syntax: [Click here](https://example.com)
"""
let attributedString = parser.parse(markdown)
// Disable automatic link detection
let strictParser = MarkdownParser()
strictParser.enabledElements = .disabledAutomaticLink
let strictResult = strictParser.parse("https://github.com won't be a link")
```
--------------------------------
### Customize Code Element Styling
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Configures the visual style of inline code and code blocks, including font, text color, highlight color, and background color.
```swift
import MarkdownKit
import UIKit
let parser = MarkdownParser()
// Customize code font (typically monospace)
parser.code.font = UIFont(name: "Menlo", size: 14)
// Customize code text color
parser.code.color = UIColor.darkGray
// Customize code highlight/foreground color
parser.code.textHighlightColor = UIColor.systemPink
// Customize code background color
parser.code.textBackgroundColor = UIColor.systemGray6
let markdown = """
Inline code: `let x = 42`
Code block:
```
func hello() {
print("Hello, World!")
}
```
"""
let attributedString = parser.parse(markdown)
```
--------------------------------
### MarkdownQuote Customization
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Configure the appearance and behavior of blockquote elements.
```APIDOC
## MarkdownQuote Customization
### Description
Configures the styling of blockquote elements within the MarkdownParser.
### Parameters
- **indicator** (String) - Optional - The character used for quote prefix.
- **separator** (String) - Optional - String between the indicator and text.
- **maxLevel** (Int) - Optional - Maximum nesting depth for quotes.
- **color** (UIColor) - Optional - Text color for quotes.
- **font** (UIFont) - Optional - Font styling for quotes.
### Request Example
```swift
parser.quote.indicator = "|"
parser.quote.maxLevel = 3
```
```
--------------------------------
### Customize Italic Text Styling
Source: https://context7.com/bmoliveira/markdownkit/llms.txt
Shows how to apply custom colors and fonts to italicized text using the MarkdownItalic element.
```swift
import MarkdownKit
import UIKit
let parser = MarkdownParser()
// Customize italic color
parser.italic.color = UIColor.blue
// Customize italic font
parser.italic.font = UIFont.italicSystemFont(ofSize: 18)
let markdown = """
This is *italic text* using asterisks.
This is _italic text_ using underscores.
Combine with **bold for *nested* styling**.
"""
let attributedString = parser.parse(markdown)
```
--------------------------------
### Parse Markdown to Attributed String
Source: https://github.com/bmoliveira/markdownkit/blob/master/README.md
Basic usage of the MarkdownParser class to convert a Markdown string into an NSAttributedString.
```swift
let markdownParser = MarkdownParser()
let markdown = "I support a *lot* of custom Markdown **Elements**, even `code`!"
label.attributedText = markdownParser.parse(markdown)
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.