[Cryptech-Commits] [wiki] 16/75: More fun with lists

git at cryptech.is git at cryptech.is
Fri Oct 8 18:51:42 UTC 2021


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch production
in repository wiki.

commit 9d927e49d9c10fc16c6dfa4a2a96cdb6216e4e2b
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Thu Mar 21 14:54:25 2019 +0000

    More fun with lists
---
 tools/trac2md.py | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/tools/trac2md.py b/tools/trac2md.py
index 03d8861..99b7df0 100755
--- a/tools/trac2md.py
+++ b/tools/trac2md.py
@@ -164,29 +164,22 @@ def WikiToMD(content):
             # Convert bullet lists.  The start and end of a list needs
             # an empty line.
             #
-            if line.startswith('- ') or line.startswith('* '):
-                # No need to modify the line, just add the new line
+            nested_line = line.lstrip(' ')
+            if nested_line.startswith('- ') or nested_line.startswith('* '):
                 if not in_list:
                     new_content.append("\n")
-                in_list = True
-            elif line.startswith(' '):
-                # Check for nested lists
-                nested_line = line.lstrip(' ')
-                if nested_line.startswith('* ') or nested_line.startswith('- '):
-                    # Adjust the nested list level as needed
-                    indent = len(line) - len(nested_line)
-                    if indent > prev_indent:
-                        nested_level += 1
-                    elif indent < prev_indent:
-                        nested_level -= 1
-                    prev_indent = indent
-
-                    # Set the proper indentation for markdown
-                    line = '    ' * nested_level + nested_line
-            else:
-                if in_list:
-                    # Add the closing empty line
-                    new_content.append("\n")
+                    nested_level = 0
+                    prev_indent = 0
+                    in_list = True
+                indent = len(line) - len(nested_line)
+                if indent > prev_indent:
+                    nested_level += 1
+                elif indent < prev_indent:
+                    nested_level -= 1
+                prev_indent = indent
+                line = '    ' * nested_level + nested_line
+            elif in_list:
+                new_content.append("\n")
                 in_list = False
                 nested_level = 0
                 prev_indent = 0



More information about the Commits mailing list