@@ -134,18 +134,18 @@ func parse(_ content: String) -> [String: Any]? {
134134 var metadata = [ : ] as [ String : [ String ] ]
135135 // iterate through the possible metadata keys in file
136136 if let metas = Range ( match. range ( at: g2) , in: content) {
137+ let p = #"^(?:[ \t]*(?:\/\/)?[ \t]*@)([\w-]+)[ \t]+([^\s]+[^\r\n\t\v\f]*)"#
138+ // this pattern checks for specific keys that won't have values
139+ let p2 = #"^(?:[ \t]*(?:\/\/)?[ \t]*@)(noframes)[ \t]*$"#
140+ // force try b/c pattern is known to be valid regex
141+ let re = try ! NSRegularExpression ( pattern: p, options: [ ] )
142+ let re2 = try ! NSRegularExpression ( pattern: p2, options: [ ] )
137143 // split metadatas by new line
138144 let metaArray = content [ metas] . split ( whereSeparator: \. isNewline)
139145 // loop through metadata lines and populate metadata dictionary
140146 for meta in metaArray {
141- let p = #"^(?:[ \t]*(?:\/\/)?[ \t]*@)([\w-]+)[ \t]+([^\s]+[^\r\n\t\v\f]*)"#
142- // this pattern checks for specific keys that won't have values
143- let p2 = #"^(?:[ \t]*(?:\/\/)?[ \t]*@)(noframes)[ \t]*$"#
144147 // the individual meta string, ie. // @name File Name
145148 let metaString = String ( meta) . trimmingCharacters ( in: . whitespaces)
146- // force try b/c pattern is known to be valid regex
147- let re = try ! NSRegularExpression ( pattern: p, options: [ ] )
148- let re2 = try ! NSRegularExpression ( pattern: p2, options: [ ] )
149149 let range = NSRange ( location: 0 , length: metaString. utf16. count)
150150 // key lines not properly prefixed & without values will be skipped
151151 if let m = re. firstMatch ( in: metaString, options: [ ] , range: range) {
0 commit comments