Turn regex patterns into consts

This commit is contained in:
Zed
2020-01-22 13:04:35 +01:00
parent bddb6df567
commit b03faccd45
3 changed files with 16 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ from htmlgen import a
const
thumbRegex = re".+:url\('([^']+)'\)"
gifRegex = re".+thumb/([^\.']+)\.[jpng].*"
reColor = re"a:active \{\n +color: (#[A-Z0-9]+)"
proc selectAll*(node: XmlNode; selector: string): seq[XmlNode] =
if node == nil: return
@@ -134,7 +135,7 @@ proc getTimelineBanner*(node: XmlNode): string =
let style = node.select("style").innerText()
var m: RegexMatch
if style.find(re"a:active \{\n +color: (#[A-Z0-9]+)", m):
if style.find(reColor, m):
return style[m.group(0)[0]]
proc getMediaCount*(node: XmlNode): string =