mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
bom detection and removal
This commit is contained in:
parent
6f5d8eae96
commit
92e9f3b313
1 changed files with 5 additions and 2 deletions
|
|
@ -14,7 +14,7 @@ import fnmatch
|
||||||
from collections import defaultdict, Hashable
|
from collections import defaultdict, Hashable
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from codecs import open
|
from codecs import open, BOM_UTF8
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
from jinja2 import Markup
|
from jinja2 import Markup
|
||||||
|
|
@ -192,7 +192,10 @@ class pelican_open(object):
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return open(self.filename, encoding='utf-8').read()
|
content = open(self.filename, encoding='utf-8').read()
|
||||||
|
if content[0] == BOM_UTF8.decode('utf8'):
|
||||||
|
content = content[1:]
|
||||||
|
return content
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue