chiark / gitweb /
m.abbr: fix case of empty title, test it.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 11 Dec 2017 00:47:02 +0000 (01:47 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 11 Dec 2017 02:03:32 +0000 (03:03 +0100)
pelican-plugins/m/abbr.py
pelican-plugins/m/test/abbr/page.html [new file with mode: 0644]
pelican-plugins/m/test/abbr/page.rst [new file with mode: 0644]
pelican-plugins/m/test/test_abbr.py [new file with mode: 0644]

index 7e19629e2328bb2264d59df17c47da82ee831597..39163c9d76a6aa78ec3eb010ff52483d70678c9a 100644 (file)
@@ -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 (file)
index 0000000..b827dd0
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>m.abbr | A Pelican Blog</title>
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400,400i,600%7CSource+Sans+Pro:400,400i,600,600i" />
+  <link rel="stylesheet" href="static/m-dark.css" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+  <meta property="og:title" content="m.abbr" />
+  <meta name="twitter:title" content="m.abbr" />
+  <meta property="og:url" content="page.html" />
+  <meta name="twitter:url" content="page.html" />
+  <meta property="og:description" content="no." />
+  <meta name="twitter:description" content="no." />
+  <meta name="twitter:card" content="summary" />
+  <meta property="og:type" content="website" />
+</head>
+<body>
+<header><nav id="navigation">
+  <div class="m-container">
+    <div class="m-row">
+      <a href="./" id="m-navbar-brand" class="m-col-t-9 m-col-m-none m-left-m">A Pelican Blog</a>
+    </div>
+  </div>
+</nav></header>
+<main>
+<article>
+  <div class="m-container m-container-inflatable">
+    <div class="m-row">
+      <div class="m-col-l-10 m-push-l-1">
+        <h1>m.abbr</h1>
+<!-- content -->
+<p><abbr title="Title">Text</abbr>. <abbr>Text</abbr>.</p>
+<!-- /content -->
+      </div>
+    </div>
+  </div>
+</article>
+</main>
+</body>
+</html>
diff --git a/pelican-plugins/m/test/abbr/page.rst b/pelican-plugins/m/test/abbr/page.rst
new file mode 100644 (file)
index 0000000..5268b21
--- /dev/null
@@ -0,0 +1,6 @@
+m.abbr
+######
+
+:summary: no.
+
+:abbr:`Text <Title>`. :abbr:`Text`.
diff --git a/pelican-plugins/m/test/test_abbr.py b/pelican-plugins/m/test/test_abbr.py
new file mode 100644 (file)
index 0000000..47210f3
--- /dev/null
@@ -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'))