diff options
| author | Justin Mayer <entroP@gmail.com> | 2019-10-17 10:47:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-17 10:47:05 -0700 |
| commit | 67781f63afefe7079f1cf41587916fb89fb60427 (patch) | |
| tree | c7ffef6d4c1edb3196dee664e96d3c513989bda8 | |
| parent | 7bfc70c1538108dfaf1b0cbfc563ee4883bc1f2a (diff) | |
| parent | 3be00060166ee23eb03d45508dd107554c0ce615 (diff) | |
| download | pelican-67781f63afefe7079f1cf41587916fb89fb60427.tar.gz | |
Support inline SVG images (#2634)
Support inline SVG images
| -rw-r--r-- | RELEASE.md | 6 | ||||
| -rw-r--r-- | pelican/readers.py | 2 | ||||
| -rw-r--r-- | pelican/tests/content/article_with_inline_svg.html | 17 | ||||
| -rw-r--r-- | pelican/tests/test_generators.py | 2 | ||||
| -rw-r--r-- | pelican/tests/test_readers.py | 7 |
5 files changed, 33 insertions, 1 deletions
diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 00000000..6b958464 --- /dev/null +++ b/RELEASE.md @@ -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 diff --git a/pelican/readers.py b/pelican/readers.py index 0edfed0e..52378c4f 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -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': diff --git a/pelican/tests/content/article_with_inline_svg.html b/pelican/tests/content/article_with_inline_svg.html new file mode 100644 index 00000000..07f97a8a --- /dev/null +++ b/pelican/tests/content/article_with_inline_svg.html @@ -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> diff --git a/pelican/tests/test_generators.py b/pelican/tests/test_generators.py index 2455d1f4..9ade301e 100644 --- a/pelican/tests/test_generators.py +++ b/pelican/tests/test_generators.py @@ -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', diff --git a/pelican/tests/test_readers.py b/pelican/tests/test_readers.py index 30181f54..3f05bb4a 100644 --- a/pelican/tests/test_readers.py +++ b/pelican/tests/test_readers.py @@ -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) |
