1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00
jdhao-nvim-config/my_snippets/markdown.snippets
jdhao 70f02ae20f
fix: time zone info is now shown
datetime.now() produces a naive datetime object which does not know tzinfo. 
So the '%z' has no effect. We need to convert it to time zone aware object using
`datetime.astimezone()`.
2020-04-17 18:06:48 +08:00

57 lines
1.1 KiB
Plaintext

global !p
def gen_header(snip):
placeholders_string = snip.buffer[snip.line].strip()
level = int(placeholders_string[0])
# erase current line
snip.buffer[snip.line] = ""
line_content = "#"*level + " ${1:Section Name} " + "#"*level
line_content += '\n\n$0'
snip.expand_anon(line_content)
endglobal
snippet kbd "HTML kbd tag"
<kbd>${1:KEY}</kbd>$0
endsnippet
snippet "meta(data)?" "Markdown front matter in YAML format" br
---
title: "$1"
date: `!p from datetime import datetime
if not snip.c:
snip.rv=datetime.now().astimezone().strftime("%Y-%m-%d %H:%M:%S%z")`
tags: [$2]
categories: [$3]
---
$0
endsnippet
snippet more "HTML more tag"
<!--more-->
endsnippet
snippet img "Aligned image using HTML tag"
<p align="center">
<img src="${1:URL}" width="${2:800}">
</p>
$0
endsnippet
snippet link "Markdown links"
[$1]($2)$0
endsnippet
post_jump "gen_header(snip)"
snippet "h([1-6])" "Markdown header" br
`!p snip.rv = match.group(1)`
endsnippet
snippet detail "Clickable details" b
<details>
<summary><font size="2" color="red">${1:Click to show the code.}</font></summary>
$2
</details>
endsnippet