MarkdownDecorator: Enable CSS class prefix to be injected (#83)

This change makes it possible to inject a custom CSS class
prefix into `MarkdownDecorator`, which will in turn be
passed to its underlying HTML-based syntax highlighter.
This commit is contained in:
John Sundell 2019-09-05 11:54:56 +02:00 committed by GitHub
parent 91adf9359f
commit d1dd1acda0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -8,10 +8,14 @@ import Foundation
/// Type used to decorate a Markdown file with Splash-highlighted code blocks
public struct MarkdownDecorator {
private let highlighter = SyntaxHighlighter(format: HTMLOutputFormat())
private let highlighter: SyntaxHighlighter<HTMLOutputFormat>
private let skipHighlightingPrefix = "no-highlight"
public init() {}
/// Create a Markdown decorator with a given prefix to apply to all CSS
/// classes used when highlighting code blocks within a Markdown string.
public init(classPrefix: String = "") {
highlighter = SyntaxHighlighter(format: HTMLOutputFormat(classPrefix: classPrefix))
}
/// Decorate all code blocks within a given Markdown string. This API assumes
/// that the passed Markdown is valid. Each code block will be replaced by