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 My super title
############## ##############
.. date: 2010-10-03 10:20 :date: 2010-10-03 10:20
.. tags: thats, awesome :tags: thats, awesome
.. category: yeah :category: yeah
.. author: Alexis Metaireau :author: Alexis Metaireau
Why the name "Pelican" ? Why the name "Pelican" ?
------------------------ ------------------------

View file

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

View file

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

View file

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

View file

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