]> git.parisson.com Git - teleforma.git/commitdiff
back to previous rst processor
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 25 Jun 2021 11:06:54 +0000 (13:06 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 25 Jun 2021 11:06:54 +0000 (13:06 +0200)
teleforma/templatetags/teleforma_tags.py

index 3b558e8a8baa5e5f6f702c36b02273b487d4bb8b..a14d9b11f3a97ebd35fbbf09403e42a2efec6c52 100644 (file)
@@ -384,32 +384,30 @@ def render_flatpage(content):
     if isinstance(content, str):
         content = content.split("\n")
 
-    if content:
-        for line in content:
-            match = re.match(
-                '^(\.\. *(?:_[^:]*:|(?:\|\w+\|)? *image::) *)([^ ]+) *$', line)
-            if match:
-                directive, urlname = match.groups()
-                line = directive
-                try:
-                    i = urlname.index('teleforma-')
-                except ValueError:
-                    i = -1
-                if i == 0:
-                    line += reverse(urlname)
-                elif urlname[:1] != '/':
-                    line += reverse('teleforma-flatpage',
-                                    args=[path + '/../' + urlname])
-                else:
-                    line += urlname
-
-            parsed += line + "\n"
-
-        parts = publish_parts(source=smart_str(
-            parsed), writer_name="html4css1", settings_overrides={})
-        return mark_safe('<div class="rst-content">\n' + force_text(parts["html_body"]) + '</div>')
-    else:
-        return ""
+    for line in content:
+        match = re.match(
+            '^(\.\. *(?:_[^:]*:|(?:\|\w+\|)? *image::) *)([^ ]+) *$', line)
+        if match:
+            directive, urlname = match.groups()
+            line = directive
+            try:
+                i = urlname.index('teleforma-')
+            except ValueError:
+                i = -1
+            if i == 0:
+                line += reverse(urlname)
+            elif urlname[:1] != '/':
+                line += reverse('teleforma-flatpage',
+                                args=[path + '/../' + urlname])
+            else:
+                line += urlname
+
+        parsed += line + "\n"
+
+    parts = publish_parts(source=smart_str(
+        parsed), writer_name="html4css1", settings_overrides={})
+    return mark_safe('<div class="rst-content">\n' + force_text(parts["html_body"]) + '</div>')
+
 
 render_flatpage.is_safe = True