# ----------------------------------------------------------------------------- # txt2etx ; Setext Mark-Up and Indexing script for jgawk Ver1.0b5 # # Copyright (C) 1996-1997 by voyager (voyager@sparc.club.ne.jp) # # ----------------------------------------------------------------------------- # tabstop=4 # ----------------------------------------------------------------------------- BEGIN{ # Global_Variables FS = " " null="" # regexp_discription mySetext_chapter_control = "^@[Cc][Hh][Aa][Pp][Tt][Ee][Rr]=" mySetext_section_control = "^@[Ss][Ee][Cc][Tt][Ii][Oo][Nn]=" myStealth_chapter_control = "^![Cc][Hh][Aa][Pp][Tt][Ee][Rr]=" myStealth_section_control = "^![Ss][Ee][Cc][Tt][Ii][Oo][Nn]=" # label_discription mySetext_chapter_label = "^[^](.)+$" mySetext_section_label = "^[^](.)+$" myStealth_chapter_label = "^=[^=](.)+$" myStealth_section_label = "^-[^-](.)+$" actaJ_chapter_label = "^[PQRSTUVWXO]+ (.)+$" actaJ_section_label = "^\t[PQRSTUVWXO]+ (.)+$" actaE_chapter_label = "^[IVX]+\. (.)+$" actaE_section_label = "^\t[ABCDEFGHIJKLMNOPQRSTUVWXYZ]+\. (.)+$" actaN_chapter_label = "^[1234567890]+[\.][0] (.)+$" actaN_section_label = "^\t[1234567890]+\.[1234567890] (.)+$" # Constant myErrMsg_1 = "*REGEXP Error: Following are Meta charactor in Regular Expression." myErrMsg_2 = " Please use other chatactor for marking-up chapter or section." myErrMsg_3 = " Meta Charactor: \\ \^ \$ \. \[ \] \| \( \) \* \+ \?" myErrMsg_4 = "*Markup Error: NOT Yet difined mark-up charactor for chapter or section." myErrMsg_5 = " DO NOT use space, double space, tab for marking-up." myErrMsg_6 = " **Please re-try marking-up.**" } # Main_Loop ------------------------------------------------------------------- { gsub(/[ @\t]+$/, "", $0) } $0~mySetext_chapter_control || $0~mySetext_section_control \ || $0~myStealth_chapter_control || $0~myStealth_section_control{ if ( $2~/[\\\^\$\.\[\]\|\(\)\*\+\?]/ ) { regexp_error() ; next } if ( $2 == null ) { markup_error() ; next } } $0~mySetext_chapter_control{ mySetext_chapter_label = "^"$2"(.)+$" ; next } $0~mySetext_section_control{ mySetext_section_label = "^"$2"(.)+$" ; next } $0~myStealth_chapter_control{ myStealth_chapter_label = "^"$2"(.)+$" ; next } $0~myStealth_section_control{ myStealth_section_label = "^"$2"(.)+$" ; next } $0~myStealth_chapter_label{ detab() ; stealth() ; setext_chapter() ; next } $0~myStealth_section_label{ detab() ; stealth() ; setext_section() ; next } $0~mySetext_chapter_label{ detab() ; setext_chapter() ; next } $0~mySetext_section_label{ detab() ; setext_section() ; next } $0~actaJ_chapter_label{ detab() ; setext_chapter() ; next } $0~actaJ_section_label{ detab() ; setext_section() ; next } $0~actaE_chapter_label{ detab() ; setext_chapter() ; next } $0~actaE_section_label{ detab() ; setext_section() ; next } $0~actaN_chapter_label{ detab() ; setext_chapter() ; next } $0~actaN_section_label{ detab() ; setext_section() ; next } { print $0 } # implementation -------------------------------------------------------------- function regexp_error(){ printf("%s\n", $0) printf("%s\n", myErrMsg_1) printf("%s\n", myErrMsg_2) printf("%s\n", myErrMsg_3) printf("%s\n", myErrMsg_6) } function markup_error(){ printf("%s\n", $0) printf("%s\n", myErrMsg_4) printf("%s\n", myErrMsg_5) printf("%s\n", myErrMsg_6) } function detab(){ gsub(/^\t/, "", $0) return $0 } function stealth(){ gsub(jsubstr($0, 1, 1), "", $0) return $0 } function setext_chapter( count, myOutStream){ count = 1 while ( count <= length ($0)) { myOutStream = myOutStream "=" count++ } { print myOutStream print $0 print myOutStream myOutStream = null } } function setext_section( count, myOutStream){ count = 1 while ( count <= length ($0)) { myOutStream = myOutStream "-" count++ } { print myOutStream print $0 print myOutStream myOutStream = null } } # -----------------------------------------------------------------------------