forked from ruangrupa/konfluks
Merge pull request 'feed: compile regex once' (#1) from knoflook/lumbunglib:master into master
Reviewed-on: r/lumbunglib#1
This commit is contained in:
commit
e0fd2c40a6
@ -12,7 +12,8 @@ import jinja2
|
|||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from slugify import slugify
|
from slugify import slugify
|
||||||
from re import sub
|
from re import compile as re_compile
|
||||||
|
yamlre = re_compile('"')
|
||||||
|
|
||||||
|
|
||||||
def write_etag(feed_name, feed_data):
|
def write_etag(feed_name, feed_data):
|
||||||
@ -119,12 +120,12 @@ def sanitize_yaml (frontmatter):
|
|||||||
#some fields are lists
|
#some fields are lists
|
||||||
l = []
|
l = []
|
||||||
for i in v:
|
for i in v:
|
||||||
i = sub('"', '\\"', i)
|
i = yamlre.sub('\\"', i)
|
||||||
l.append(i)
|
l.append(i)
|
||||||
frontmatter[k] = l
|
frontmatter[k] = l
|
||||||
|
|
||||||
else:
|
else:
|
||||||
v = sub('"', '\\"', v)
|
v = yamlre.sub('\\"', v)
|
||||||
frontmatter[k] = v
|
frontmatter[k] = v
|
||||||
|
|
||||||
return frontmatter
|
return frontmatter
|
||||||
|
Loading…
Reference in New Issue
Block a user