concepts/
efun/
#! /usr/local/bin/gawk -f
# a simple example script to convert a manpage into a LaTeX section
# ToDo:
# - preserve line breaks and indentation in Examples
# - generate index entries for the section names
# - generate cross references for the See Also entries.

/^NAME|^CONCEPT/	{ getline line; split(line, name, "[ \t]+");
			  printf("\\section{%s}\n", name[1]);
			  print line "\\\\";
			  next;
			}
/^SYNOPSIS/	{ getline line; name = line;
#		 # gsub(/[ \t]+/," ",name);
#		 # print l;
		  sub(/^[ \t]*[a-z]+[ \t]+\**/,"", name);
		  sub(/\([^)]*\)/,"()", name);
		  sub(/\).*$/,")", name);
#		 # print name;
		  printf("\\section{%s}\n", name);
		  print line "\\\\"
		  next;
		}
/^LAST UPDATE/	{ print "\\subsection*{Last Update}\n"; next; }
/^SEE ALSO/	{ print "\\subsection*{See Also}\n"; next; }
/^[A-Z]+/	{ printf("\\subsection*{%s%s}\n",
			 toupper(substr($1, 1, 1)),
			 tolower(substr($1, 2)));
		  next;
		}
		{ gsub(/[_{}%&]/, "\\\\&");
		  gsub(/[<>]/,"$&$");
##		  gsub("\"","\\quote+\"+"); 
#		  gsub("\{", "\\{");
#		  gsub("\}", "\\}");
		  print $0;
		 }