A Swift package that provides Markdown syntax highlighting for STTextView.
- Cross-platform: Compatible with macOS and iOS
- Beautiful defaults: Thoughtfully designed default colors and typography
- Fully customizable: Configurable fonts and colors for different Markdown elements
- Performance-minded: Built with performance in mind for handling large documents
- Easy integration: Simple API for adding to STTextView instances
Add the following to your Package.swift file:
dependencies: [
.package(url: "https://github.com/your-username/STTextView-Plugin-Markdown", from: "1.0.0")
]import STTextView
import STPluginMarkdown
// Create your text view
let textView = STTextView()
// Add Markdown plugin with beautiful default configuration
textView.addMarkdownPlugin()The default configuration provides:
- Typography: 16pt body text with appropriately scaled headings (28pt, 24pt, 20pt)
- Colors: Semantic colors that work well in both light and dark modes:
- 🟦 Headings: Indigo (distinctive but not overwhelming)
- 🟪 Code: Pink (stands out for inline code)
- 🔵 Links: Blue (standard web convention)
- 🟢 Emphasis: Teal (subtle italic highlighting)
- 🟠 Strong: Orange (warm, attention-grabbing for bold text)
import STTextView
import STPluginMarkdown
// Create custom styles for different elements
let customConfig = MarkdownConfiguration(
body: MarkdownStyle(
font: PlatformFont.systemFont(ofSize: 14),
color: PlatformColor.labelColor
),
heading1: MarkdownStyle(
font: PlatformFont.boldSystemFont(ofSize: 32),
color: PlatformColor.headingColor
),
code: MarkdownStyle(
font: PlatformFont.monospacedSystemFont(ofSize: 12, weight: .regular),
color: PlatformColor.codeColor
),
link: MarkdownStyle(
font: PlatformFont.systemFont(ofSize: 14),
color: PlatformColor.linkColor
)
// ... other styles use defaults
)
// Add plugin with custom configuration
textView.addMarkdownPlugin(configuration: customConfig)Or customize individual styles:
// Just customize heading style
let config = MarkdownConfiguration(
heading1: MarkdownStyle(
font: PlatformFont.boldSystemFont(ofSize: 32),
color: .systemRed
)
)
textView.addMarkdownPlugin(configuration: config)import STTextView
import STPluginMarkdown
let textView = STTextView()
let plugin = STPluginMarkdown(configuration: MarkdownConfiguration())
textView.addPlugin(plugin)Currently supports:
- Headings (
# ## ###) - Bold text (
**bold**) - Italic text (
*italic*) - Inline code (
`code`) - Links (
[text](url))
Configure fonts for different Markdown elements:
body: Default text fontheading1,heading2,heading3: Heading fontscode: Inline code fontbold: Bold text fontitalic: Italic text font
Configure colors for different Markdown elements:
text: Default text colorheading: Heading colorcode: Inline code colorlink: Link coloremphasis: Italic text colorstrong: Bold text color
- iOS 18.0+ / macOS 15.0+
- Swift 6.1+
- STTextView 2.0+
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- STTextView for the excellent text view implementation
- swift-markdown for Markdown parsing capabilities