1
0
Fork 0
forked from github/pelican

Support inline SVG images (#2634)

Support inline SVG images
This commit is contained in:
Justin Mayer 2019-10-17 10:47:05 -07:00 committed by GitHub
commit 67781f63af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 1 deletions

6
RELEASE.md Normal file
View file

@ -0,0 +1,6 @@
Release type: minor
* Support inline SVGs; don't treat titles in SVGs as HTML titles
* Add category to feeds (in addition to tags)
* Improve content metadata field docs
* Add docs for including other Markdown/reST files in content

View file

@ -407,7 +407,7 @@ class HTMLReader(BaseReader):
if self._in_head:
self._in_head = False
self._in_top_level = True
elif tag == 'title':
elif self._in_head and tag == 'title':
self._in_title = False
self.metadata['title'] = self._data_buffer
elif tag == 'body':

View file

@ -0,0 +1,17 @@
<html>
<head>
<title>Article with an inline SVG</title>
</head>
<body>
Ensure that the title attribute in an inline svg is not handled as an HTML title.
<svg xmlns="http://www.w3.org/2000/svg" width="210mm" height="297mm" viewBox="0 0 210 297">
<path fill="#b2b2ff" stroke="#000" stroke-width="2.646" d="M88.698 89.869l-8.899 15.63a38.894 38.894 0 00-16.474 31.722 38.894 38.894 0 0038.894 38.894 38.894 38.894 0 0038.894-38.894 38.894 38.894 0 00-9-24.83l-2.38-16.886-14.828 4.994a38.894 38.894 0 00-12.13-2.144z">
<title>A different title inside the inline SVG</title>
</path>
<ellipse cx="100.806" cy="125.285" rx="3.704" ry="10.583"/>
<ellipse cx="82.021" cy="125.285" rx="3.704" ry="10.583"/>
<ellipse cx="-111.432" cy="146.563" rx="3.704" ry="10.583" transform="rotate(-64.822)"/>
<ellipse cx="-118.245" cy="91.308" rx="6.18" ry="8.62" transform="matrix(.063 -.99801 .96163 .27436 0 0)"/>
</svg>
</body>
</html>

View file

@ -262,6 +262,7 @@ class TestArticlesGenerator(unittest.TestCase):
['This is a super article !', 'published', 'yeah', 'article'],
['This is a super article !', 'published', 'yeah', 'article'],
['This is a super article !', 'published', 'Default', 'article'],
['Article with an inline SVG', 'published', 'Default', 'article'],
['This is an article with category !', 'published', 'yeah',
'article'],
['This is an article with multiple authors!', 'published',
@ -554,6 +555,7 @@ class TestArticlesGenerator(unittest.TestCase):
'An Article With Code Block To Test Typogrify Ignore',
'Article title',
'Article with Nonconformant HTML meta tags',
'Article with an inline SVG',
'Article with markdown and summary metadata multi',
'Article with markdown and summary metadata single',
'Article with markdown containing footnotes',

View file

@ -764,3 +764,10 @@ class HTMLReaderTest(ReaderTest):
}
self.assertDictHasSubset(page.metadata, expected)
def test_article_with_inline_svg(self):
page = self.read_file(path='article_with_inline_svg.html')
expected = {
'title': 'Article with an inline SVG',
}
self.assertDictHasSubset(page.metadata, expected)