From: Vladimír Vondruš Date: Mon, 11 Dec 2017 00:47:02 +0000 (+0100) Subject: m.abbr: fix case of empty title, test it. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=878a28a030b0205b07ad18d3a4ba5817e7c52f5e;p=blog.git m.abbr: fix case of empty title, test it. --- diff --git a/pelican-plugins/m/abbr.py b/pelican-plugins/m/abbr.py index 7e19629e..39163c9d 100644 --- a/pelican-plugins/m/abbr.py +++ b/pelican-plugins/m/abbr.py @@ -28,8 +28,8 @@ from docutils.parsers import rst def abbr(name, rawtext, text, lineno, inliner, options={}, content=[]): abbr, title = parse_link(text) - if not title: - return [nodes.abbreviation(abbr, abbr)], [] + if not abbr: + return [nodes.abbreviation(title, title)], [] return [nodes.abbreviation(abbr, abbr, title=title)], [] def register(): diff --git a/pelican-plugins/m/test/abbr/page.html b/pelican-plugins/m/test/abbr/page.html new file mode 100644 index 00000000..b827dd05 --- /dev/null +++ b/pelican-plugins/m/test/abbr/page.html @@ -0,0 +1,41 @@ + + + + + m.abbr | A Pelican Blog + + + + + + + + + + + + + +
+
+
+
+
+
+

m.abbr

+ +

Text. Text.

+ +
+
+
+
+
+ + diff --git a/pelican-plugins/m/test/abbr/page.rst b/pelican-plugins/m/test/abbr/page.rst new file mode 100644 index 00000000..5268b216 --- /dev/null +++ b/pelican-plugins/m/test/abbr/page.rst @@ -0,0 +1,6 @@ +m.abbr +###### + +:summary: no. + +:abbr:`Text `. :abbr:`Text`. diff --git a/pelican-plugins/m/test/test_abbr.py b/pelican-plugins/m/test/test_abbr.py new file mode 100644 index 00000000..47210f33 --- /dev/null +++ b/pelican-plugins/m/test/test_abbr.py @@ -0,0 +1,12 @@ +from m.test import PluginTestCase + +class Abbr(PluginTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, '', *args, **kwargs) + + def test(self): + self.run_pelican({ + 'PLUGINS': ['m.htmlsanity', 'm.abbr'] + }) + + self.assertEqual(*self.actual_expected_contents('page.html'))