mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge branch 'master' of https://github.com/Skami18/pelican
This commit is contained in:
commit
28d29aa33c
2 changed files with 20 additions and 3 deletions
|
|
@ -165,8 +165,7 @@ class ArticlesGenerator(Generator):
|
||||||
|
|
||||||
# if no category is set, use the name of the path as a category
|
# if no category is set, use the name of the path as a category
|
||||||
if 'category' not in metadatas.keys():
|
if 'category' not in metadatas.keys():
|
||||||
category = os.path.dirname(f).replace(
|
category = os.path.basename(os.path.dirname(f))
|
||||||
os.path.expanduser(self.path)+'/', '')
|
|
||||||
|
|
||||||
if category == self.path:
|
if category == self.path:
|
||||||
category = self.settings['DEFAULT_CATEGORY']
|
category = self.settings['DEFAULT_CATEGORY']
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,25 @@ class MarkdownReader(object):
|
||||||
)(value[0])
|
)(value[0])
|
||||||
return content, metadatas
|
return content, metadatas
|
||||||
|
|
||||||
_EXTENSIONS = {'rst': RstReader, 'md': MarkdownReader} # supported formats
|
|
||||||
|
class HtmlReader(object):
|
||||||
|
_re = re.compile('\<\!\-\-\#\s?[A-z0-9_-]*\s?\:s?[A-z0-9\s_-]*\s?\-\-\>')
|
||||||
|
|
||||||
|
def read(self, filename):
|
||||||
|
"""Parse content and metadata of (x)HTML files"""
|
||||||
|
content = open(filename)
|
||||||
|
metadatas = {'title':'unnamed'}
|
||||||
|
for i in self._re.findall(content):
|
||||||
|
key = i.split(':')[0][5:].strip()
|
||||||
|
value = i.split(':')[-1][:-3].strip()
|
||||||
|
print [key,value]
|
||||||
|
metadatas[key.lower()] = value
|
||||||
|
|
||||||
|
return content, metadatas
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_EXTENSIONS = {'rst': RstReader, 'md': MarkdownReader, 'html': HtmlReader} # supported formats
|
||||||
|
|
||||||
|
|
||||||
def read_file(filename, fmt=None):
|
def read_file(filename, fmt=None):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue