Skip to content

Commit

Permalink
process order list regex
Browse files Browse the repository at this point in the history
  • Loading branch information
starfall-9000 committed Apr 8, 2021
1 parent ea67df8 commit ec0e247
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Sources/SwiftyMarkdown/SwiftyLineProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ public class SwiftyLineProcessor {
return nil
}

if !text.contains(element.token) {
if element.token == "1. " { output = processOrderListRegex(output) }

if !text.contains(element.token) && element.token != "1. " {
continue
}

Expand Down Expand Up @@ -244,6 +246,14 @@ public class SwiftyLineProcessor {
return foundAttributes
}

func processOrderListRegex(_ text: String) -> String {
let regex = try? NSRegularExpression(pattern: "^[0-9]+. ", options: .caseInsensitive)
let range = NSMakeRange(0, text.count)
let result = regex?.stringByReplacingMatches(in: text, options: [], range: range,
withTemplate: "1. ")
return result ?? text
}

}


0 comments on commit ec0e247

Please sign in to comment.