scripts

scripts
git clone git://git.wimdupont.com/scripts.git
Log | Files | Refs | README | LICENSE

commit 4c894b28254d65ef9099949513a847f64d343c30
parent e2b61f12719e3d621553c88eacee9467aeed52e2
Author: Wim Dupont <wim@wimdupont.com>
Date:   Tue, 16 Jul 2024 23:07:28 +0200

added md2html

Diffstat:
MREADME.adoc | 22++++++++++++----------
Dbin/adoc | 25-------------------------
Abin/htmlconv | 34++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/README.adoc b/README.adoc @@ -2,16 +2,6 @@ For certain scripts I've added a "requires" section to specify software which is less likely to be installed by default that the script uses. Most of these can be changed with alternatives by choice if willing to edit the script. :toc: -== link:bin/adoc[adoc] - -Generates html for asciidoc file and opens in browser or refreshes if current tab has -the html filename in URL. - -.Requires: - -* https://github.com/astrand/xclip[xclip] -* https://github.com/jordansissel/xdotool[xdotool] - == link:bin/askpass[askpass] Prompts for sudo password - using Zenity GUI only when using display server. Meant to be used with addition to the sudo.conf: @@ -81,6 +71,18 @@ Adds, commits and pushes git changes to all remotes after confirmation. The "pus pushall = !git remote | xargs -L1 git push ---- +== link:bin/htmlconv[htmlconv] + +Generates html for asciidoc and markdown files and opens in browser or refreshes if current tab has +the html filename in URL. + +.Requires: + +* https://github.com/astrand/xclip[xclip] +* https://github.com/jordansissel/xdotool[xdotool] +* https://github.com/asciidoctor/asciidoctor.git[asciidoctor] +* https://github.com/mity/md4c.git[md4c] + == link:bin/mpvd[mpvd] Uses dmenu to browse through music directory, including option to shuffle when choosing to play a directory. diff --git a/bin/adoc b/bin/adoc @@ -1,25 +0,0 @@ -#!/bin/bash - -filename="$1" - -test -z "${filename}" && echo "Please give file as program argument." >&2 && exit 1 - -filename="${filename%.*}" - -readonly BROWSER=$(xdg-settings get default-web-browser | xargs echo `sed 's/.desktop//'`) -readonly ADOC_FILE="$filename.adoc" -readonly OUTPUT_FILE="$filename.html" - -test ! -f "$ADOC_FILE" && echo "\"$ADOC_FILE\" not found." >&2 && exit 1 - -asciidoctor -o "$OUTPUT_FILE" "$ADOC_FILE" - -window_id=$(xdotool search --onlyvisible --class "$BROWSER") - -if [ -n "$window_id" ]; then - xdotool key --window $window_id ctrl+l ctrl+c Escape - name=$(xclip -o -selection clipboard) - [[ $name == *"$OUTPUT_FILE" ]] && xdotool key --window $window_id F5 && exit 0 -fi - -$BROWSER $OUTPUT_FILE & diff --git a/bin/htmlconv b/bin/htmlconv @@ -0,0 +1,34 @@ +#!/bin/bash + +filearg="$1" + +test -z "${filearg}" && echo "Please give file as program argument." >&2 && exit 1 + +filename="${filearg%.*}" +extension="${filearg##*.}" + +readonly BROWSER=$(xdg-settings get default-web-browser | xargs echo `sed 's/.desktop//'`) +readonly MARKUP_FILE="$filename.$extension" + +readonly OUTPUT_FILE="$filename.html" + +test ! -f "$MARKUP_FILE" && echo "\"$MARKUP_FILE\" not found." >&2 && exit 1 + +case "$extension" in + "adoc"|"asciidoc") + asciidoctor -o "$OUTPUT_FILE" "$MARKUP_FILE";; + "md") + md2html -f -o "$OUTPUT_FILE" "$MARKUP_FILE";; + *) + echo "$extension is not supported" >&2 && exit 1;; +esac + +window_id=$(xdotool search --onlyvisible --class "$BROWSER") + +if [ -n "$window_id" ]; then + xdotool key --window $window_id ctrl+l ctrl+c Escape + name=$(xclip -o -selection clipboard) + [[ $name == *"$OUTPUT_FILE" ]] && xdotool key --window $window_id F5 && exit 0 +fi + +$BROWSER $OUTPUT_FILE &