From 5c4a1bcfa70b31391114ba0096c68b5f714222a8 Mon Sep 17 00:00:00 2001 From: Oleksandr Glushchenko Date: Fri, 12 Apr 2019 18:03:51 +0300 Subject: [PATCH] #538 --- FSNotes/Helpers/NotesTextProcessor.swift | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/FSNotes/Helpers/NotesTextProcessor.swift b/FSNotes/Helpers/NotesTextProcessor.swift index 0b35f3107..eaf3eaa8d 100644 --- a/FSNotes/Helpers/NotesTextProcessor.swift +++ b/FSNotes/Helpers/NotesTextProcessor.swift @@ -659,7 +659,7 @@ public class NotesTextProcessor { styleApplier.enumerateAttribute(.foregroundColor, in: paragraphRange, options: []) { (value, range, stop) -> Void in if (value as? NSColor) != nil { - styleApplier.addAttribute(.foregroundColor, value: NotesTextProcessor.fontColor, range: paragraphRange) + styleApplier.addAttribute(.foregroundColor, value: NotesTextProcessor.fontColor, range: range) } } #endif @@ -721,20 +721,11 @@ public class NotesTextProcessor { } // We detect and process lists - if isFullScan { - NotesTextProcessor.listRegex.matches(string, range: paragraphRange) { (result) -> Void in - guard let range = result?.range else { return } - NotesTextProcessor.listOpeningRegex.matches(string, range: range) { (innerResult) -> Void in - guard let innerRange = innerResult?.range else { return } - styleApplier.addAttribute(.foregroundColor, value: NotesTextProcessor.syntaxColor, range: innerRange) - } - } - } else { - NotesTextProcessor.listSingleLineRegex.matches(string, range: paragraphRange) { (innerResult) -> Void in + NotesTextProcessor.listRegex.matches(string, range: paragraphRange) { (result) -> Void in + guard let range = result?.range else { return } + NotesTextProcessor.listOpeningRegex.matches(string, range: range) { (innerResult) -> Void in guard let innerRange = innerResult?.range else { return } styleApplier.addAttribute(.foregroundColor, value: NotesTextProcessor.syntaxColor, range: innerRange) - styleApplier.addAttribute(.font, value: NotesTextProcessor.font, range: innerRange) - styleApplier.fixAttributes(in: innerRange) } } @@ -1068,7 +1059,7 @@ public class NotesTextProcessor { fileprivate static let _markerUL = "[*+-]" fileprivate static let _markerOL = "\\d+[.]" - fileprivate static let _listMarker = "(?:\(_markerUL)|\(_markerOL))" + fileprivate static let _listMarker = "(?:\\p{Z}|\\t)*(?:\(_markerUL)|\(_markerOL))" fileprivate static let _wholeList = [ "( # $1 = whole list", " ( # $2",