Add section link snippet
parent
4e625a45fa
commit
e11085ca91
|
@ -57,6 +57,9 @@ def code_inline():
|
||||||
def code():
|
def code():
|
||||||
return code_inline() or code_block()
|
return code_inline() or code_block()
|
||||||
|
|
||||||
|
def slugify(text):
|
||||||
|
return re.sub('\s+', '-', text.lower())
|
||||||
|
|
||||||
def linkify(text, link):
|
def linkify(text, link):
|
||||||
return f"[{text}]({link})"
|
return f"[{text}]({link})"
|
||||||
|
|
||||||
|
@ -741,6 +744,12 @@ for i in range(int(match.group(1)), int(match.group(2)) + 1):
|
||||||
`
|
`
|
||||||
endsnippet
|
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
|
snippet cp(\d+) "Comment current page (and date)" r
|
||||||
`!p snip.rv = "<!--" + datetime.now().strftime("%Y-%m-%d") + " p. " + match.group(1) + "-->"`
|
`!p snip.rv = "<!--" + datetime.now().strftime("%Y-%m-%d") + " p. " + match.group(1) + "-->"`
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
Loading…
Reference in New Issue