#!/bin/bash ########################################################################## # File Name : md2html.sh # Encoding : utf-8 # Author : We-unite # Email : weunite1848@gmail.com # Created Time : 2023-12-15 ########################################################################## origin=$1 # 源文件名 src="."$origin # 源文件的复制 dst=${origin%.*}".html" # 目标文件 if [ $# -ne 2 ] || [ ${origin##*.} != "md" ]; then echo "Usage: $0 " exit 1 elif [ ! -f $origin ]; then echo "Error: $1 does not exist" exit 1 fi cp $origin $src pandoc --no-highlight --mathjax=none -s $src -o $dst --metadata title="$2" rm $src # 处理多行代码块,将
替换为
 
sed -i -E ':a;N;$!ba;s|]*class="([^"]+)"[^>]*>[[:space:]]*]*>|
|g' $dst
sed -i '/