forked from Spark/builder
old trash
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
e96427f2ad
commit
d07c3748a9
49
syntax
49
syntax
|
@ -1,49 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
_highlight() {
|
||||
declare -n syn=$1
|
||||
|
||||
if [[ "$syn" ]]; then
|
||||
exec highlight --force --inline-css -f -I -O xhtml -S "$syn" 2>/dev/null
|
||||
else
|
||||
# echo " :cgit: No syntax type provided."
|
||||
exec cat
|
||||
fi
|
||||
}
|
||||
|
||||
file_name=$1
|
||||
file_extension="${file_name##*.}"
|
||||
|
||||
if ! [[ "$file_name" == "$file_extension" ]]; then
|
||||
case "$file_extension" in
|
||||
(md) exec cmark;;
|
||||
(bash|zsh) syntax='sh';;
|
||||
(*) syntax=$file_extension;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$file_name" in
|
||||
(Makefile) syntax='makefile';;
|
||||
(PKGBUILD) syntax='sh';;
|
||||
esac
|
||||
|
||||
# Read and output the first line
|
||||
read -r
|
||||
|
||||
# Set syntax if the first line is a shebang
|
||||
if [[ "$REPLY" =~ ^'#!' ]]; then
|
||||
case "$REPLY" in
|
||||
(*sh) syntax='sh';;
|
||||
(*ruby*) syntax='ruby';;
|
||||
esac
|
||||
fi
|
||||
|
||||
{
|
||||
# Print the first line
|
||||
printf '%s\n' "$REPLY"
|
||||
|
||||
# Read and output everything
|
||||
while read -r; do
|
||||
printf '%s\n' "$REPLY"
|
||||
done
|
||||
} | _highlight syntax
|
Loading…
Reference in New Issue
Block a user