summaryrefslogtreecommitdiff
path: root/packages/md.source.sh
diff options
context:
space:
mode:
authorPaul Buetow <git@mx.buetow.org>2021-05-21 05:18:10 +0100
committerPaul Buetow <git@mx.buetow.org>2021-05-21 05:18:10 +0100
commit85df071aa1a5aa73328fdc5969d3ca0ed9df2c08 (patch)
treeec8c11c9e1ad5dfa02c15e57212b239b75e52c87 /packages/md.source.sh
parent9dbd7f008192fd506bf642944232334fad0ed55c (diff)
add readme
Diffstat (limited to 'packages/md.source.sh')
-rw-r--r--packages/md.source.sh63
1 files changed, 0 insertions, 63 deletions
diff --git a/packages/md.source.sh b/packages/md.source.sh
deleted file mode 100644
index e7bfae11..00000000
--- a/packages/md.source.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-# Make a Markdown image.
-md::make_img () {
- local link="$1"; shift
- local descr="$1"; shift
-
- if [ -z "$descr" ]; then
- echo "[![$link]($link)]($link) "
- else
- echo "[![$descr]($link \"$descr\")]($link) "
- fi
-}
-
-# Make a Markdown hyperlink.
-md::make_link () {
- local link="$1"; shift
- local descr="$1"; shift
-
- if ! $GREP -F -q '://' <<< "$link"; then
- link=${link/.gmi/.md}
- fi
- if [[ -z "$descr" ]]; then
- descr="$link"
- fi
-
- echo "[$descr]($link) "
-}
-
-# Convert Gemtext to Markdown.
-md::fromgmi () {
- while IFS='' read -r line; do
- case "$line" in
- '=> '*)
- generate::make_link md "$line"
- ;;
- *)
- echo "$line"
- ;;
- esac
- done
-}
-
-# Test the Markdown package.
-md::test () {
- local line='=> https://example.org'
- assert::equals "$(generate::make_link md "$line")" \
- '[https://example.org](https://example.org) '
-
- line='=> index.md'
- assert::equals "$(generate::make_link md "$line")" \
- '[index.md](index.md) '
-
- line='=> http://example.org Description of the link'
- assert::equals "$(generate::make_link md "$line")" \
- '[Description of the link](http://example.org) '
-
- line='=> http://example.org/image.png'
- assert::equals "$(generate::make_link md "$line")" \
- '[![http://example.org/image.png](http://example.org/image.png)](http://example.org/image.png) '
-
- line='=> http://example.org/image.png Image description'
- assert::equals "$(generate::make_link md "$line")" \
- '[![Image description](http://example.org/image.png "Image description")](http://example.org/image.png) '
-}