Skip to content

Commit 5b366fe

Browse files
committed
Fix accessibility bug that prevented EmphasisTransformer to be extensible.
1 parent 5f5fac9 commit 5b366fe

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Sources/MarkdownKit/Parser/EmphasisTransformer.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,26 @@ open class EmphasisTransformer: InlineTransformer {
3232
/// from two parameters: the first denoting whether it's double usage, and the second
3333
/// referring to the emphasized text.
3434
public struct Emphasis {
35-
let ch: Character
36-
let special: Bool
37-
let factory: (Bool, Text) -> TextFragment
35+
public let ch: Character
36+
public let special: Bool
37+
public let factory: (Bool, Text) -> TextFragment
38+
39+
public init(ch: Character, special: Bool, factory: @escaping (Bool, Text) -> TextFragment) {
40+
self.ch = ch
41+
self.special = special
42+
self.factory = factory
43+
}
3844
}
3945

40-
/// Emphasis supported by default. Override this property to change the what gets
41-
/// supported.
46+
/// Emphasis supported by default. Override this property to change what is supported.
4247
open class var supportedEmphasis: [Emphasis] {
4348
let factory = { (double: Bool, text: Text) -> TextFragment in
4449
double ? .strong(text) : .emph(text)
4550
}
4651
return [Emphasis(ch: "*", special: true, factory: factory),
4752
Emphasis(ch: "_", special: false, factory: factory)]
4853
}
49-
54+
5055
/// The emphasis map, used internally to determine how characters are used for emphasis
5156
/// markup.
5257
private var emphasis: [Character : Emphasis] = [:]

0 commit comments

Comments
 (0)