Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion vimwiki_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import json
import os
import re
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -30,7 +31,7 @@
</body>
</html>
"""
default_extension = ["fenced_code", "tables", "codehilite", "toc"]
default_extension = ["fenced_code", "tables", "codehilite", "toc", "smarty"]

vim = shutil.which("vim") and "vim" or (shutil.which("nvim") and "nvim")

Expand Down Expand Up @@ -64,6 +65,17 @@ def get(l, index, default):
return l[index] if index < len(l) else default


def convert_task_lists(html):
"""Convert GitHub-style task list markers to unicode symbols in HTML list items."""
# Pattern for checked items: <li> followed by optional whitespace,
# [x] or [X], followed by optional whitespace
html = re.sub(r'(<li>)\s*\[(x|X)\]\s*', r'\1☑ ', html)
# Pattern for unchecked items: <li> followed by optional whitespace,
# [ ] followed by optional whitespace
html = re.sub(r'(<li>)\s*\[ \]\s*', r'\1☐ ', html)
return html


def main():

FORCE = sys.argv[1] # noqa - not supported
Expand Down Expand Up @@ -165,6 +177,9 @@ def main():
# Parse content
content = md.convert(content)

# Convert task list markers to unicode symbols
content = convert_task_lists(content)

# Merge template
template = template.replace("%content%", content)

Expand Down