From 51a43245d34d227ce7a12a14e52262f9618f2c66 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Fri, 17 Jun 2022 16:16:42 +0300 Subject: [PATCH] Escape square brackets in file+heading based org-mode links --- src/processor/org_mode/orgnode.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/processor/org_mode/orgnode.py b/src/processor/org_mode/orgnode.py index f0a91c39..c3458bb5 100644 --- a/src/processor/org_mode/orgnode.py +++ b/src/processor/org_mode/orgnode.py @@ -173,7 +173,9 @@ def makelist(filename): n.setHeading(prtysrch.group(2)) # Set SOURCE property to a file+heading based org-mode link to the entry - n.properties['SOURCE'] = f'[[file:{filename}::*{n.Heading()}]]' + escaped_filename = filename.replace("[","\[").replace("]","\]") + escaped_heading = n.Heading().replace("[","\[").replace("]","\]") + n.properties['SOURCE'] = f'[[file:{escaped_filename}::*{escaped_heading}]]' return nodelist