#!/usr/bin/awk -f BEGIN { FS="\n" italic=0; bold=0; underline=0 } { for(i=1; i<=NF; i++) { if (substr($0,1) ~ /[.]/) { printf "macr "; print substr($0,2) } else { printf "text "; split($i, chars, "") for (x=1; x <= length($i); x++) { if (substr(chars[x],1) ~ /\\/) { x++ printf("%s", chars[x]) } else if (substr(chars[x],1) ~ /\*/) { if (italic == 0) { italic=1; printf("\nsita\ntext ") } else { italic=0 printf("\neita\ntext ") } } else if (substr(chars[x],1) ~ /&/) { if (bold == 0) { bold=1; printf("\nsbld\ntext ") } else { bold=0 printf("\nebld\ntext ") } } else if (substr(chars[x],1) ~ /_/) { if (underline == 0) { underline=1; printf("\nsund\ntext ") } else { underline=0 printf("\neund\ntext ") } } else if (substr(chars[x],1) ~ /-/) { if (underline == 0) { underline=1; printf("\nsstk\ntext ") } else { underline=0 printf("\nestk\ntext ") } } else { printf("%s", chars[x]) } } printf("\n") } } } END { printf("EOF") }