Make 'markdown' a shell script wrapper
This commit is contained in:
parent
5e3b41029f
commit
4ebb93dcac
3 changed files with 30 additions and 1 deletions
25
roles/home-cli/files/markdown.sh
Normal file
25
roles/home-cli/files/markdown.sh
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
command -v cmark >/dev/null || (echo "cmark: command not found" >&2 && exit 1)
|
||||||
|
test -n "$2" || (echo "Usage: $0 \"Document title\" filename1 [filename2...]" >&2 && exit 1)
|
||||||
|
cat << __EOF__
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>$1</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
width: 26cm;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
__EOF__
|
||||||
|
shift # Drop the first argument (document title).
|
||||||
|
cmark --to html --nobreaks --unsafe --smart --validate-utf8 $*
|
||||||
|
cat << __EOF__
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
__EOF__
|
|
@ -243,7 +243,6 @@ alias isodate="date +'Date: %Y-%m-%d%nTime: %H:%M:%S%nZone: %:z%n%nWeek: %G-W%V-
|
||||||
alias la="ls -a"
|
alias la="ls -a"
|
||||||
alias ll="ls -l"
|
alias ll="ls -l"
|
||||||
alias ls="command ls -F"
|
alias ls="command ls -F"
|
||||||
alias markdown="cmark --to html --nobreaks --unsafe --smart --validate-utf8"
|
|
||||||
alias now="date +%Y%m%dT%H%M%S%z"
|
alias now="date +%Y%m%dT%H%M%S%z"
|
||||||
alias nowh="date +%Y-%m-%dT%H:%M:%S%:z"
|
alias nowh="date +%Y-%m-%dT%H:%M:%S%:z"
|
||||||
alias nowu="date -u +%Y%m%dT%H%M%SZ"
|
alias nowu="date -u +%Y%m%dT%H%M%SZ"
|
||||||
|
|
|
@ -97,3 +97,8 @@
|
||||||
state: link
|
state: link
|
||||||
force: yes
|
force: yes
|
||||||
follow: false
|
follow: false
|
||||||
|
- name: Create $HOME/.local/bin/markdown
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: markdown.sh
|
||||||
|
dest: "{{ ansible_env.HOME }}/.local/bin/markdown"
|
||||||
|
mode: '0755'
|
||||||
|
|
Loading…
Reference in a new issue