Use docinfo fields instead of comments.

This commit is contained in:
Alexis Metaireau 2010-10-15 01:26:21 +01:00
commit 3ea2968a83
5 changed files with 15 additions and 15 deletions

View file

@ -39,10 +39,10 @@ following syntax::
My super title
##############
.. date: 2010-10-03 10:20
.. tags: thats, awesome
.. category: yeah
.. author: Alexis Metaireau
:date: 2010-10-03 10:20
:tags: thats, awesome
:category: yeah
:author: Alexis Metaireau
Why the name "Pelican" ?
------------------------

View file

@ -224,7 +224,7 @@ def read_settings(filename):
context[key] = tempdict[key]
return context
_METADATA = re.compile('.. ([a-z]+): (.*)', re.M)
_METADATA = re.compile(':([a-z]+): (.*)', re.M)
_METADATAS_FIELDS = {'tags': lambda x: x.split(', '),
'date': lambda x: get_date(x),
'category': lambda x: x,
@ -252,7 +252,7 @@ def parse_metadata(string):
"""
output = {}
for m in _METADATA.finditer(string):
name = m.group(1)
name = m.group(1).lower()
value = m.group(2)
if name in _METADATAS_FIELDS:
output[name] = _METADATAS_FIELDS[name](value)

View file

@ -1,10 +1,10 @@
Oh yeah !
#########################
.. tags: oh, bar, yeah
.. date: 2010-10-20 10:14
.. category: bar
.. author: Alexis Métaireau
:tags: oh, bar, yeah
:date: 2010-10-20 10:14
:category: bar
:author: Alexis Métaireau
Why not ?
=========

View file

@ -1,10 +1,10 @@
This is a super article !
#########################
.. tags: foo, bar, foobar
.. date: 2010-10-02 10:14
.. category: yeah
.. author: Alexis Métaireau
:tags: foo, bar, foobar
:date: 2010-10-02 10:14
:category: yeah
:author: Alexis Métaireau
Some content here !

View file

@ -1,6 +1,6 @@
Unbelievable !
##############
.. date: 2010-10-15 20:30
:date: 2010-10-15 20:30
Or completely awesome. Depends the needs.