Plan 9 from Bell Labs’s /usr/web/sources/contrib/josh/rc/markhpage

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

# NAME
# 	markhpage - convert Markdown file to HTML page
# SYNOPSIS
# 	markhpage [-c cssuri] [-t title] [ file ]
# DESCRIPTION
# 	The rc script markhpage uses markdown(1) to interpret
# 	text in file (or standard input) and inserts its HTML
#	representation into the body element of a complete
#	HTML document on the standard output. Under -c, the
#	path or URL cssuri is inserted as a stylesheet <link> in
# 	the output <head>. The (possibly quoted) title argument to -t
#	gives a <title> for the output.

rfork en

flagfmt='c cssuri,t title'
args='[file]'
if(! ifs=() eval `{aux/getflags $*} || ! ~ $#* 0 1){
	aux/usage
	exit usage
}

if(~ $#* 1)
	srcf=$1

title=TITLE
if(~ $#flagt 1)
	title=$flagt
if not if(~ $#srcf 1)
	title=`{basename $srcf}

echo '<!DOCTYPE html>'
echo '<html dir="ltr" lang="en-US">'
echo '	<head>'
echo '		<meta charset="UTF-8" />'
echo '		<title>'^$title^'</title>'
if(~ $#flagc 1)
	echo '		<link rel="stylesheet" type="text/css" href="'^$flagc^'" />'
echo '	</head>'
echo '	<body>'
if(! ~ $#srcf 1)
	srcf=()
markdown $srcf
echo '	</body>'
echo '</html>'

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.