15 lines
		
	
	
	
		
			320 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			15 lines
		
	
	
	
		
			320 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/bin/zsh
 | |
| #dep:mdcat iconv chardetect
 | |
| 
 | |
| #encoding=$(file -i "$1" | sed "s/.*charset=\(.*\)$/\1/")
 | |
| if [[ $2 ]]; then
 | |
| 	encoding=$2
 | |
| else
 | |
| 	encoding='utf-8'
 | |
| 	#encoding=$(chardetect "$1" | grep -op '(?<=: )\s*')
 | |
| fi
 | |
| if [[ $encoding != 'UTF-8' ]]; then
 | |
| 	iconv -f $encoding -t 'utf-8' < "$1" | mdcat /dev/stdin
 | |
| else
 | |
| 	mdcat $1
 | |
| fi
 | 
