diff --git a/.vim/snips/pandoc.snippets b/.vim/snips/pandoc.snippets index 6d3c119..f32d6ff 100644 --- a/.vim/snips/pandoc.snippets +++ b/.vim/snips/pandoc.snippets @@ -57,6 +57,9 @@ def code_inline(): def code(): return code_inline() or code_block() +def slugify(text): + return re.sub('\s+', '-', text.lower()) + def linkify(text, link): return f"[{text}]({link})" @@ -741,6 +744,12 @@ for i in range(int(match.group(1)), int(match.group(2)) + 1): ` endsnippet +snippet "sec([\sA-z]+)" "Link section titled ..." r +`!p +snip.rv = "* " + linkify(match.group(1), f"{snip.basename}_{slugify(match.group(1))}") +` +endsnippet + snippet cp(\d+) "Comment current page (and date)" r `!p snip.rv = ""` endsnippet