open|load) file="$1"
cat "$file" || return 1
;;
- check|contains) key="$(STRING "$1")" val=''
+ check|contains) key="$(STRING "$1")" seq="${2:-1}"
val="${data##*"${BR}${key}" }" val="${val%%"${BR}"*}"
+ [ "$val" = '' ] && return 1 || val="${val} "
+ while [ $seq -gt 1 ]; do
+ seq=$((seq - 1)) val="${val#* }"
+ done
[ "$val" = '' ] && return 1
;;
count) key="$(STRING "$1")" val='' seq=0
delete|remove) key="$(STRING "$1")"
val="${data#*"${BR}${key}" *"${BR}"}"
key="${data%"${BR}${key}" *"${BR}"*}"
- [ "${key}${BR}${val}" = "${data}" ] && return 1
- printf '%s' "${key#"${BR}"}${BR}${val%"${BR}"}"
+ if [ "${val}" = "${data}" ]; then
+ printf %s\\n "${data}"
+ return 1
+ else
+ printf '%s' "${key#"${BR}"}${BR}${val%"${BR}"}"
+ fi
;;
set|store) key="$(STRING "$1")" val=""
shift 1
# Meant to support all features of John Grubers basic Markdown
# + a number of common extensions, mostly inspired by Pandoc Markdown
-# Copyright 2021 - 2023 Paul Hänsch
+# Copyright 2021 - 2024 Paul Hänsch
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
gsub(/(^ | $)/, "", attrib);
if ( match(code, "(^|\n)" guard "+(\n|$)" ) && attrib ) {
len = RLENGTH; st = RSTART;
- ret = ret "<pre><code class=\"" attrib "\">" HTML( substr(code, 1, st - 1) ) "</code></pre>\n";
+ ret = ret "<pre class=\"" attrib "\"><code class=\"" attrib "\">" \
+ HTML( substr(code, 1, st - 1) ) "</code></pre>\n";
block = substr( code, st + len );
continue;
*formatted*
but ­ <escaped>
```' \
-'<pre><code class="tag code">fenced code will
+'<pre class="tag code"><code class="tag code">fenced code will
not be
*formatted*
but &shy; <escaped></code></pre>' \
</ul>
<hr>
-<pre><code class="blue">Fenced Code Block
+<pre class="blue"><code class="blue">Fenced Code Block
# with verbatim Text
`and an attribute`</code></pre>
<div class="line-block">The limerick packs laughs anatomical<br>