aboutsummaryrefslogtreecommitdiff
path: root/tools/trac2md.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/trac2md.py')
-rwxr-xr-xtools/trac2md.py35
1 files 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