mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Fix #900
Allow HTML files with meta tags that don't have a "name" and "content" field to be read by the HTMLReader. For example, "<meta charset="utf-8" />" might appear in an HTML document. Without this change, this causes an exception.
This commit is contained in:
parent
3857fd72b5
commit
8869bbdc1f
2 changed files with 13 additions and 10 deletions
|
|
@ -302,16 +302,18 @@ class HTMLReader(BaseReader):
|
|||
return result + '>'
|
||||
|
||||
def _handle_meta_tag(self, attrs):
|
||||
name = self._attr_value(attrs, 'name').lower()
|
||||
contents = self._attr_value(attrs, 'content', '')
|
||||
if not contents:
|
||||
contents = self._attr_value(attrs, 'contents', '')
|
||||
if contents:
|
||||
logger.warning("Meta tag attribute 'contents' used in file %s, should be changed to 'content'", self._filename)
|
||||
name = self._attr_value(attrs, 'name')
|
||||
if name:
|
||||
name = name.lower()
|
||||
contents = self._attr_value(attrs, 'content', '')
|
||||
if not contents:
|
||||
contents = self._attr_value(attrs, 'contents', '')
|
||||
if contents:
|
||||
logger.warning("Meta tag attribute 'contents' used in file %s, should be changed to 'content'", self._filename)
|
||||
|
||||
if name == 'keywords':
|
||||
name = 'tags'
|
||||
self.metadata[name] = contents
|
||||
if name == 'keywords':
|
||||
name = 'tags'
|
||||
self.metadata[name] = contents
|
||||
|
||||
@classmethod
|
||||
def _attr_value(cls, attrs, name, default=None):
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
<meta name="author" contents="Alexis Métaireau" />
|
||||
<meta name="summary" contents="Summary and stuff" />
|
||||
<meta name="custom_field" contents="http://notmyidea.org" />
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
Multi-line metadata should be supported
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue