feed: move to saneyaml

This commit is contained in:
2022-04-12 13:41:34 +02:00
parent cf8b1ff7e9
commit a809433410
3 changed files with 67 additions and 5 deletions

View File

@ -13,8 +13,7 @@ import requests
from bs4 import BeautifulSoup
from slugify import slugify
from re import compile as re_compile
from re import sub
yamlre = re_compile('[_\'\[\]\{\}\#\&\*\!\|\>\`\"\%]')
import saneyaml
def write_etag(feed_name, feed_data):
@ -121,12 +120,12 @@ def sanitize_yaml (frontmatter):
#some fields are lists
l = []
for i in v:
i = yamlre.sub(r'\\\g<0>', i)
i = saneyaml.load(i)
l.append(i)
frontmatter[k] = l
else:
v = yamlre.sub(r'\\\g<0>', v)
v = saneyaml.load(v)
frontmatter[k] = v
return frontmatter