changeset 346:4f06842488d3

Cat text file of attachment with pretty format with line numbers
author HIROSE Yuuji <yuuji@gentei.org>
date Tue, 25 Oct 2016 22:42:34 +0859
parents 8134b548b385
children 332765572341
files examples/common/default/pretty.m4.txt s4-funcs.sh
diffstat 2 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/common/default/pretty.m4.txt	Tue Oct 25 22:42:34 2016 +0859
@@ -0,0 +1,22 @@
+Content-type: _CONTENT_TYPE_
+
+<html>
+<!-- Default style for pretty-print of text files -->
+<head><title>_TITLE_</title>
+<style type="text/css">
+pre {margin-left: 8.5ex;}
+pre span {counter-increment: linenum; text-align: right; position: relative;}
+pre span:before {
+    position: absolute; right: 0px;
+    background: #ddd; text-align: right; padding: 0 0.5ex;
+    width: 8ex; margin-right: 0.5ex;
+    content: counter(linenum) ":";
+}
+</style>
+<head>
+<body>
+<pre>
+_BODY_
+</pre>
+</body>
+</html>
--- a/s4-funcs.sh	Tue Oct 25 13:11:26 2016 +0859
+++ b/s4-funcs.sh	Tue Oct 25 22:42:34 2016 +0859
@@ -3361,7 +3361,12 @@
       case $charset in
 	ASCII*)	charset=""	;;
       esac
-      ct="text/plain${charset:+; charset=$charset}"
+      ct="text/html${charset:+; charset=$charset}"
+      cat $bin \
+	  | sed 's,^,<span></span>,' \
+	  | _m4 -D_TITLE_="$fn" -D_CONTENT_TYPE_="$ct" \
+		-D_BODY_="syscmd(\`cat')" $layout/pretty.m4.txt
+      exit $?
       ;;
   esac
   contenttype "$ct"

yatex.org