mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Make HTMLReader parse multiple occurences of metadata tags as list
this means you can now specify: <meta name="custom_field" content="value_1" /> <meta name="custom_field" content="value_2" /> and the resulting object.custom_field will be ['value_1', 'value_2']
This commit is contained in:
parent
34103cd5dd
commit
f62217f38e
5 changed files with 33 additions and 1 deletions
|
|
@ -440,7 +440,17 @@ class HTMLReader(BaseReader):
|
|||
|
||||
if name == 'keywords':
|
||||
name = 'tags'
|
||||
self.metadata[name] = contents
|
||||
|
||||
if name in self.metadata:
|
||||
# if this metadata already exists (i.e. a previous tag with the
|
||||
# same name has already been specified then either convert to
|
||||
# list or append to list
|
||||
if isinstance(self.metadata[name], list):
|
||||
self.metadata[name].append(contents)
|
||||
else:
|
||||
self.metadata[name] = [self.metadata[name], contents]
|
||||
else:
|
||||
self.metadata[name] = contents
|
||||
|
||||
@classmethod
|
||||
def _attr_value(cls, attrs, name, default=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue