File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,9 @@ import Logging
7
7
fileprivate let log = Logger ( label: " D2Commands.AutoLatexCommand " )
8
8
9
9
/// A simple heuristic for detecting "formulas" in messages. Matches a single character.
10
- fileprivate let formulaPattern = try ! LegacyRegex ( from : " [0-9{} \\ + \\ -* \\ / \\ [ \\ ] \\ \\ |] " )
10
+ fileprivate let formulaPattern = #/ [0-9{}\+\ -*\/\[\ ]\\|]/#
11
11
/// Matches text that should be "escaped" when rendering the message as LaTeX.
12
- fileprivate let textPattern = try ! LegacyRegex ( from: " (?<! \\ \\ ) \\ b \\ s* \\ p{L}[ \\ p{L} \\ s]* " )
12
+ fileprivate let textPattern = try ! LegacyRegex ( from: " (?<! \\ \\ ) \\ b \\ s* \\ p{L}[ \\ p{L} \\ s]* " ) // TODO: Migrate to Swift regex once lookbehind is supported
13
13
14
14
public class AutoLatexCommand : StringCommand {
15
15
public let info = CommandInfo (
@@ -39,7 +39,7 @@ public class AutoLatexCommand: StringCommand {
39
39
return
40
40
}
41
41
42
- if formulaPattern . matchCount ( in : content ) > 0 {
42
+ if !content . matches ( of : formulaPattern ) . isEmpty {
43
43
let formula = escapeText ( in: content)
44
44
latexRenderer. renderImage ( from: formula, scale: 1.5 ) . listenOrLogError {
45
45
do {
You can’t perform that action at this time.
0 commit comments