global !p def smart_space(next_str, auto_str=" ", loose=False): next_word = "" if next_str: if loose == True: next_word = auto_str elif next_str[0] in [",", ".", "-", "!", "?", " "]: next_word = auto_str return next_word endglobal # Text formatting snippet "h(\d)" "Quick header snippet" biw `!p header_level = int(match.group(1)) legit_header_level = True if header_level >= 1 and header_level <= 6 else False snip.rv = "#" * header_level if legit_header_level else "" ` $0 endsnippet snippet tt "Monospace" biw `$1` $0 endsnippet snippet hl "Highlighted text" biw #$1# $0 endsnippet snippet a "Hyperlink" iw ${1:}[${2:}] $0 endsnippet snippet sp "Superscript" biw ^$1^ $0 endsnippet snippet sb "Subscript" biw ~$1~ $0 endsnippet snippet dt "Definition term" bi ${1:}:: ${2:} $0 endsnippet snippet ul "Unordered list item" bi * ${1:} $0 endsnippet snippet ol "Ordered list item" bi . ${1:} $0 endsnippet snippet -ol "Reversed ordered list (use it only once in a list)" bi [%reversed] . ${1:} endsnippet snippet bquote "Blockquote" bi ---- $1 ---- $0 endsnippet snippet src "Source code listings" bi [source,${1:}] ---- ${2:} ---- $0 endsnippet snippet "-table (\d+)-" "Make a quick table" bir [cols="`!p snip.rv = match.group(1)`*"] |=== $1 |=== $0 endsnippet # Multimedia blocks snippet figure "Image block with caption" bi .${2:} image::${1:}[$2, ${3:width=100%,height=100%}] $0 endsnippet snippet -figure "Inline image" i image:${1:}[${2}] $0 endsnippet snippet video "Video block" bi video::${1:}[$2] $0 endsnippet snippet youtube "YouTube video block" bi video::${1:}[youtube] $0 endsnippet snippet vimeo "Vimeo video block" bi video::${1:}[vimeo] $0 endsnippet snippet audio "Audio block" bi audio::${1:}[`!p snip.rv=smart_space(t[2], "options=", loose=True)`$2] $0 endsnippet # Other features snippet incl "Include document" bi include::${1:}[${2:}] $0 endsnippet snippet oblock "Open block" bi -- $1 -- $0 endsnippet snippet sidebar "Sidebar as an open block" bi [sidebar] .${1:} -- $2 -- $0 endsnippet snippet abstract "Abstract block" bi [abstract] == ${1:Summary} $0 endsnippet