Introduction
Welcome to the documentation for MarkedView, a powerful library for rendering Markdown in iOS applications.
Installation
To install MarkedView, you can use CocoaPods. Simply add the following line to your Podfile:
pod 'MarkedView'
Usage
Here is an example of how you can use MarkedView in your iOS application:
// Import the MarkedView framework
import MarkedView
// Create a MarkedView instance
let markedView = MarkedView()
// Set the Markdown content to render
markedView.setMarkedContent("# Hello, MarkedView!")
// Add the MarkedView to your view hierarchy
view.addSubview(markedView)
Customization
You can customize the appearance and behavior of MarkedView by using various properties and methods.
Rendering Options
You can set rendering options to modify the way MarkedView displays the Markdown content:
markedView.useGFM = true
: Enables support for GitHub Flavored Markdown.markedView.renderOptions.hardWrap = true
: Wraps the text at the container width.markedView.renderOptions.breaks = true
: Converts newlines into line breaks.markedView.renderOptions.sanitize = true
: Sanitizes the rendered HTML, removing any potentially harmful content.markedView.renderOptions.smartypants = true
: Renders smart quotes and other typographic enhancements.
Styling
You can customize the style of the rendered Markdown by changing the CSS properties:
markedView.customCSS = "h1 { color: red; }"
: Changes the color of first-level headings to red.
Examples
Here are some examples to help you get started using MarkedView:
Basic Markdown
Here’s an example of rendering basic Markdown content:
markedView.setMarkedContent("# Hello, MarkedView!")
Render HTML
MarkedView supports rendering HTML within Markdown documents. Here’s an example:
markedView.setMarkedContent("You can add emphasis or strong tags.")
Advanced
Delegate
You can use the MarkedViewDelegate
to implement custom logic when certain events occur in MarkedView:
markedView.delegate = self
Link Handling
If you want to handle custom link actions, you can use the following delegate method:
func markedView(_ markedView: MarkedView, didClickOnLinkWith URL: URL)
Conclusion
Congratulations! You now have a basic understanding of how to use MarkedView to render Markdown content in your iOS application. Consider exploring the official documentation for more details and advanced features.