--- plain2-2.54p1.orig/doc/Beginning.tex +++ plain2-2.54p1/doc/Beginning.tex @@ -9,7 +9,7 @@ } \medskip -{\large \dg\bf\addtocounter{sectionx}{1}\setcounter{subsectionx}{0}{\thesectionx} ようこそ plain2 の世界へ} +{\large \bf\addtocounter{sectionx}{1}\setcounter{subsectionx}{0}{\thesectionx} ようこそ plain2 の世界へ} \medskip \par TeXなんて書けない,読めない.そんなユーザの声に応える @@ -24,10 +24,10 @@ \ \ \ \ \ \ \ \ ...\\ \%~xdvi~example.dvi\\ } -\endlist} +\mbox{}\endlist} \medskip -{\normalsize \dg\bf\addtocounter{subsectionx}{1}\setcounter{subsubsectionx}{0}{\thesectionx}.{\thesubsectionx} 多様なリスト} +{\normalsize \bf\addtocounter{subsectionx}{1}\setcounter{subsubsectionx}{0}{\thesectionx}.{\thesubsectionx} 多様なリスト} \medskip \par いろいろなリストが書けます.ネストもできます. @@ -45,12 +45,12 @@ \medskip \end{itemize} -{\normalsize \dg\bf\addtocounter{subsectionx}{1}\setcounter{subsubsectionx}{0}{\thesectionx}.{\thesubsectionx} テーブルと線画の機能} +{\normalsize \bf\addtocounter{subsectionx}{1}\setcounter{subsubsectionx}{0}{\thesectionx}.{\thesubsectionx} テーブルと線画の機能} \medskip \par plain2ならテーブルも簡単に書けます ~\\ -\begin{center} +\mbox{}\begin{center} \begin{tabular}{|c|c|c|c|} \hline & べた書き & マークアップ & ワープロ\\ @@ -63,7 +63,7 @@ \end{center} \medskip ~\\ -\begin{center} +\mbox{}\begin{center} \begin{picture}(288,120)(0,0) \put(3,97){簡単な絵くらいは書けます.} \thinlines --- plain2-2.54p1.orig/doc/Example_adjust2.tex +++ plain2-2.54p1/doc/Example_adjust2.tex @@ -19,5 +19,5 @@ cc $-$DKANJI $-$DPICTURE $-$DBSD $-$DDEBUG $-$target sun4 $-$c hint.c\\ cc $-$DKANJI $-$DPICTURE $-$DBSD $-$DDEBUG $-$target sun4 $-$c justify.c\\ cc $-$DKANJI $-$DPICTURE $-$DBSD $-$DDEBUG $-$target sun4 $-$c texout.c\\ -\endlist} +\mbox{}\endlist} }\end{minipage}}\\ --- plain2-2.54p1.orig/doc/Makefile +++ plain2-2.54p1/doc/Makefile @@ -46,7 +46,7 @@ Example_adjust2.tex PRTGIF=prtgif+ -PLAIN2=../src/plain2 +PLAIN2=../src/plain2 -tstyle=a4j -jverb VERBTEXFILES= plain2.ps: plain2.dvi @@ -63,7 +63,10 @@ rm -f ${SAMPLES} ${OTHERFILES} plain2.tex plain2.dvi plain2.ps \ plain2.toc plain2.aux plain2.log -title_a47.tex title_shounin.tex: +title_a47.tex: title_a47.raw + $(PLAIN2) -tex -fexampl_left $< > $@ + +title_shounin.tex: title_shounin.raw $(PLAIN2) -tex -fexampl_left $< > $@ table_kanji.tex: table_kanji.pln --- plain2-2.54p1.orig/doc/Tgif_doc.tex +++ plain2-2.54p1/doc/Tgif_doc.tex @@ -2,11 +2,11 @@ \hspace*{2cm}\framebox[13.5cm][l]{~~\begin{minipage}{12cm} \setcounter{sectionx}{0}{\small\baselineskip=10pt -{\large \dg\bf\addtocounter{sectionx}{1}\setcounter{subsectionx}{0}{\thesectionx} tgif+ の利用} +{\large \bf\addtocounter{sectionx}{1}\setcounter{subsectionx}{0}{\thesectionx} tgif+ の利用} \medskip \par tgif+ で書いた絵を次のようにして -べた書き文書に取り込みます.\\ +べた書き文書に取り込みます.\\\mbox{} \medskip --- plain2-2.54p1.orig/doc/exampl.p2 +++ plain2-2.54p1/doc/exampl.p2 @@ -7,6 +7,8 @@ EXAM_BEGIN "{\\baselineskip=#1pt\n\\tt\\obeylines\\catcode` =11\n" EXAM_END "}\n", +JEXAM_BEGIN "{\\baselineskip=#1pt\n\\tt\\obeylines\\catcode` =11\n" +JEXAM_END "}\n", BOLD_BEGIN, "{\\bf " SECTION_1 "\n{\\normalsize \\bf\\addtocounter{sectionx}{1}\ --- plain2-2.54p1.orig/doc/exampl_star.p2 +++ plain2-2.54p1/doc/exampl_star.p2 @@ -7,6 +7,8 @@ EXAM_BEGIN "{\\baselineskip=#1pt\n\\tt\\obeylines\\catcode` =11\n" EXAM_END "}\n", +JEXAM_BEGIN "{\\baselineskip=#1pt\n\\tt\\obeylines\\catcode` =11\n" +JEXAM_END "}\n", SECTION_1 "\n\\section*{@1}\n" SECTION_2 "\n\\subsection*{@1}\n" --- plain2-2.54p1.orig/doc/guide.p2 +++ plain2-2.54p1/doc/guide.p2 @@ -1,4 +1,10 @@ -DOC_BEGIN "\\documentstyle[epsf]{jarticle}\n\ +DOC_BEGIN "\ + \\newif\\ifNTT\\NTTfalse\n\ + \\ifx\\gtfam\\undefined\\ifx\\gtfamily\\undefined\\NTTtrue\\fi\\fi\n\ + \\ifNTT\\documentstyle[$2,epsf]{j-article}\n\ + \\else\\documentstyle[$3,epsf]{jarticle}\\fi\n\ + \\advance\\textwidth1.4cm \\advance\\oddsidemargin-.7cm\n\ + \\advance\\textheight2cm \\advance\\topmargin-1cm\n\ \\setcounter{secnumdepth}{6}\n\ \\setcounter{tocdepth}{6}\n\ \\topsep=0.1cm\n\ @@ -15,12 +21,12 @@ \\let\\@mkboth=\\@gobbletwo\n\ \\def\\@evenhead{}\\def\\@evenfoot{}%\n\ \\def\\@oddhead{\\makebox[\\textwidth]%\n\ - {\\ plain2ユーザガイド(r2.5)\\hfill\\thesection\\ 章}}%\n\ + {plain2ユーザガイド(r2.5)\\hfill\\thesection\\ 章}}%\n\ \\def\\@oddfoot{\\makebox[\\textwidth]%\n\ - {\\rightmark\\leaders\\hbox{\\tiny ~plain2}\\hfill}\\ \\thepage}}\n\ - \\@ifundefined{jintercharskip}{%\n\ - \\def\\p2zerointerskip{\\kanjiskip=0cm}}{%\n\ - \\def\\p2zerointerskip{\\jintercharskip=0cm}}\n\ + {\\rightmark\\leaders\\hbox{\\tiny ~plain2}\\hfill\\ \\thepage}}}\n\ + %\\@ifundefined{jintercharskip}{%\n\ + % \\def\\p2zerointerskip{\\kanjiskip=0cm}}{%\n\ + % \\def\\p2zerointerskip{\\jintercharskip=0cm}}\n\ \\makeatother\n" SECTION_1 "\n\ \\section{@1}\ --- plain2-2.54p1.orig/doc/plain2.pln +++ plain2-2.54p1/doc/plain2.pln @@ -377,6 +377,7 @@ [[R \input{picture_intro.tex} +\mbox{} % to avoid `Underfull \hbox (badness 10000)' ]]R 3. plain2 コマンド @@ -2270,7 +2271,7 @@ "tgif_fig.eps"とします. [[R ~\\ -\begin{center} +\mbox{}\begin{center} \epsfile{file=tgif_win.eps}\\ \end{center} ]]R --- plain2-2.54p1.orig/doc/pln2raw +++ plain2-2.54p1/doc/pln2raw @@ -9,22 +9,25 @@ LNUM= while getopts n c do - case $c in + case "$c" in n) LNUM="on" shift ;; esac done -echo '{\list{}{\leftmargin=0.5in}\item[]' -echo '{\baselineskip=10pt' -echo '\p2zerointerskip' -echo '\begin{verbatim}' +cat <<'EOF' +{\list{}{\leftmargin=0.5in}\item[] +{\par\baselineskip=10pt +\begin{jverbatim} +EOF if [ "$LNUM" = "on" ] then - awk '{printf "%3d: %s\n",NR,$0}' $1 + awk '{printf "%3d: %s\n",NR,$0}' ${1+"$@"} else - cat $1 + cat ${1+"$@"} fi | expand -echo '\end{verbatim}}' -echo '\endlist}' +cat <<'EOF' +\end{jverbatim}\par} +\endlist} +EOF --- plain2-2.54p1.orig/doc/table_adjust.texv +++ plain2-2.54p1/doc/table_adjust.texv @@ -1,7 +1,7 @@ {\list{}{\leftmargin=0.5in}\item[] {\baselineskip=10pt -\jintercharskip=0cm -\begin{verbatim} +\par +\begin{jverbatim} % plain2 -tex -nopre table_adjust.pln \par 次のように枠のないテーブルは, @@ -12,5 +12,5 @@ 明示的に指定する "[[T"と"]]T" そのまま我慢する 多分例示になる \endlist} -\end{verbatim}} +\end{jverbatim}\par} \endlist} --- plain2-2.54p1.orig/lib/jbook.p2 +++ plain2-2.54p1/lib/jbook.p2 @@ -1,9 +1,13 @@ # # jbookスタイルを使う # -# $Id: jbook.p2,v 1.1 1993/02/25 19:40:32 uchida Exp $ +# # -DOC_BEGIN "\\documentstyle[]{jbook}\n\ +DOC_BEGIN "\ +\\newif\\ifNTT\\NTTfalse\n\ +\\ifx\\gtfam\\undefined\\ifx\\gtfamily\\undefined\\NTTtrue\\fi\\fi\n\ +\\ifNTT\\documentstyle[$2]{j-book}\n\ +\\else\\documentstyle[$3]{jbook}\\fi\n\ \\setcounter{secnumdepth}{6}\n\ \\setcounter{tocdepth}{6}\n\ \\topsep=0.1cm\n\ --- plain2-2.54p1.orig/src/Makefile +++ plain2-2.54p1/src/Makefile @@ -10,23 +10,23 @@ SHELL=/bin/sh -DEFINES=-DKANJI -DPICTURE +DEFINES=-DKANJI -DPICTURE -DHTML -#CC=gcc -#CFLAGS= -fwritable-strings ${DEFINES} -DBSD -DDEBUG +CC=gcc +CFLAGS= -fwritable-strings ${DEFINES} -DBSD -DDEBUG -O2 -s -CC=cc -CFLAGS= -O ${DEFINES} -DBSD -DDEBUG +#CC=cc +#CFLAGS= -O -fwritable-strings ${DEFINES} -DBSD -DDEBUG #CFLAGS= -g ${DEFINES} -DDEBUG SRCS=plain2.c readfile.c analyze.c miscutil.c\ section.c example.c list.c plaintxt.c table.c spacing.c\ headfoot.c hint.c picture.c justify.c ftitle.c\ - roffout.c texout.c title.c output.c renumout.c macro.c + roffout.c texout.c title.c output.c renumout.c macro.c htmlout.c OBJS_NOKANJI=plain2.o readfile.o miscutil.o\ section.o example.o list.o plaintxt.o spacing.o\ headfoot.o hint.o justify.o\ - texout.o output.o renumout.o macro.o + texout.o output.o renumout.o macro.o htmlout.o # # Following files contain Kanji characters(8bit) in EUC code. # @@ -96,3 +96,4 @@ output.o: plain2.h picture.h macro.h renumout.o: plain2.h macro.o: plain2.h macro.h +htmlout.o: plain2.h macro.h --- plain2-2.54p1.orig/src/headfoot.c +++ plain2-2.54p1/src/headfoot.c @@ -282,6 +282,8 @@ } /* * Build and print Header/Footer string for troff output + * (Note: This function returns a pointer to a static buffer which will be + * re-written at next call) */ extern struct transTable roffTransQ[]; char * @@ -290,7 +292,7 @@ { char left[HF_MAXLEN]; char right[HF_MAXLEN]; - char ret[64]; + static char ret[64]; if (build(pat1, pat2, left, right)) { (void)strcpy(ret, codeCvt(textQuote(left, roffTransQ))); (void)strcat(ret, "\\\\\\\\nP"); --- plain2-2.54p1.orig/src/hint.c +++ plain2-2.54p1/src/hint.c @@ -47,7 +47,7 @@ } hp++; } - return NULL; + return 0; } hint(begin, end) int begin; --- plain2-2.54p1.orig/src/macro.c +++ plain2-2.54p1/src/macro.c @@ -15,12 +15,14 @@ #define MACRO_SUFFIX ".p2" struct macNames macNames[] = { - "DOC_BEGIN", M_DOC_BEGIN, "#$", + "DOC_BEGIN", M_DOC_BEGIN, "#$$", "DOC_END", M_DOC_END, "", "PLAIN_BEGIN", M_PLAIN_BEGIN, "", "PLAIN_END", M_PLAIN_END, "", "EXAM_BEGIN", M_EXAM_BEGIN, "#", "EXAM_END", M_EXAM_END, "", + "JEXAM_BEGIN", M_JEXAM_BEGIN, "#", + "JEXAM_END", M_JEXAM_END, "", "SET_SEC", M_SET_SEC, "#$", "APPENDIX", M_APPENDIX, "$", "APDX_BEGIN", M_APDX_BEGIN, "", @@ -86,12 +88,18 @@ struct cmpMac *mip, *new_mip; int def_type; mip = (struct cmpMac *)malloc(sizeof(struct cmpMac)); + if(mip == NULL){ /* Add Nide */ + malloc_error: + fprintf(stderr, "PANIC(malloc in macroParse)\n"); + exit (2); + } mip->cmac_next = NULL; mip->cmac_argnum = -1; mip->cmac_str = s; while (*s) { if (isdigit(*(s+1)) && (def_type = atype(*s)) != ATYPE_VOID) { new_mip=(struct cmpMac *)malloc(sizeof(struct cmpMac)); + if(new_mip == NULL) goto malloc_error; /* Add Nide */ mip->cmac_next = new_mip; new_mip->cmac_next = NULL; new_mip->cmac_argtype = *s; @@ -369,8 +377,7 @@ } if (ret == -1) continue; - s = (char *)malloc(strlen(defstr)); - strcpy(s, defstr); + s = strsave(defstr); /* Changed Nide (but don't we need free?)*/ outMacro[macroNum] = macroParse(s, macroNum, s); } fclose(fd); --- plain2-2.54p1.orig/src/macro.h +++ plain2-2.54p1/src/macro.h @@ -10,29 +10,31 @@ #define M_PLAIN_END 3 #define M_EXAM_BEGIN 4 #define M_EXAM_END 5 -#define M_SET_SEC 6 -#define M_APPENDIX 7 -#define M_APDX_BEGIN 8 -#define M_BLANK 9 -#define M_PAGE 10 -#define M_NEWLINE 11 -#define M_CENTER_BEGIN 12 -#define M_CENTER_END 13 -#define M_RIGHT_BEGIN 14 -#define M_RIGHT_END 15 -#define M_INDENT 16 -#define M_INDENT0 17 -#define M_TITLE 18 -#define M_FOOTN_BEGIN 19 -#define M_FOOTN_END 20 -#define M_REFER_BEGIN 21 -#define M_REFER_END 22 -#define M_BOLD_BEGIN 23 -#define M_BOLD_END 24 -#define M_INDEX_BEGIN 25 -#define M_INDEX_END 26 -#define M_SECTION_END 27 -#define M_SECTION_1 28 +#define M_JEXAM_BEGIN 6 /* Inserted by Nide */ +#define M_JEXAM_END 7 /* Inserted by Nide */ +#define M_SET_SEC 8 +#define M_APPENDIX 9 +#define M_APDX_BEGIN 10 +#define M_BLANK 11 +#define M_PAGE 12 +#define M_NEWLINE 13 +#define M_CENTER_BEGIN 14 +#define M_CENTER_END 15 +#define M_RIGHT_BEGIN 16 +#define M_RIGHT_END 17 +#define M_INDENT 18 +#define M_INDENT0 19 +#define M_TITLE 20 +#define M_FOOTN_BEGIN 21 +#define M_FOOTN_END 22 +#define M_REFER_BEGIN 23 +#define M_REFER_END 24 +#define M_BOLD_BEGIN 25 +#define M_BOLD_END 26 +#define M_INDEX_BEGIN 27 +#define M_INDEX_END 28 +#define M_SECTION_END 29 +#define M_SECTION_1 30 #define M_SECTION_2 (M_SECTION_1 + 1) #define M_SECTION_3 (M_SECTION_1 + 2) #define M_SECTION_4 (M_SECTION_1 + 3) --- plain2-2.54p1.orig/src/output.c +++ plain2-2.54p1/src/output.c @@ -1,9 +1,12 @@ /* * Copyright (C) 1991,1992,1993 NEC Corporation. */ +/* + * modify by k-chinen@is.aist-nara.ac.jp, 1994 + */ #ifndef lint -static char rcsid[] = - "$Id: output.c,v 2.17 1994/04/19 10:16:51 uchida Exp $ (NEC)"; + + #endif #include @@ -19,9 +22,11 @@ ?(textp)->body\ :(textp)->body+(textp)->indent) #endif + /* * Definition of Output driver routines. */ +/***** roff *****/ int roffPlain(), roffExample(), roffListBlock(), roffDlistItem(), roffListItem(), roffRawText(), roffSpace(), @@ -33,6 +38,8 @@ roffTable(), roffFTitle(), roffTitle(); char *roffQuote1(), *roffQuote2(); + +/***** TeX *****/ int texPlain(), texExample(), texListBlock(), texDlistItem(), texListItem(), texRawText(), texSpace(), @@ -44,6 +51,20 @@ texTable(), texFTitle(), texTitle(); char *texQuote1(), *texQuote2(); +#ifdef HTML +/***** HTML *****/ +int htmlPlain(), htmlExample(), + htmlListBlock(), htmlDlistItem(), + htmlListItem(), htmlRawText(), htmlSpace(), + htmlCapsule(), htmlComment(), +#ifdef PICTURE + htmlPictureBlock(), htmlPicLine(), htmlPicArc(), + htmlPicText(), htmlLineWidth(), +#endif + htmlTable(), htmlFTitle(), htmlTitle(); +char *htmlQuote1(), *htmlQuote2(); +#endif + struct outDev roffPut = { roffPlain, roffExample, roffListBlock, roffDlistItem, @@ -69,9 +90,32 @@ texTable, texFTitle, texTitle, texQuote1, texQuote2, }; + +#ifdef HTML +struct outDev htmlPut = { + htmlPlain, htmlExample, + htmlListBlock, htmlDlistItem, + htmlListItem, htmlRawText, htmlSpace, + htmlCapsule, htmlComment, +#ifdef PICTURE + htmlPictureBlock, htmlPicLine, htmlPicArc, + htmlPicText, htmlLineWidth, +#endif + htmlTable, htmlFTitle, htmlTitle, + htmlQuote1, htmlQuote2, +}; +#endif + + +#ifdef HTML +/* + * Output text in (roff, TeX or HTML) format. + */ +#else /* * Output text in (roff or TeX) format. */ +#endif struct inline_mark { char il_mark; @@ -408,12 +452,19 @@ + texts[begin]->indent + texts[begin]->headLen, capsule); PRINTED(begin); - if (!capsule) + if (!capsule){ + if(texts[begin]->indent && put == &texPut){ + /* この場合、texFTitle()の出力が「\\」で終わっており、 + 次のputIndent()が「\endlist」を出力する直前に + 「\mbox{}」を入れてunderfull hboxの警告を抑える */ + printf("\\mbox{}"); + } putIndent(IND_RESUME, 0); + } break; case TB_QUOTE: case TB_EXAMPLE: - putMacro(M_EXAM_BEGIN, fontSize); + putMacro(useJverb ? M_JEXAM_BEGIN : M_EXAM_BEGIN, fontSize); for (i = begin; i < end; i++) { PRINTED(i); if (texts[i]->blank) @@ -421,7 +472,7 @@ else (*put->example)(texts[i]->body + listIndent); } - putMacro(M_EXAM_END); + putMacro(useJverb ? M_JEXAM_END : M_EXAM_END); break; case TB_LISTHD: printf("ERROR(List Output%d)%s\n", begin, texts[begin]->body); @@ -452,17 +503,40 @@ case TB_TABLE: { int center; + int indent_amount = 0; + if (!capsule) { center = isCenter(begin, end); (*put->capsule)(BEGIN, FT_TABLE, center); - if (!center) - putIndent(IND_INDENT, - texts[begin]->indent / 2); + if (!center){ + indent_amount = + texts[begin]->indent / 2; + + if(!crossRefer && put == &texPut && + indent_amount){ + /* この場合、texCapsule()の出力が + 「\\」で終わっており、次の + putIndent()が「{\list{}…」を出力 + する直前に「\mbox{}」を入れて + underfull hboxの警告を抑える */ + printf("\\mbox{}"); + } + putIndent(IND_INDENT, indent_amount); + } } tblOutput(begin, end); if (!capsule) { - if (!center) + if (!center){ + if(put == &texPut && indent_amount){ + /* この場合、直前のputIndent()の出力 + が「\\」で終わっており、次の + putIndent()が「\endlist」を出力 + する直前に「\mbox{}」を入れて + underfull hboxの警告を抑える */ + printf("\\mbox{}"); + } putIndent(IND_RESUME, 0); + } (*put->capsule)(END, FT_TABLE, center); } } --- plain2-2.54p1.orig/src/picture.c +++ plain2-2.54p1/src/picture.c @@ -1,9 +1,13 @@ /* * Copyright (C) 1991,1992 NEC Corporation. */ +/* + * modify by k-chinen@is.aist-nara.ac.jp, 1994 + */ + #ifndef lint -static char rcsid[]= - "$Id: picture.c,v 2.11 1994/04/19 10:16:53 uchida Exp $ (NEC)"; + + #endif #ifdef PICTURE @@ -627,6 +631,39 @@ int l; int maxLen; int minInd; + +#ifdef HTML + static int pic_count=0; + if(put == &htmlPut) { + if(htmlOnce) { + if(rawOutput) { + printf("
\n");
+		    for( l = begin; l < end; l++) {
+			htmlRawText(texts[l]->body);
+		    }
+		    printf("
\n"); + } + else { + printf("\n"); + } + return ; + } + else { + printf("\n", + pic_count, begin, end); + if(htmlHere) { + printf("

\n", pic_count); + } + else { + printf("

Picture here

\n", + pic_count); + } + pic_count++; + return ; + } + } +#endif /* HTML */ + minInd = minIndent(begin, end); maxLen = maxLength(begin, end); if ((maxLen - minInd) * fontSize > pageWidth) --- plain2-2.54p1.orig/src/plain2.c +++ plain2-2.54p1/src/plain2.c @@ -1,9 +1,13 @@ /* * Copyright (C) 1991,1992,1994 NEC Corporation. */ +/* + * modify by k-chinen@is.aist-nara.ac.jp, 1994 + */ + #ifndef lint -static char rcsid[] = - "$Id: plain2.c,v 2.29 1994/04/19 10:40:29 uchida Exp $ (NEC)"; + + #endif #include @@ -12,6 +16,30 @@ #include "plain2.h" #include "macro.h" +#ifdef HTML +#define PLAIN2_USAGE_1 "\ +usage: plain2 [options] [files ...]\n\n\ + ---- parser options ---- ---- output options ----(default)\n\ +-table=dd: table factor [0-100](def=50) -roff: troff output\n\ +-exam=dd: example factor[0-100](def=50) -ms/-mm: troff macro (mm)\n\ +-indsec: sections can be indented -tex: tex output\n\ +-ktable:enable JIS keisen table -tstyle=ss:tex style\n\ +-ref: figure/picture reference -html: HTML output\n\ + -htmlonce: HTML (one path) output\n\ + -here: HTML table/picture ref.\n\ + -renum: renumbering only\n\ + -[no]listd:list decoration (on)\n\ + ---- Others ---- -[no]space:spacing (on)\n\ +-v: verbose output -[no]pre: preamble block (on)\n\ +-dLevel: debug level -[no]acursec: section numbers (off)\n\ + ----- experimental ---- -raw: quote special chars(off)\n\ +-pt=Size: font size -jis: JIS code output\n\ + -sjis: Shift-JIS code input/output\n\ + -f file: output customization\n\n" +#define VERSION "plain2 r2.54 1994/04 by A.Uchida NEC Corporation\n\ +\t(HTML output) by k-chinen@is.aist-nara.ac.jp, NAIST\n\ +\t(unofficial patch 98/08/13 by N.Nide)" +#else #define PLAIN2_USAGE_1 "\ usage: plain2 [options] [files ...]\n\ ---- parser options ---- ---- output options ----(default)\n\ @@ -28,13 +56,19 @@ -pt=Size: font size -jis: JIS code output\n\ -sjis: Shift-JIS code input/output\n\ -f file: output customization\n" -#define VERSION "plain2 r2.54 1994/04 by A.Uchida NEC Corporation" +#define VERSION "plain2 r2.54 1994/04 by A.Uchida NEC Corporation\n\ +\t(HTML output) by k-chinen@is.aist-nara.ac.jp, NAIST" +#endif -extern char *getenv(); +extern char *getenv(); extern char *optarg; extern int optind; extern struct macDefs roffMacros[], roffMsMacros[]; extern struct macDefs texMacros[]; +#ifdef HTML +extern struct macDefs htmlMacros[]; +#endif + /* * Default parameters for Parsing */ @@ -64,10 +98,15 @@ int fontSize = 10; int fontSpecified = 0; int verbose = 0; +#ifdef HTML +int htmlOnce = 0; +int htmlHere = 0; +#endif char *plain2Lib = NULL; char *macroName = NULL; -char *texStyle = NULL; +char *texStyle = DEFAULT_STY; /* Nide */ struct outDev *put = &roffPut; +int useJverb = 0; /* Nide */ FILE *inFile; struct text **texts; @@ -89,6 +128,8 @@ extern unsigned _stklen = 32768U; #endif +int stflag = 1; + main(argc, argv) int argc; char **argv; @@ -112,6 +153,7 @@ (void)fprintf(stderr, "%s\n", VERSION); exit (2); } + if (put != &texPut) useJverb = 0; if (macroName) macroFile(macroName); saveParseDefaults(); @@ -146,6 +188,46 @@ putMacro(M_DOC_END); exit(0); } + + /* "a4j,12pt" -> "a4,12pt" etc. Return value can be free'ed afterward */ +char *styleConv(s, nttflag) +char *s; +int nttflag; +{ + char *buf, *p; + int sty_appeared = 0; + + if(NULL == (p = buf = malloc(strlen(s)*3/2+6+1))){ /* 6 for ",jverb" */ + fprintf(stderr, "PANIC(malloc in styleConv)\n"); + exit(2); + } + while(*s){ + while(isspace(*s)) *p++ = *s++; + if(*s) sty_appeared = 1; + if((*s == 'a' || *s == 'b') && (s[1] == '4' || s[1] == '5')){ + if(nttflag){ + if(s[2] == 'j' && (!s[3] || s[3] == ',')){ + strncpy(p, s, 2), p += 2, s += 3; + } + } else { + if(!s[2] || s[2] == ','){ + strncpy(p, s, 2), p += 2, s += 2; + *p++ = 'j'; + } + } + } + while(*s) if(',' == (*p++ = *s++)) break; + } + if(useJverb){ + if(sty_appeared) *p++ = ','; + strcpy(p, "jverb"), p += 5; + } + *p = '\0'; + return buf; +} +#define nttSty(s) styleConv(s, 1) +#define asciiSty(s) styleConv(s, 0) + /* * Do parse & output */ @@ -163,14 +245,26 @@ if (firstTime) { firstTime = 0; +#ifdef HTML + if (put == &htmlPut) { + initMacroDefs(htmlMacros); + /* sorry, nothing is change this "if" */ + if (halfCooked) { + htmlSetTrans(0); + } + else { + htmlSetTrans(1); + } + } + else +#endif if (put == &roffPut) { if (roffMacro == MS_MACRO) initMacroDefs(roffMsMacros); initMacroDefs(roffMacros); } - else if (put == &texPut) + else if (put == &texPut) { initMacroDefs(texMacros); - if (put == &texPut) { if (halfCooked) { texSetTrans(0); } @@ -179,10 +273,18 @@ } } if (preamble) { - if (texStyle) - putMacro(M_DOC_BEGIN, (long)fontSize, texStyle); - else - putMacro(M_DOC_BEGIN, (long)fontSize, ""); + if (stflag) { + char *p = nttSty(texStyle), *q = asciiSty(texStyle); + + putMacro(M_DOC_BEGIN, (long)fontSize, p, q); + free(p), free(q); + } + else { + char *p = asciiSty(texStyle), *q = asciiSty(texStyle); + + putMacro(M_DOC_BEGIN, (long)fontSize, p, q); + free(p), free(q); + } } } @@ -285,6 +387,13 @@ } else #endif + /* Add Nide (need jverb,sty to use this option) */ + if (strcmp(optarg, "verb") == 0) { + OUTPUT_OPTION("-jverb"); + useJverb = 1; + } + else + /* Add Nide end */ goto usage; break; case 'l': @@ -300,12 +409,17 @@ outputCode = CODE_SJIS; inputCode = CODE_SJIS; } - else + else if (strcmp(optarg, "trict") == 0) { + stflag = 0; + } #endif if (strcmp(optarg, "pace") == 0) { OUTPUT_OPTION("-space"); reflectSpace = 1; } + else if (strcmp(optarg, "trict") == 0) { + stflag = 0; + } else goto usage; break; case 'e': @@ -407,6 +521,22 @@ OUTPUT_OPTION("-alfraw"); halfCooked = 1; } +#ifdef HTML + else if (strcmp(optarg, "tmlonce") == 0) { + OUTPUT_OPTION("-htmlonce"); + htmlOnce = 1; + put = &htmlPut; + } + else if (strcmp(optarg, "tml") == 0) { + OUTPUT_OPTION("-html"); + htmlOnce = 0; + put = &htmlPut; + } + else if (strcmp(optarg, "ere") == 0) { + OUTPUT_OPTION("-here"); + htmlHere = 1; + } +#endif else goto usage; break; case 't': --- plain2-2.54p1.orig/src/plain2.h +++ plain2-2.54p1/src/plain2.h @@ -19,16 +19,23 @@ * 2.4: 28/04/92 * 2.5: 06/08/93 */ -#define NEC_CCS /* NEC C&C Common Software Lab. dependent */ +/* + * modify by k-chinen@is.aist-nara.ac.jp, 1994 + */ + +/* #define NEC_CCS /* NEC C&C Common Software Lab. dependent */ -#define NTT_TEX /* NTT jlatex */ +/* #undef NTT_TEX /* NTT jlatex */ /* no longer needed */ #define TITLE_SPECIAL #define PLAIN2_ENV "PLAIN2_INIT" #define PLAIN2_LIB "PLAIN2_LIB" -#define MACRO_LIB "/usr/local/lib/plain2" +#define MACRO_LIB "/usr/lib/plain2" + +#define DEFAULT_STY "" /* default style in TeX output */ +/*#define DEFAULT_STY "a4" */ #define MIN_INDENT 4 /* minimum indentation to be indented region */ #define MIN_SPACING 4 /* minimum number of lines to be space region*/ @@ -203,9 +210,14 @@ extern int listDecor; /* List decoration */ extern int reflectSpace; /* reflect space lines */ extern int texQuote; /* Use \verb| | for tex output */ +#ifdef HTML +extern int htmlOnce; /* One/Multi-path flag for HTML */ +extern int htmlHere; /* flag of pic/tbl here or not */ +#endif extern int indexEnabled; /* Enables Indexing */ extern int fontSize; /* font size */ extern int fontSpecified; /* font size specified */ +extern int useJverb; /* use jverbatim (Nide) */ /* */ extern FILE *inFile; /* intput File */ extern struct text **texts; /* texts[lineNum] array of text @@ -268,6 +280,8 @@ int markAsPlain(); int markIfQuote(); int markIfTable(); +struct picLineElm *picLineMatch(); +struct picMiscLines *picMiscMatch(); /* * Output driver @@ -309,6 +323,9 @@ }; extern struct outDev roffPut; extern struct outDev texPut; +#ifdef HTML +extern struct outDev htmlPut; +#endif extern struct outDev *put; #define INLINE_BEGIN "((" --- plain2-2.54p1.orig/src/readfile.c +++ plain2-2.54p1/src/readfile.c @@ -201,6 +201,7 @@ while (fgets(buf, MAX_LINE_LEN, inFile) != NULL) { textp->next = (struct text *)malloc(sizeof(struct text)); if (textp->next == NULL){ + malloc_error: fprintf(stderr, "PANIC(malloc in readAndStore)\n"); exit (2); } @@ -222,8 +223,10 @@ */ texts = (struct text **) malloc(sizeof(struct text *) * (textLines + 1)); + if(texts == NULL) goto malloc_error; /* Add Nide */ for (textp = textTop, i=1; i < textLines; textp = textp->next, i++) texts[i] = textp; texts[textLines] = (struct text *)malloc(sizeof(struct text)); + if(texts[textLines] == NULL) goto malloc_error; /* Add Nide */ bzero((char *)texts[textLines], sizeof(struct text)); } --- plain2-2.54p1.orig/src/table.c +++ plain2-2.54p1/src/table.c @@ -464,7 +464,7 @@ if (colVline[col] == COLV_ASC && tblAsciAttr[(unsigned char)*s] == 0 && tblKanjiByte[(unsigned char)*s] - && tblKwakuAttr(s) == NULL) + && tblKwakuAttr(s) == 0) nilg++; #ifdef KANJI if (isZenkaku(s)) { --- plain2-2.54p1.orig/src/roffout.c +++ plain2-2.54p1/src/roffout.c @@ -19,6 +19,10 @@ M_PLAIN_END, "", M_EXAM_BEGIN, ".ft CW\n.vs -2\n.nf\n", M_EXAM_END, ".fi\n.vs +2\n.ft\n", + M_JEXAM_BEGIN, "", + M_JEXAM_END, "", /* These two are not actually used, because when + roff output is selected, the flag useJverb + is always 0 */ M_APPENDIX, "\\fBAppendix $1\\fP\n", M_BLANK, "\n", M_PAGE, ".bp\n", --- plain2-2.54p1.orig/src/texout.c +++ plain2-2.54p1/src/texout.c @@ -12,32 +12,30 @@ #include "table.h" #include "macro.h" -#ifdef NTT_TEX -#define STR_DOC_BEGIN "\\documentstyle[$2]{jarticle}\n\ +#define STR_DOC_BEGIN "\ +\\newif\\ifNTT\\NTTfalse\n\ +\\ifx\\gtfam\\undefined\\ifx\\gtfamily\\undefined\\NTTtrue\\fi\\fi\n\ +\\ifNTT\\documentstyle[$2]{j-article}\n\ +\\else\\documentstyle[$3]{jarticle}\\fi\n\ \\setcounter{secnumdepth}{6}\n\ \\setcounter{tocdepth}{6}\n\ \\topsep=0.1cm\n\ \\parsep=0.1cm\n\ \\itemsep=0.0cm\n\ -\\renewcommand{\\bf}{\\protect\\pbf\\protect\\pdg}\n\ +%\\renewcommand{\\bf}{\\protect\\pbf\\protect\\pdg}\n\ \\begin{document}\n" -#else /* ASCII_TEX */ -#define STR_DOC_BEGIN "\\documentstyle[$2]{jarticle}\n\ -\\setcounter{secnumdepth}{6}\n\ -\\setcounter{tocdepth}{6}\n\ -\\topsep=0.1cm\n\ -\\parsep=0.1cm\n\ -\\itemsep=0.0cm\n\ -\\begin{document}\n" -#endif struct macDefs texMacros[] = { M_DOC_BEGIN, STR_DOC_BEGIN, M_DOC_END, "\\end{document}\n", M_PLAIN_BEGIN, "\\par\n", M_PLAIN_END, "", - M_EXAM_BEGIN, "{\\baselineskip=#1pt\n\\begin{verbatim}\n", + M_EXAM_BEGIN, "{\\par\\baselineskip=#1pt\n\\begin{verbatim}\n", + /* 直前の行間まで狭まってしまうのを防ぐため\parを置いた */ M_EXAM_END, "\\end{verbatim}}\n", + M_JEXAM_BEGIN, "{\\par\\baselineskip=#1pt\n\\begin{jverbatim}\n", + M_JEXAM_END, "\\end{jverbatim}\\par}\n", + /* jverbatimの前後には\par必要。jverb.styのドキュメント参照 */ M_APDX_BEGIN, "\\appendix\n", M_APPENDIX, "\\section{@1}\n", M_BLANK, "\\medskip\n", @@ -180,8 +178,9 @@ s = buf; while(*str) { if (len = alpha(str)) { - (void)strcpy(s, "\\verb|"); - s += strlen("\\verb|"); + char *p = useJverb ? "\\jverb|" : "\\verb|"; + (void)strcpy(s, p); + s += strlen(p); (void)strncpy(s, str, len); s += len; str += len; @@ -805,7 +804,9 @@ if (begin) { printf("~\\\\\n"); if (center) { - printf("\\begin{center}\n"); + /* 「\begin{center}」の直前が「\\」となるため + 「\mbox{}」を入れてunderfill hboxの警告を抑える */ + printf("\\mbox{}\\begin{center}\n"); } } else { --- plain2-2.54p1.orig/src/title.c +++ plain2-2.54p1/src/title.c @@ -101,6 +101,12 @@ "事業部", TENT_SHOZOKU, S_ALL, 0, W_ANYWHERE, "研究所", TENT_SHOZOKU, S_ALL, 0, W_ANYWHERE, "研究部", TENT_SHOZOKU, S_ALL, 0, W_ANYWHERE, +/* Add Nide */ + "大学", TENT_SHOZOKU, S_ALL, 0, W_ANYWHERE, + "学部", TENT_SHOZOKU, S_ALL, 0, W_ANYWHERE, + "学科", TENT_SHOZOKU, S_ALL, 0, W_ANYWHERE, + "研究室", TENT_SHOZOKU, S_ALL, 0, W_ANYWHERE, +/* Add Nide end */ "文書番号", TENT_NUMBER, S_FROMRIGHT, 0, W_ANYWHERE, "日付", TENT_DATE, S_FROMRIGHT, 0, W_ANYWHERE, "月", TENT_DATE, S_ALL, 0, W_ANYWHERE, @@ -132,6 +138,18 @@ "/97", TENT_DATE, S_ALL, 0, W_ANYWHERE, "/98", TENT_DATE, S_ALL, 0, W_ANYWHERE, "/99", TENT_DATE, S_ALL, 0, W_ANYWHERE, +/* Add Nide */ + "2000/", TENT_DATE, S_ALL, 0, W_ANYWHERE, + "2001/", TENT_DATE, S_ALL, 0, W_ANYWHERE, + "2002/", TENT_DATE, S_ALL, 0, W_ANYWHERE, + "2003/", TENT_DATE, S_ALL, 0, W_ANYWHERE, + "2004/", TENT_DATE, S_ALL, 0, W_ANYWHERE, + "/2000", TENT_DATE, S_ALL, 0, W_ANYWHERE, + "/2001", TENT_DATE, S_ALL, 0, W_ANYWHERE, + "/2002", TENT_DATE, S_ALL, 0, W_ANYWHERE, + "/2003", TENT_DATE, S_ALL, 0, W_ANYWHERE, + "/2004", TENT_DATE, S_ALL, 0, W_ANYWHERE, +/* Add Nide end */ #ifdef NEC_CCS "開本", TENT_SHOZOKU, S_ALL, 0, W_ANYWHERE, "開研", TENT_SHOZOKU, S_ALL, 0, W_ANYWHERE, --- plain2-2.54p1.orig/src/README.HTML +++ plain2-2.54p1/src/README.HTML @@ -0,0 +1,176 @@ +by k-chinen@is.aist-nara.ac.jp + +1. Prologue + + +This packege is patched HTML support plain2. +HTML support routines separated by Macro HTML. + + #ifdef HTML + +If you found bugs, please send mail k-chinen@is.aist-nara.ac.jp. + + + + +2. What is HTML ? + +HTML was acronym for Hyper Text Markup Language, which is used in World +Wide Web. +World Wide Web is famous service for Mosaic. World Wide Web makes hypertext +over Network. + + + +3. How to use ? + +3.1. Basic + +3.1.1. convert plain text to HTML + + + % plain2 -html foo.txt > bar.html + +plain2 convert foo.txt (plain text) to bar.html (HTML). + + + +3.1.2. convert plain text to HTML with pictures and tables + +use -here option, plain2 made HTML which include pictures and tables. +But HTML not support picture and table. plain2 only express anchor for link +to picture and table + + % plain2 -html -here foo.txt > junk.html + + +3.1.3. convert plain text to HTML with erasing pictures and tables + +If you want to erase picture or table, use -htmlonce option (don't use -html). + + + +3.1.4. convert plain2 text to HTML with raw pictures and tables + +If you want to convert plain2 text with raw pictures and tables, +use -htmlonce and -raw. + + + +3.2. Extended (plain2html) + +3.2.1. require + +HTML is not support picture and table, you know. but plain2 generate +image and table via roff or TeX. +Then you need roff or TeX and image processing programs. + +For example, this packege include c-shell script which named plain2html. +This script ganerate HTML and picture and table files. +(pictures and tables are GIF format file). +and plain2html require follow programs. + + (1) plain2 + + (2) typesetting program + - TeX + * latex and dvi2ps + ('jlatex' is japanelized latex. please subsitute + 'jlatex' to 'latex' in script) + - roff + * groff + + (3) image processing program + - convert ( which included ImageMagick) + - pnmcrop ( which included pbmplus) + + (4) other + - csh or tcsh + - awk + - ghostscript ( convert calle it) + - pt2htcol.awk ( inclued this packege ) + +3.2.2. How to use + +For eample, convert plain text file foo.txt to HTML. + + (1) Make working direcory, because plain2 generate many files. + + % mkdir foo.work + % cp foo.txt foo.work + % cd foo.work + + (2) run plain2html + + % plain2html foo.txt + + plain2html gerate HTML file foo.html, PIC*.gif (for picture) and + TBL*.gif (for table). + +So, you get HTML file. Please check result via Mosaic or Chimera. + + % Mosaic foo.html + +or + + % chimera foo.html + + + +4. Changes for plain2 + +* add -html option + +* add -here option + Document size is important in WWW. switch include images or not. + +* new make htmlout.c (like texout.c) + +* Cannot found pictures begin and end, I modify picture.c + +* add plain2html and pt2htcol.awk + + 1. Genate HTML with -html + 2. Convert pictures and tables. + + a) groff + - conver to PS via groff + + b) latex + - convert to DVI via latex + - convert to PS via dvi2ps + + 3. cut improtant part in picures and convert to GIF. + - convet to PNM via 'convert' + - cut via 'pnmcrop' + - convet to GIF via 'convert' + + + +5. Bugs. + +* It is multi path + plain2 is beauty, because plain2 is one path... + but plain2html is multi path. + +* I think to hard to install. because it require many programs. + +* on groff + - groff not support japanaes + + +6. Acknowledgment + +Special thank for Mr. Uchida (uchida@ccs.mt.nec.co.jp). he release +plain2 r2.5 for this program. And he give important advice and +suggestion. + + +7. Epilogue + +This packege is only patch for plain2. It is not new revision of plain2. +Then, If you have questions, advices and requiremnts. please mail +k-chinen@is.aist-nara.ac.jp + +Own your risk. +Enjoy !!! --- plain2-2.54p1.orig/src/README.HTML.JPN +++ plain2-2.54p1/src/README.HTML.JPN @@ -0,0 +1,197 @@ +$BBjL>(B plain2 $B$N(B HTML $BBP1~(B +by k-chinen@is.aist-nara.ac.jp + +1. $B$O$8$a$K(B + +$B$3$N%G%#%l%/%H%j$N%=!<%9%U%!%$%k$NCf$G!"(B + + #ifdef HTML + +$B$H$7$F$"$k$N$O!"%*%j%8%J%k$N(B plain2 $B$rF`NI@hC<2J3X5;=QBg3X1!Bg3X$N(B +$BCNG0(B (k-chinen@is.aist-nara.ac.jp) $B$,(B HTML $BBP1~$N$?$a2~B$$7$?$H$3$m(B +$B$G$9!#(B +$B$=$NItJ,$G%P%0$,5/$-$?$H;W$o$l$k:]$K$O(B k-chinen@is.aist-nara.ac.jp +$B$X(B E-mail $B$G$*CN$i$;$/$@$5$$!#O$r:n@.$9$k0Y$N8@8l$G$9!#(BWorld Wide Web $B$O(B Mosaic $B$H(B +$B$$$&%W%m%0%i%`$GM-L>$J!"%M%C%H%o!<%/>e$K%O%$%Q!<%F%-%9%H$r:n$k%5!<(B +$B%S%9$G$9!#(B + + +3. $B;H$$J}(B + +3.1. $B4pK\(B + +3.1.1. plain text $B$r(B HTML $B$K(B + +$B4pK\E*$J%*%j%8%J%k$N(B plain2 $B$H$[$H$s$IF1$8$G!"(B + + % plain2 -html -jis foo.txt > bar.html + +$B$H$$$&$h$&$K;H$$$^$9!#(B +$B$3$&$9$k$H!"(Bfoo.txt $B$H$$$&(B plain text $B$r(B bar.html $B$H$$$&(B HTML $B$N=q(B +$B<0$G$+$+$l$?%U%!%$%k$,$G$-$^$9!#(B + +3.1.2. plain text $B$r?^$dI=$,F~$C$?(B HTML $B$K(B + +plain2 $B$K(B -here $B%*%W%7%g%s$r$D$1$k$H!"?^$dI=$rD>@\4^$a$k$h$&$K=q$+(B +$B$l$?(B HTML $B$N=q<0$N%U%!%$%k$,$G$-$^$9!#(B +($B$?$@$7!";DG0$J$,$i(B plain2 $B$G?^$dI=$r(B HTML $B$K$9$k;v$O=PMh$^$;$s!#(B) + + % plain2 -html -here -jis foo.txt > junk.html + +$B$H$7$F;H$C$F$_$^$7$g$&!#(B +$B$3$N(B junk.html $B$G$O!"(B bar.html $B$G(B "Picture here" $B$H$+(B "Table here" +$B$H=q$$$F$"$C$?>l=j$K2?$+?^$,=P$k$H$*$b$$$^$9!#(B + +3.1.3. plain text $B$N?^$dI=$rL5;k$7$F(B HTML $B$K(B + +$B?^$dI=$rL5;k$7$F(B HTML $B$K$7$?$$;~$K$O!"(B-html $B$G$O$J$/(B -htmlonce $B$r(B +$B;H$C$F$/$@$5$$!#(B + +3.1.4. plain text $B$N?^$dI=$O$=$N$^$^$G(B HTML $B$K(B + +$B?^$dI=$r$=$N$^$^(B HTML $B$K4^$a$?$$;~$K$O!"(B-htmlonce $B$H(B -raw $B$r0l=o(B +$B$K;H$C$F$/$@$5$$!#(B + + + +3.2. $B1~MQ(B (plain2html) + +3.2.1. $BI,MW$JJ*(B + +plain2 $B$N(B HTML $B$r:n$k5!G=$G$O?^$dI=$O:n$l$^$;$s$,!"(Broff $B$d(B TeX $B$r(B +$B;H$C$F?^$dI=$r:n$k;v$,=PMh$^$9!#$3$N$?$a$K$O(B roff $B$d(B TeX $B$N7A<0$N(B +$B%U%!%$%k$r(B gif $BEy$N%$%a!<%8%G!<%?$K$9$k%W%m%0%i%`$,I,MW$G$9!#(B + +$B%5%s%W%k$H$7$F!"$3$N%Q%C%A$G$O(B plain2html $B$H$$$&(B csh script $B$r$D(B +$B$1$F$"$j$^$9!#$3$N%9%/%j%W%H$G$O(B HTML $B$N%U%!%$%k$H$=$l$KI,MW$J?^(B +$B$dI=$N$?$a$N%$%a!<%8%G!<%?$r:n$j$^$9!#(B + +$B$3$N%9%/%j%W%H$r;H$&$K$O0J2<$N$h$&$J%W%m%0%i%`$,I,MW$G$9!#(B + + (1) plain2 + + (2) $BAHHG%W%m%0%i%`(B + - TeX $B$r$D$+$&>l9g(B + * jlatex $B$H(B dvi2ps + - roff $B$r;H$&>l9g(B + * groff + + (3) $B%$%a!<%8%G!<%?JQ49%W%m%0%i%`(B + - convert ( ImageMagick $B$K4^$^$l$F$$$^$9(B ) + - pnmcrop ( pbmplus $B$K4^$^$l$F$$$^$9(B ) + + (4) $B$=$NB>(B + - csh $B$+(B tcsh + - awk + - ghostscript ( convert $B$,8F$S=P$7$^$9(B ) + - pt2htcol.awk ( $B$3$N%Q%C%A$K4^$^$l$F$$$^$9(B ) + +3.2.2. $B;H$$J}(B + +foo.txt $B$r(B HTML $B$N%U%!%$%k$K$9$kNc$r>R2p$7$^$9!#(B + + (1) $B?^$dI=$N%$%a!<%8%G!<%?$,$G$-$k$N$GJL$N%G%#%l%/%H%j$r$D$/(B + $B$C$F$=$3$G:n6H$7$^$7$g$&!#(B + + % mkdir foo.work + % cp foo.txt foo.work + % cd foo.work + + (2) plain2html $B$r\$7$/$J$$(B + $B$N$G<+?.$,$J$$(B) + + +5. $BLdBjE@(B + +* multi path $B$J$C$F$7$^$C$?!#(B + plain2 $B$O(B one path $B$@$+$iH~$7$$$N$K(B... + +* $B$$$m$$$m$J%D!<%k$r;H$&$N$G!"(Binstall $B$9$k;~$OBgJQ$+$bCN$l$J$$!#(B + +* groff $B$K4X$7$F(B + - $BF|K\8l$,DL$8$J$$(B + + +6. $B!" +#include "plain2.h" +#include "picture.h" +#include "table.h" +#include "macro.h" + + +struct macDefs htmlMacros[] = { + M_DOC_BEGIN, "\n", + M_DOC_END, "\n", + M_PLAIN_BEGIN, "

\n", + M_PLAIN_END, "

\n", + M_EXAM_BEGIN, "
\n",
+	M_EXAM_END,	"
\n", + M_APDX_BEGIN, "\n", + M_APPENDIX, "\n", + M_BLANK, "\n", + M_PAGE, "\n\n", + M_NEWLINE, "\n\n", + M_CENTER_BEGIN, "\n", + M_CENTER_END, "\n", + M_RIGHT_BEGIN, "\n", + M_RIGHT_END, "\n", + M_INDENT, "
\n", + M_INDENT0, "
\n", + M_FOOTN_BEGIN, "", + M_FOOTN_END, "", + M_REFER_BEGIN, "GO", + M_BOLD_BEGIN, "", + M_BOLD_END, "", + M_INDEX_BEGIN, "", + M_INDEX_END, "", + M_SECTION_1, "\n

@1

\n", + M_SECTION_2, "\n

@1

\n", + M_SECTION_3, "\n

@1

\n", + M_SECTION_4, "\n

@1

\n", + M_SECTION_5, "\n
@1
\n", + M_SECTION, "", + M_SETSEC_1, "", + M_SETSEC_2, "", + M_SETSEC_3, "", + M_SETSEC_4, "", + M_SETSEC_5, "", + M_TITLE, "&1\n

&1

\n&6\n
&4\n&3
\n
", + -1, "", + }; + + +/* + * HTML text output routines + */ + +struct transTable *htmlTrans; +struct transTable *htmlTransM; + +static struct transTable htmlFullTrans[] = { + {'<', "<" }, + {'>', ">" }, + {'&', "&" }, + {0,0} }; +static struct transTable htmlFullTransM[] = { + {'<', "<" }, + {'>', ">" }, + {'&', "&" }, + {0,0} }; + +static struct transTable htmlHalfTrans[] = { + {'<', "<" }, + {'>', ">" }, + {'&', "&" }, + {0,0} }; + +static struct transTable htmlHalfTransM[] = { + {'<', "<" }, + {'>', ">" }, + {'&', "&" }, + {0,0} }; + +htmlSetTrans(full) +int full; +{ + if (full) { + htmlTrans = htmlFullTrans; + htmlTransM = htmlFullTransM; + } + else { + htmlTrans = htmlHalfTrans; + htmlTransM = htmlHalfTransM; + } +} + + +char * +htmlTextQuote(str, quotable) +char *str; +int quotable; +{ + char *s; + int len; + static char buf[MAX_LINE_LEN]; + + if (rawOutput) + return str; + + if (!quotable) + return textQuote(str, htmlTransM); + + return textQuote(str, htmlTrans); +} + +char *htmlQuote1(str) +char *str; +{ + return htmlTextQuote(str, 1); +} + +char *htmlQuote2(str) +char *str; +{ + return htmlTextQuote(str, 0); +} + + +htmlPutLabel(str) +char *str; +{ + printf(" (here) ", codeCvt(str)); +} + +htmlPlain(str, attr, newline) +char *str; +int attr; +int newline; +{ + if (attr == IL_RAW || attr == IL_REFERENCE) + printf("%s", codeCvt(str)); + else + printf("%s", codeCvt(htmlTextQuote(str, 1))); + if (newline) + printf("\n"); +} + +htmlExample(str) +char *str; +{ + printf("%s\n",textQuote(str, htmlTrans)); +} + +static int enumLevel = 0; +htmlListBlock(begin, level, ltype, hint) +int begin; +int level; +int ltype; +char hint; +{ + char *lstr; + if (begin) { + switch (ltype) { + case L_BULLET: + case L_DASH: + printf("
    \n"); + break; + case L_DLIST: + printf("
    \n"); + break; + case L_LROMAN: + case L_SROMAN: + case L_NUMBER: + case L_LALPHA: + case L_SALPHA: + enumLevel++; + printf("
      \n"); + break; + default: + break; + } + } + else { + switch (ltype) { + case L_BULLET: + case L_DASH: + printf("
\n"); + break; + case L_LROMAN: + case L_SROMAN: + case L_NUMBER: + case L_LALPHA: + case L_SALPHA: + enumLevel--; + printf("\n"); + break; + case L_DLIST: + printf("\n"); + break; + default: + break; + } + } +} + +htmlDlistItem(level, dscr, cont) +int level; +char *dscr; +int cont; +{ + printf("
%s\n", codeCvt(htmlTextQuote(dscr, 1))); +} + +htmlListItem(level) +int level; +{ + printf("
  • "); +} + +htmlRawText(str) +char *str; +{ + printf("%s\n",codeCvt(str)); +} + +htmlSpace(length) +int length; +{ + /* EMPTY --- I don't know what do here */ +} + +htmlFTitle(ft, str, capsule) +int ft; +char *str; /* if (str!=NULL) output title */ +int capsule; +{ + static int figNumber = 1; + static int tblNumber = 1; + if (crossRefer && capsule) { + printf("%s\n", codeCvt(htmlTextQuote(str, 1))); + htmlPutLabel(str); + } + else { + printf ("

    "); +#ifdef KANJI + if (japaneseText) { + if (ft == FT_FIGURE) + printf (" %s %d.", codeCvt("$B?^(B"), figNumber++); + + else if (ft == FT_TABLE) + printf (" %s %d.", codeCvt("$BI=(B"), tblNumber++); + } + else { +#endif + if (ft == FT_FIGURE) + printf (" Figure %d.", figNumber++); + else if (ft == FT_TABLE) + printf (" Table %d.", tblNumber++); +#ifdef KANJI + } +#endif + printf ("%s\n", codeCvt(htmlTextQuote(str, 1))); + } +} + +#ifdef PICTURE +/* + * Driver for HTML(picture) output + */ +static int picLines; /* Number of lines in the block */ +static int picMinInd; /* Indentation of the region */ + +static int htmlVsize; +static int htmlUnit; + +htmlPictureBlock(begin, lines, indent, maxLen) +int begin; +int lines; +int indent; +int maxLen; +{ + if(htmlOnce) { + if(begin) + printf("\n"); + } + else { + if(begin) + printf("\n"); + } +} + +/* set line width */ +htmlLineWidth(style) +int style; +{ + /* */ +} + +htmlEllipse(x0, y0, x1, y1, style) +int x0, x1, y0, y1; +int style; +{ + /* */ +} + +/* + * Draw line + * Only ({-1,0,1},{-1,0,1}) direction. + */ +htmlPicLine(x0, y0, x1, y1, style, vector) +int x0, x1, y0, y1; +int style; +int vector; +{ + /* */ +} + +htmlPicArc(x, y, r, dir, style) +int x, y, r; +enum direction dir; +int style; +{ + /* */ +} + +htmlPicText(s, xpos, vpos, factor) +char *s; +int xpos; +int vpos; +int factor; +{ + /* */ +} +#endif + + + +htmlTitle(style, haifu, title, shozoku, number, date, name, renraku +#ifdef TITLE_SPECIAL + ,special8, special9 +#endif + ) +int style; +char **haifu; +char **title; +char **shozoku; +char **number; +char **date; +char **name; +char **renraku; +#ifdef TITLE_SPECIAL +char **special8, **special9; +#endif +{ + char **s; + if (style == 0) { + putMacro(M_TITLE, + title, number, date, shozoku, haifu, name, renraku +#ifdef TITLE_SPECIAL + ,special8, special9 +#endif + ); + return; + } +} + +htmlTable(begin, end, tblp) +int begin; +int end; +struct table *tblp; +{ + if(htmlOnce) { + if(rawOutput) { + int l; + + printf("

    \n");
    +			for (l = begin; l < end; l++) {
    +				htmlRawText(texts[l]->body);
    +			}
    +			printf("
    \n"); + } + else { + printf("\n"); + } + + } + else { + static int tbl_count=0; + printf("\n\n",tbl_count,begin,end); + + if(htmlHere) { + printf("

    \n", tbl_count); + } + else { + printf("

    Table here

    \n", + tbl_count); + } + tbl_count++; + } +} + +htmlCapsule(begin, type, center) +int begin; +int type; +int center; +{ + static int count=0; + char *typeStr; + + if (crossRefer) { + switch (type) { + case FT_FIGURE: + typeStr = "figure"; + break; + case FT_TABLE: + typeStr = "table"; + break; + default: + fprintf(stderr, "PANIC(unknown capsule type)\n"); + exit(2); + break; + } + if (begin) { + count++; + printf("\n\n",count); + } + else { + printf("\n\n",count); + } + } + else /* short paper */ { + if (begin) { + printf("\n\n",count); + } + else { + printf("\n\n",count); + } + } +} + +htmlComment(begin, end) +int begin; +int end; +{ + int l; + for (l = begin; l < end; l++) { + printf ("\n", codeCvt(texts[l]->body)); + } +} --- plain2-2.54p1.orig/src/plain2html +++ plain2-2.54p1/src/plain2html @@ -0,0 +1,159 @@ +#!/usr/local/bin/tcsh +# +# plain2html: plain text to HTML file +# by k-chinen@is.aist-nara.ac.jp , 1994 +# +# NOTE: +# * This script will be running under csh or tcsh. +# * Handle with care for directory, because this script make +# a lot of temporary file and output file. +# + + +# +# require: +# +# program: +# csh or tcsh +# plain2 ( have -html option verison ) +# awk +# groff ( gtbl, gpic ) +# latex or jlatex +# dvi2ps +# convert ( convertable PS to Any-format version ) +# pnmcrop ( included PBMPLUS ) +# ghostscript ( called by convert when convert PS format ) +# +# script: +# pt2htcol.awk ( included this packeage ) +# +# +# input: +# $1 (plain text file name. e.g., README.j) +# +# output: +# $1:r.html (e.g., README.html) +# +# temporary file: +# _src, _cut.sh , _out.html , pt2empty.sty, _tmp.pnm +# TBL*.p TBL*.ps TBL*.src TBL*.tex TBL*.dvi TBL*.pnm +# PIC*.p PIC*.ps PIC*.src PIC*.tex PIC*.dvi PIC*.pnm +# + + +# +# Default values +# +set tex=1 +set roff=0 +set lib=/usr/local/lib/plain2 + + +# +# Check args. +# +if ( $#argv > 0 ) then + switch ($1) + case -tex: + set tex=1 + set roff=0 + shift + breaksw + case -roff: + set tex=0 + set roff=1 + shift + breaksw + default: + breaksw + endsw +endif + +if ( $#argv > 0 ) then + set target=$1 +else + cat << END_USAGE +plain2html: plain text to HTML file + by k-chinen@is.aist-nara.ac.jp NAIST , 1994 + +usage: plain2html [option] input-filename + +option: -tex TeX mode (use latex, dvi2ps) [defauts] + -roff roff mode (use groff) + +END_USAGE + exit +endif + + + +# +# Start +# convert document's main body. +# collect table/picture location and cut these. +# + +echo "Copy Target $target ." +cp $target _src + +echo "Process document main body" +plain2 -html -jis -here _src > _out.html + +echo "Collect Table/Picutre" +awk -f $lib/pt2htcol.awk _out.html > _cut.sh + + + +# +# Convert parts(table/picture) via LaTeX +# If you don't have jlatex substitute to "latex". +# ( jlatex is Japanese LaTeX ) +# +if ( $tex ) then +cat << END_STYLEFILE > pt2empty.sty +\\thispagestyle{empty} +\\pagestyle{empty} +END_STYLEFILE +cat << END_TEX_CUT >> _cut.sh +foreach i ( TBL*.p PIC*.p ) + echo "Part \$i process" + plain2 -tex -jis -tstyle=pt2empty \$i > \$i:r.tex + jlatex \$i:r.tex + dvi2ps \$i:r.dvi > \$i:r.ps + convert -density 144x144 \$i:r.ps \$i:r.pnm + pnmcrop -white \$i:r.pnm > _tmp.pnm + convert _tmp.pnm \$i:r.gif + rm -f \$i:r.ps \$i:r.dvi \$i:r.aux \$i:r.log \$i:r.tex \$i:r.p \$i:r.pnm +end +END_TEX_CUT +endif + +# +# Convert parts(table/picture) via GROFF +# If you don't have gorff substitute to ROFF-like program. +# +if ( $roff ) then +cat << END_ROFF_CUT >> _cut.sh +foreach i ( TBL*.p PIC*.p ) + echo "Part \$i process" + plain2 -roff -euc \$i > \$i:r.src + groff -me -t -p \$i:r.src > \$i:r.ps + convert -density 144x144 \$i:r.ps \$i:r.pnm + pnmcrop -white \$i:r.pnm > _tmp.pnm + convert _tmp.pnm \$i:r.gif + rm -f \$i:r.ps \$i:r.src \$i:r.p \$i:r.pnm +end +END_ROFF_CUT +endif + +# +# Run parts conversion script +# +echo "Cut Table/Picture" +$shell _cut.sh + +rm -f $target:r.html +mv _out.html $target:r.html +rm -f _cut.sh pt2empty.sty _src _tmp.pnm + +echo "Complete" --- plain2-2.54p1.orig/src/pt2htcol.awk +++ plain2-2.54p1/src/pt2htcol.awk @@ -0,0 +1,20 @@ +# +# pt2htcol.awk: plain2html's parts collection awk-script. +# by k-chinen@is.aist-nara.ac.jp , 1994 +# +# plain2's (with -html) output have "plain2:TABLE" and "plain2:PICTURE" +# sentence. It is mean that output have link to TABLE and PICTURE. +# Therefore, this script collect such sentence and make cutting script. +# +BEGIN{ +} +/^\n", ++ M_APPENDIX, "\n", ++ M_BLANK, "\n", ++ M_PAGE, "\n\n", ++ M_NEWLINE, "\n\n", ++ M_CENTER_BEGIN, "\n", ++ M_CENTER_END, "\n", ++ M_RIGHT_BEGIN, "\n", ++ M_RIGHT_END, "\n", ++ M_INDENT, "
    \n", ++ M_INDENT0, "
    \n", ++ M_FOOTN_BEGIN, "", ++ M_FOOTN_END, "", ++ M_REFER_BEGIN, "GO", ++ M_BOLD_BEGIN, "", ++ M_BOLD_END, "", ++ M_INDEX_BEGIN, "", ++ M_INDEX_END, "", ++ M_SECTION_1, "\n

    @1

    \n", ++ M_SECTION_2, "\n

    @1

    \n", ++ M_SECTION_3, "\n

    @1

    \n", ++ M_SECTION_4, "\n

    @1

    \n", ++ M_SECTION_5, "\n
    @1
    \n", ++ M_SECTION, "", ++ M_SETSEC_1, "", ++ M_SETSEC_2, "", ++ M_SETSEC_3, "", ++ M_SETSEC_4, "", ++ M_SETSEC_5, "", ++ M_TITLE, "&1\n

    &1

    \n&6\n
    &4\n&3
    \n
    ", ++ -1, "", ++ }; ++ ++ ++ /* ++ * HTML text output routines ++ */ ++ ++ struct transTable *htmlTrans; ++ struct transTable *htmlTransM; ++ ++ static struct transTable htmlFullTrans[] = { ++ {'<', "<" }, ++ {'>', ">" }, ++ {'&', "&" }, ++ {0,0} }; ++ static struct transTable htmlFullTransM[] = { ++ {'<', "<" }, ++ {'>', ">" }, ++ {'&', "&" }, ++ {0,0} }; ++ ++ static struct transTable htmlHalfTrans[] = { ++ {'<', "<" }, ++ {'>', ">" }, ++ {'&', "&" }, ++ {0,0} }; ++ ++ static struct transTable htmlHalfTransM[] = { ++ {'<', "<" }, ++ {'>', ">" }, ++ {'&', "&" }, ++ {0,0} }; ++ ++ htmlSetTrans(full) ++ int full; ++ { ++ if (full) { ++ htmlTrans = htmlFullTrans; ++ htmlTransM = htmlFullTransM; ++ } ++ else { ++ htmlTrans = htmlHalfTrans; ++ htmlTransM = htmlHalfTransM; ++ } ++ } ++ ++ ++ char * ++ htmlTextQuote(str, quotable) ++ char *str; ++ int quotable; ++ { ++ char *s; ++ int len; ++ static char buf[MAX_LINE_LEN]; ++ ++ if (rawOutput) ++ return str; ++ ++ if (!quotable) ++ return textQuote(str, htmlTransM); ++ ++ return textQuote(str, htmlTrans); ++ } ++ ++ char *htmlQuote1(str) ++ char *str; ++ { ++ return htmlTextQuote(str, 1); ++ } ++ ++ char *htmlQuote2(str) ++ char *str; ++ { ++ return htmlTextQuote(str, 0); ++ } ++ ++ ++ htmlPutLabel(str) ++ char *str; ++ { ++ printf(" (here) ", codeCvt(str)); ++ } ++ ++ htmlPlain(str, attr, newline) ++ char *str; ++ int attr; ++ int newline; ++ { ++ if (attr == IL_RAW || attr == IL_REFERENCE) ++ printf("%s", codeCvt(str)); ++ else ++ printf("%s", codeCvt(htmlTextQuote(str, 1))); ++ if (newline) ++ printf("\n"); ++ } ++ ++ htmlExample(str) ++ char *str; ++ { ++ printf("%s\n",textQuote(str, htmlTrans)); ++ } ++ ++ static int enumLevel = 0; ++ htmlListBlock(begin, level, ltype, hint) ++ int begin; ++ int level; ++ int ltype; ++ char hint; ++ { ++ char *lstr; ++ if (begin) { ++ switch (ltype) { ++ case L_BULLET: ++ case L_DASH: ++ printf("
      \n"); ++ break; ++ case L_DLIST: ++ printf("
      \n"); ++ break; ++ case L_LROMAN: ++ case L_SROMAN: ++ case L_NUMBER: ++ case L_LALPHA: ++ case L_SALPHA: ++ enumLevel++; ++ printf("
        \n"); ++ break; ++ default: ++ break; ++ } ++ } ++ else { ++ switch (ltype) { ++ case L_BULLET: ++ case L_DASH: ++ printf("
    \n"); ++ break; ++ case L_LROMAN: ++ case L_SROMAN: ++ case L_NUMBER: ++ case L_LALPHA: ++ case L_SALPHA: ++ enumLevel--; ++ printf("\n"); ++ break; ++ case L_DLIST: ++ printf("\n"); ++ break; ++ default: ++ break; ++ } ++ } ++ } ++ ++ htmlDlistItem(level, dscr, cont) ++ int level; ++ char *dscr; ++ int cont; ++ { ++ printf("
    %s\n", codeCvt(htmlTextQuote(dscr, 1))); ++ } ++ ++ htmlListItem(level) ++ int level; ++ { ++ printf("
  • "); ++ } ++ ++ htmlRawText(str) ++ char *str; ++ { ++ printf("%s\n",codeCvt(str)); ++ } ++ ++ htmlSpace(length) ++ int length; ++ { ++ /* EMPTY --- I don't know what do here */ ++ } ++ ++ htmlFTitle(ft, str, capsule) ++ int ft; ++ char *str; /* if (str!=NULL) output title */ ++ int capsule; ++ { ++ static int figNumber = 1; ++ static int tblNumber = 1; ++ if (crossRefer && capsule) { ++ printf("%s\n", codeCvt(htmlTextQuote(str, 1))); ++ htmlPutLabel(str); ++ } ++ else { ++ printf ("

    "); ++ #ifdef KANJI ++ if (japaneseText) { ++ if (ft == FT_FIGURE) ++ printf (" %s %d.", codeCvt("$B?^(B"), figNumber++); ++ ++ else if (ft == FT_TABLE) ++ printf (" %s %d.", codeCvt("$BI=(B"), tblNumber++); ++ } ++ else { ++ #endif ++ if (ft == FT_FIGURE) ++ printf (" Figure %d.", figNumber++); ++ else if (ft == FT_TABLE) ++ printf (" Table %d.", tblNumber++); ++ #ifdef KANJI ++ } ++ #endif ++ printf ("%s\n", codeCvt(htmlTextQuote(str, 1))); ++ } ++ } ++ ++ #ifdef PICTURE ++ /* ++ * Driver for HTML(picture) output ++ */ ++ static int picLines; /* Number of lines in the block */ ++ static int picMinInd; /* Indentation of the region */ ++ ++ static int htmlVsize; ++ static int htmlUnit; ++ ++ htmlPictureBlock(begin, lines, indent, maxLen) ++ int begin; ++ int lines; ++ int indent; ++ int maxLen; ++ { ++ if(htmlOnce) { ++ if(begin) ++ printf("\n"); ++ } ++ else { ++ if(begin) ++ printf("\n"); ++ } ++ } ++ ++ /* set line width */ ++ htmlLineWidth(style) ++ int style; ++ { ++ /* */ ++ } ++ ++ htmlEllipse(x0, y0, x1, y1, style) ++ int x0, x1, y0, y1; ++ int style; ++ { ++ /* */ ++ } ++ ++ /* ++ * Draw line ++ * Only ({-1,0,1},{-1,0,1}) direction. ++ */ ++ htmlPicLine(x0, y0, x1, y1, style, vector) ++ int x0, x1, y0, y1; ++ int style; ++ int vector; ++ { ++ /* */ ++ } ++ ++ htmlPicArc(x, y, r, dir, style) ++ int x, y, r; ++ enum direction dir; ++ int style; ++ { ++ /* */ ++ } ++ ++ htmlPicText(s, xpos, vpos, factor) ++ char *s; ++ int xpos; ++ int vpos; ++ int factor; ++ { ++ /* */ ++ } ++ #endif ++ ++ ++ ++ htmlTitle(style, haifu, title, shozoku, number, date, name, renraku ++ #ifdef TITLE_SPECIAL ++ ,special8, special9 ++ #endif ++ ) ++ int style; ++ char **haifu; ++ char **title; ++ char **shozoku; ++ char **number; ++ char **date; ++ char **name; ++ char **renraku; ++ #ifdef TITLE_SPECIAL ++ char **special8, **special9; ++ #endif ++ { ++ char **s; ++ if (style == 0) { ++ putMacro(M_TITLE, ++ title, number, date, shozoku, haifu, name, renraku ++ #ifdef TITLE_SPECIAL ++ ,special8, special9 ++ #endif ++ ); ++ return; ++ } ++ } ++ ++ htmlTable(begin, end, tblp) ++ int begin; ++ int end; ++ struct table *tblp; ++ { ++ if(htmlOnce) { ++ if(rawOutput) { ++ int l; ++ ++ printf("

    \n");
    ++ 			for (l = begin; l < end; l++) {
    ++ 				htmlRawText(texts[l]->body);
    ++ 			}
    ++ 			printf("
    \n"); ++ } ++ else { ++ printf("\n"); ++ } ++ ++ } ++ else { ++ static int tbl_count=0; ++ printf("\n\n",tbl_count,begin,end); ++ ++ if(htmlHere) { ++ printf("

    \n", tbl_count); ++ } ++ else { ++ printf("

    Table here

    \n", ++ tbl_count); ++ } ++ tbl_count++; ++ } ++ } ++ ++ htmlCapsule(begin, type, center) ++ int begin; ++ int type; ++ int center; ++ { ++ static int count=0; ++ char *typeStr; ++ ++ if (crossRefer) { ++ switch (type) { ++ case FT_FIGURE: ++ typeStr = "figure"; ++ break; ++ case FT_TABLE: ++ typeStr = "table"; ++ break; ++ default: ++ fprintf(stderr, "PANIC(unknown capsule type)\n"); ++ exit(2); ++ break; ++ } ++ if (begin) { ++ count++; ++ printf("\n\n",count); ++ } ++ else { ++ printf("\n\n",count); ++ } ++ } ++ else /* short paper */ { ++ if (begin) { ++ printf("\n\n",count); ++ } ++ else { ++ printf("\n\n",count); ++ } ++ } ++ } ++ ++ htmlComment(begin, end) ++ int begin; ++ int end; ++ { ++ int l; ++ for (l = begin; l < end; l++) { ++ printf ("\n", codeCvt(texts[l]->body)); ++ } ++ } +diff -p -c -r -N orig-plain2-2.53/src/macro.c plain2/src/macro.c +*** orig-plain2-2.53/src/macro.c Fri Jan 7 05:34:40 1994 +--- plain2/src/macro.c Sun Aug 14 03:27:30 1994 +*************** char *fname; +*** 369,375 **** + } + if (ret == -1) + continue; +! s = (char *)malloc(strlen(defstr)); + strcpy(s, defstr); + outMacro[macroNum] = macroParse(s, macroNum, s); + } +--- 369,375 ---- + } + if (ret == -1) + continue; +! s = (char *)malloc(strlen(defstr)+1); + strcpy(s, defstr); + outMacro[macroNum] = macroParse(s, macroNum, s); + } +diff -p -c -r -N orig-plain2-2.53/src/output.c plain2/src/output.c +*** orig-plain2-2.53/src/output.c Fri Jan 7 05:34:46 1994 +--- plain2/src/output.c Wed Jan 19 19:08:44 1994 +*************** +*** 1,6 **** +--- 1,9 ---- + /* + * Copyright (C) 1991,1992,1993 NEC Corporation. + */ ++ /* ++ * modify by k-chinen@is.aist-nara.ac.jp, 1994 ++ */ + #ifndef lint + + +*************** static char rcsid[] = +*** 19,27 **** +--- 22,32 ---- + ?(textp)->body\ + :(textp)->body+(textp)->indent) + #endif ++ + /* + * Definition of Output driver routines. + */ ++ /***** roff *****/ + int roffPlain(), roffExample(), + roffListBlock(), roffDlistItem(), + roffListItem(), roffRawText(), roffSpace(), +*************** int roffPlain(), roffExample(), +*** 33,38 **** +--- 38,45 ---- + roffTable(), roffFTitle(), roffTitle(); + char *roffQuote1(), *roffQuote2(); + ++ ++ /***** TeX *****/ + int texPlain(), texExample(), + texListBlock(), texDlistItem(), + texListItem(), texRawText(), texSpace(), +*************** int texPlain(), texExample(), +*** 44,49 **** +--- 51,70 ---- + texTable(), texFTitle(), texTitle(); + char *texQuote1(), *texQuote2(); + ++ #ifdef HTML ++ /***** HTML *****/ ++ int htmlPlain(), htmlExample(), ++ htmlListBlock(), htmlDlistItem(), ++ htmlListItem(), htmlRawText(), htmlSpace(), ++ htmlCapsule(), htmlComment(), ++ #ifdef PICTURE ++ htmlPictureBlock(), htmlPicLine(), htmlPicArc(), ++ htmlPicText(), htmlLineWidth(), ++ #endif ++ htmlTable(), htmlFTitle(), htmlTitle(); ++ char *htmlQuote1(), *htmlQuote2(); ++ #endif ++ + struct outDev roffPut = { + roffPlain, roffExample, + roffListBlock, roffDlistItem, +*************** struct outDev texPut = { +*** 69,77 **** +--- 90,121 ---- + texTable, texFTitle, texTitle, + texQuote1, texQuote2, + }; ++ ++ #ifdef HTML ++ struct outDev htmlPut = { ++ htmlPlain, htmlExample, ++ htmlListBlock, htmlDlistItem, ++ htmlListItem, htmlRawText, htmlSpace, ++ htmlCapsule, htmlComment, ++ #ifdef PICTURE ++ htmlPictureBlock, htmlPicLine, htmlPicArc, ++ htmlPicText, htmlLineWidth, ++ #endif ++ htmlTable, htmlFTitle, htmlTitle, ++ htmlQuote1, htmlQuote2, ++ }; ++ #endif ++ ++ ++ #ifdef HTML + /* ++ * Output text in (roff, TeX or HTML) format. ++ */ ++ #else ++ /* + * Output text in (roff or TeX) format. + */ ++ #endif + + struct inline_mark { + char il_mark; +diff -p -c -r -N orig-plain2-2.53/src/picture.c plain2/src/picture.c +*** orig-plain2-2.53/src/picture.c Wed Dec 2 16:01:34 1992 +--- plain2/src/picture.c Wed Jan 19 19:09:26 1994 +*************** +*** 1,6 **** +--- 1,10 ---- + /* + * Copyright (C) 1991,1992 NEC Corporation. + */ ++ /* ++ * modify by k-chinen@is.aist-nara.ac.jp, 1994 ++ */ ++ + #ifndef lint + + +*************** int end; +*** 627,632 **** +--- 631,669 ---- + int l; + int maxLen; + int minInd; ++ ++ #ifdef HTML ++ static int pic_count=0; ++ if(put == &htmlPut) { ++ if(htmlOnce) { ++ if(rawOutput) { ++ printf("
    \n");
    ++ 		    for( l = begin; l < end; l++) {
    ++ 			htmlRawText(texts[l]->body);
    ++ 		    }
    ++ 		    printf("
    \n"); ++ } ++ else { ++ printf("\n"); ++ } ++ return ; ++ } ++ else { ++ printf("\n", ++ pic_count, begin, end); ++ if(htmlHere) { ++ printf("

    \n", pic_count); ++ } ++ else { ++ printf("

    Picture here

    \n", ++ pic_count); ++ } ++ pic_count++; ++ return ; ++ } ++ } ++ #endif /* HTML */ ++ + minInd = minIndent(begin, end); + maxLen = maxLength(begin, end); + if ((maxLen - minInd) * fontSize > pageWidth) +diff -p -c -r -N orig-plain2-2.53/src/plain2.c plain2/src/plain2.c +*** orig-plain2-2.53/src/plain2.c Fri Jan 7 18:40:47 1994 +--- plain2/src/plain2.c Wed Jan 19 19:09:44 1994 +*************** +*** 1,6 **** +--- 1,10 ---- + /* + * Copyright (C) 1991,1992,1994 NEC Corporation. + */ ++ /* ++ * modify by k-chinen@is.aist-nara.ac.jp, 1994 ++ */ ++ + #ifndef lint + + +*************** static char rcsid[] = +*** 12,17 **** +--- 16,44 ---- + #include "plain2.h" + #include "macro.h" + ++ #ifdef HTML ++ #define PLAIN2_USAGE_1 "\ ++ usage: plain2 [options] [files ...]\n\n\ ++ ---- parser options ---- ---- output options ----(default)\n\ ++ -table=dd: table factor [0-100](def=50) -roff: troff output\n\ ++ -exam=dd: example factor[0-100](def=50) -ms/-mm: troff macro (mm)\n\ ++ -indsec: sections can be indented -tex: tex output\n\ ++ -ktable:enable JIS keisen table -tstyle=ss:tex style\n\ ++ -ref: figure/picture reference -html: HTML output\n\ ++ -htmlonce: HTML (one path) output\n\ ++ -here: HTML table/picture ref.\n\ ++ -renum: renumbering only\n\ ++ -[no]listd:list decoration (on)\n\ ++ ---- Others ---- -[no]space:spacing (on)\n\ ++ -v: verbose output -[no]pre: preamble block (on)\n\ ++ -dLevel: debug level -[no]acursec: section numbers (off)\n\ ++ ----- experimental ---- -raw: quote special chars(off)\n\ ++ -pt=Size: font size -jis: JIS code output\n\ ++ -sjis: Shift-JIS code input/output\n\ ++ -f file: output customization\n\n" ++ #define VERSION "plain2 r2.53 1994/01 by A.Uchida C&C Open Systems Lab. NEC\n\ ++ \t(HTML output) by k-chinen@is.aist-nara.ac.jp, NAIST" ++ #else + #define PLAIN2_USAGE_1 "\ + usage: plain2 [options] [files ...]\n\ + ---- parser options ---- ---- output options ----(default)\n\ +*************** usage: plain2 [options] [files ...]\n\ +*** 29,40 **** + -sjis: Shift-JIS code input/output\n\ + -f file: output customization\n" + #define VERSION "plain2 r2.54 1994/04 by A.Uchida NEC Corporation" + +! extern char *getenv(); + extern char *optarg; + extern int optind; + extern struct macDefs roffMacros[], roffMsMacros[]; + extern struct macDefs texMacros[]; + /* + * Default parameters for Parsing + */ +--- 56,72 ---- + -sjis: Shift-JIS code input/output\n\ + -f file: output customization\n" + #define VERSION "plain2 r2.54 1994/04 by A.Uchida NEC Corporation" ++ #endif + +! extern char *getenv(); + extern char *optarg; + extern int optind; + extern struct macDefs roffMacros[], roffMsMacros[]; + extern struct macDefs texMacros[]; ++ #ifdef HTML ++ extern struct macDefs htmlMacros[]; ++ #endif ++ + /* + * Default parameters for Parsing + */ +*************** int texQuote = 0; +*** 64,69 **** +--- 96,105 ---- + int fontSize = 10; + int fontSpecified = 0; + int verbose = 0; ++ #ifdef HTML ++ int htmlOnce = 0; ++ int htmlHere = 0; ++ #endif + char *plain2Lib = NULL; + char *macroName = NULL; + char *texStyle = NULL; +*************** doPlain2() +*** 163,176 **** + + if (firstTime) { + firstTime = 0; + if (put == &roffPut) { + if (roffMacro == MS_MACRO) + initMacroDefs(roffMsMacros); + initMacroDefs(roffMacros); + } +! else if (put == &texPut) + initMacroDefs(texMacros); +- if (put == &texPut) { + if (halfCooked) { + texSetTrans(0); + } +--- 199,224 ---- + + if (firstTime) { + firstTime = 0; ++ #ifdef HTML ++ if (put == &htmlPut) { ++ initMacroDefs(htmlMacros); ++ /* sorry, nothing is change this "if" */ ++ if (halfCooked) { ++ htmlSetTrans(0); ++ } ++ else { ++ htmlSetTrans(1); ++ } ++ } ++ else ++ #endif + if (put == &roffPut) { + if (roffMacro == MS_MACRO) + initMacroDefs(roffMsMacros); + initMacroDefs(roffMacros); + } +! else if (put == &texPut) { + initMacroDefs(texMacros); + if (halfCooked) { + texSetTrans(0); + } +*************** char **xargv; +*** 407,412 **** +--- 455,476 ---- + OUTPUT_OPTION("-alfraw"); + halfCooked = 1; + } ++ #ifdef HTML ++ else if (strcmp(optarg, "tmlonce") == 0) { ++ OUTPUT_OPTION("-htmlonce"); ++ htmlOnce = 1; ++ put = &htmlPut; ++ } ++ else if (strcmp(optarg, "tml") == 0) { ++ OUTPUT_OPTION("-html"); ++ htmlOnce = 0; ++ put = &htmlPut; ++ } ++ else if (strcmp(optarg, "ere") == 0) { ++ OUTPUT_OPTION("-here"); ++ htmlHere = 1; ++ } ++ #endif + else goto usage; + break; + case 't': +diff -p -c -r -N orig-plain2-2.53/src/plain2.h plain2/src/plain2.h +*** orig-plain2-2.53/src/plain2.h Fri Jan 7 05:34:50 1994 +--- plain2/src/plain2.h Wed Jan 19 19:10:16 1994 +*************** +*** 19,24 **** +--- 19,28 ---- + * 2.4: 28/04/92 + * 2.5: 06/08/93 + */ ++ /* ++ * modify by k-chinen@is.aist-nara.ac.jp, 1994 ++ */ ++ + #define NEC_CCS /* NEC C&C Common Software Lab. dependent */ + + #define NTT_TEX /* NTT jlatex */ +*************** extern int accurateSecnum; /* Accurate +*** 203,208 **** +--- 207,216 ---- + extern int listDecor; /* List decoration */ + extern int reflectSpace; /* reflect space lines */ + extern int texQuote; /* Use \verb| | for tex output */ ++ #ifdef HTML ++ extern int htmlOnce; /* One/Multi-path flag for HTML */ ++ extern int htmlHere; /* flag of pic/tbl here or not */ ++ #endif + extern int indexEnabled; /* Enables Indexing */ + extern int fontSize; /* font size */ + extern int fontSpecified; /* font size specified */ +*************** struct outDev { +*** 309,314 **** +--- 317,325 ---- + }; + extern struct outDev roffPut; + extern struct outDev texPut; ++ #ifdef HTML ++ extern struct outDev htmlPut; ++ #endif + extern struct outDev *put; + + #define INLINE_BEGIN "((" +diff -p -c -r -N orig-plain2-2.53/src/plain2html plain2/src/plain2html +*** orig-plain2-2.53/src/plain2html +--- plain2/src/plain2html Sun Aug 14 02:27:11 1994 +*************** +*** 0 **** +--- 1,159 ---- ++ #!/usr/local/bin/tcsh ++ # ++ # plain2html: plain text to HTML file ++ # by k-chinen@is.aist-nara.ac.jp , 1994 ++ # ++ # NOTE: ++ # * This script will be running under csh or tcsh. ++ # * Handle with care for directory, because this script make ++ # a lot of temporary file and output file. ++ # ++ ++ ++ # ++ # require: ++ # ++ # program: ++ # csh or tcsh ++ # plain2 ( have -html option verison ) ++ # awk ++ # groff ( gtbl, gpic ) ++ # latex or jlatex ++ # dvi2ps ++ # convert ( convertable PS to Any-format version ) ++ # pnmcrop ( included PBMPLUS ) ++ # ghostscript ( called by convert when convert PS format ) ++ # ++ # script: ++ # pt2htcol.awk ( included this packeage ) ++ # ++ # ++ # input: ++ # $1 (plain text file name. e.g., README.j) ++ # ++ # output: ++ # $1:r.html (e.g., README.html) ++ # ++ # temporary file: ++ # _src, _cut.sh , _out.html , pt2empty.sty, _tmp.pnm ++ # TBL*.p TBL*.ps TBL*.src TBL*.tex TBL*.dvi TBL*.pnm ++ # PIC*.p PIC*.ps PIC*.src PIC*.tex PIC*.dvi PIC*.pnm ++ # ++ ++ ++ # ++ # Default values ++ # ++ set tex=1 ++ set roff=0 ++ set lib=/usr/local/lib/plain2 ++ ++ ++ # ++ # Check args. ++ # ++ if ( $#argv > 0 ) then ++ switch ($1) ++ case -tex: ++ set tex=1 ++ set roff=0 ++ shift ++ breaksw ++ case -roff: ++ set tex=0 ++ set roff=1 ++ shift ++ breaksw ++ default: ++ breaksw ++ endsw ++ endif ++ ++ if ( $#argv > 0 ) then ++ set target=$1 ++ else ++ cat << END_USAGE ++ plain2html: plain text to HTML file ++ by k-chinen@is.aist-nara.ac.jp NAIST , 1994 ++ ++ usage: plain2html [option] input-filename ++ ++ option: -tex TeX mode (use latex, dvi2ps) [defauts] ++ -roff roff mode (use groff) ++ ++ END_USAGE ++ exit ++ endif ++ ++ ++ ++ # ++ # Start ++ # convert document's main body. ++ # collect table/picture location and cut these. ++ # ++ ++ echo "Copy Target $target ." ++ cp $target _src ++ ++ echo "Process document main body" ++ plain2 -html -jis -here _src > _out.html ++ ++ echo "Collect Table/Picutre" ++ awk -f $lib/pt2htcol.awk _out.html > _cut.sh ++ ++ ++ ++ # ++ # Convert parts(table/picture) via LaTeX ++ # If you don't have jlatex substitute to "latex". ++ # ( jlatex is Japanese LaTeX ) ++ # ++ if ( $tex ) then ++ cat << END_STYLEFILE > pt2empty.sty ++ \\thispagestyle{empty} ++ \\pagestyle{empty} ++ END_STYLEFILE ++ cat << END_TEX_CUT >> _cut.sh ++ foreach i ( TBL*.p PIC*.p ) ++ echo "Part \$i process" ++ plain2 -tex -jis -tstyle=pt2empty \$i > \$i:r.tex ++ jlatex \$i:r.tex ++ dvi2ps \$i:r.dvi > \$i:r.ps ++ convert -density 144x144 \$i:r.ps \$i:r.pnm ++ pnmcrop -white \$i:r.pnm > _tmp.pnm ++ convert _tmp.pnm \$i:r.gif ++ rm -f \$i:r.ps \$i:r.dvi \$i:r.aux \$i:r.log \$i:r.tex \$i:r.p \$i:r.pnm ++ end ++ END_TEX_CUT ++ endif ++ ++ # ++ # Convert parts(table/picture) via GROFF ++ # If you don't have gorff substitute to ROFF-like program. ++ # ++ if ( $roff ) then ++ cat << END_ROFF_CUT >> _cut.sh ++ foreach i ( TBL*.p PIC*.p ) ++ echo "Part \$i process" ++ plain2 -roff -euc \$i > \$i:r.src ++ groff -me -t -p \$i:r.src > \$i:r.ps ++ convert -density 144x144 \$i:r.ps \$i:r.pnm ++ pnmcrop -white \$i:r.pnm > _tmp.pnm ++ convert _tmp.pnm \$i:r.gif ++ rm -f \$i:r.ps \$i:r.src \$i:r.p \$i:r.pnm ++ end ++ END_ROFF_CUT ++ endif ++ ++ # ++ # Run parts conversion script ++ # ++ echo "Cut Table/Picture" ++ $shell _cut.sh ++ ++ rm -f $target:r.html ++ mv _out.html $target:r.html ++ rm -f _cut.sh pt2empty.sty _src _tmp.pnm ++ ++ echo "Complete" +diff -p -c -r -N orig-plain2-2.53/src/pt2htcol.awk plain2/src/pt2htcol.awk +*** orig-plain2-2.53/src/pt2htcol.awk +--- plain2/src/pt2htcol.awk Wed Jan 19 11:20:18 1994 +*************** +*** 0 **** +--- 1,20 ---- ++ # ++ # pt2htcol.awk: plain2html's parts collection awk-script. ++ # by k-chinen@is.aist-nara.ac.jp , 1994 ++ # ++ # plain2's (with -html) output have "plain2:TABLE" and "plain2:PICTURE" ++ # sentence. It is mean that output have link to TABLE and PICTURE. ++ # Therefore, this script collect such sentence and make cutting script. ++ # ++ BEGIN{ ++ } ++ /^\n", ++ M_APPENDIX, "\n", ++ M_BLANK, "\n", ++ M_PAGE, "\n\n", ++ M_NEWLINE, "\n\n", ++ M_CENTER_BEGIN, "\n", ++ M_CENTER_END, "\n", ++ M_RIGHT_BEGIN, "\n", ++ M_RIGHT_END, "\n", ++ M_INDENT, "
    \n", ++ M_INDENT0, "
    \n", ++ M_FOOTN_BEGIN, "", ++ M_FOOTN_END, "", ++ M_REFER_BEGIN, "GO", ++ M_BOLD_BEGIN, "", ++ M_BOLD_END, "", ++ M_INDEX_BEGIN, "", ++ M_INDEX_END, "", ++ M_SECTION_1, "\n

    @1

    \n", ++ M_SECTION_2, "\n

    @1

    \n", ++ M_SECTION_3, "\n

    @1

    \n", ++ M_SECTION_4, "\n

    @1

    \n", ++ M_SECTION_5, "\n
    @1
    \n", ++ M_SECTION, "", ++ M_SETSEC_1, "", ++ M_SETSEC_2, "", ++ M_SETSEC_3, "", ++ M_SETSEC_4, "", ++ M_SETSEC_5, "", ++ M_TITLE, "&1\n

    &1

    \n&6\n
    &4\n&3
    \n
    ", ++ -1, "", ++ }; ++ ++ ++ /* ++ * HTML text output routines ++ */ ++ ++ struct transTable *htmlTrans; ++ struct transTable *htmlTransM; ++ ++ static struct transTable htmlFullTrans[] = { ++ {'<', "<" }, ++ {'>', ">" }, ++ {'&', "&" }, ++ {0,0} }; ++ static struct transTable htmlFullTransM[] = { ++ {'<', "<" }, ++ {'>', ">" }, ++ {'&', "&" }, ++ {0,0} }; ++ ++ static struct transTable htmlHalfTrans[] = { ++ {'<', "<" }, ++ {'>', ">" }, ++ {'&', "&" }, ++ {0,0} }; ++ ++ static struct transTable htmlHalfTransM[] = { ++ {'<', "<" }, ++ {'>', ">" }, ++ {'&', "&" }, ++ {0,0} }; ++ ++ htmlSetTrans(full) ++ int full; ++ { ++ if (full) { ++ htmlTrans = htmlFullTrans; ++ htmlTransM = htmlFullTransM; ++ } ++ else { ++ htmlTrans = htmlHalfTrans; ++ htmlTransM = htmlHalfTransM; ++ } ++ } ++ ++ ++ char * ++ htmlTextQuote(str, quotable) ++ char *str; ++ int quotable; ++ { ++ char *s; ++ int len; ++ static char buf[MAX_LINE_LEN]; ++ ++ if (rawOutput) ++ return str; ++ ++ if (!quotable) ++ return textQuote(str, htmlTransM); ++ ++ return textQuote(str, htmlTrans); ++ } ++ ++ char *htmlQuote1(str) ++ char *str; ++ { ++ return htmlTextQuote(str, 1); ++ } ++ ++ char *htmlQuote2(str) ++ char *str; ++ { ++ return htmlTextQuote(str, 0); ++ } ++ ++ ++ htmlPutLabel(str) ++ char *str; ++ { ++ printf(" (here) ", codeCvt(str)); ++ } ++ ++ htmlPlain(str, attr, newline) ++ char *str; ++ int attr; ++ int newline; ++ { ++ if (attr == IL_RAW || attr == IL_REFERENCE) ++ printf("%s", codeCvt(str)); ++ else ++ printf("%s", codeCvt(htmlTextQuote(str, 1))); ++ if (newline) ++ printf("\n"); ++ } ++ ++ htmlExample(str) ++ char *str; ++ { ++ printf("%s\n",textQuote(str, htmlTrans)); ++ } ++ ++ static int enumLevel = 0; ++ htmlListBlock(begin, level, ltype, hint) ++ int begin; ++ int level; ++ int ltype; ++ char hint; ++ { ++ char *lstr; ++ if (begin) { ++ switch (ltype) { ++ case L_BULLET: ++ case L_DASH: ++ printf("
      \n"); ++ break; ++ case L_DLIST: ++ printf("
      \n"); ++ break; ++ case L_LROMAN: ++ case L_SROMAN: ++ case L_NUMBER: ++ case L_LALPHA: ++ case L_SALPHA: ++ enumLevel++; ++ printf("
        \n"); ++ break; ++ default: ++ break; ++ } ++ } ++ else { ++ switch (ltype) { ++ case L_BULLET: ++ case L_DASH: ++ printf("
    \n"); ++ break; ++ case L_LROMAN: ++ case L_SROMAN: ++ case L_NUMBER: ++ case L_LALPHA: ++ case L_SALPHA: ++ enumLevel--; ++ printf("\n"); ++ break; ++ case L_DLIST: ++ printf("\n"); ++ break; ++ default: ++ break; ++ } ++ } ++ } ++ ++ htmlDlistItem(level, dscr, cont) ++ int level; ++ char *dscr; ++ int cont; ++ { ++ printf("
    %s\n", codeCvt(htmlTextQuote(dscr, 1))); ++ } ++ ++ htmlListItem(level) ++ int level; ++ { ++ printf("
  • "); ++ } ++ ++ htmlRawText(str) ++ char *str; ++ { ++ printf("%s\n",codeCvt(str)); ++ } ++ ++ htmlSpace(length) ++ int length; ++ { ++ /* EMPTY --- I don't know what do here */ ++ } ++ ++ htmlFTitle(ft, str, capsule) ++ int ft; ++ char *str; /* if (str!=NULL) output title */ ++ int capsule; ++ { ++ static int figNumber = 1; ++ static int tblNumber = 1; ++ if (crossRefer && capsule) { ++ printf("%s\n", codeCvt(htmlTextQuote(str, 1))); ++ htmlPutLabel(str); ++ } ++ else { ++ printf ("

    "); ++ #ifdef KANJI ++ if (japaneseText) { ++ if (ft == FT_FIGURE) ++ printf (" %s %d.", codeCvt("$@?^(J"), figNumber++); ++ ++ else if (ft == FT_TABLE) ++ printf (" %s %d.", codeCvt("$@I=(J"), tblNumber++); ++ } ++ else { ++ #endif ++ if (ft == FT_FIGURE) ++ printf (" Figure %d.", figNumber++); ++ else if (ft == FT_TABLE) ++ printf (" Table %d.", tblNumber++); ++ #ifdef KANJI ++ } ++ #endif ++ printf ("%s\n", codeCvt(htmlTextQuote(str, 1))); ++ } ++ } ++ ++ #ifdef PICTURE ++ /* ++ * Driver for HTML(picture) output ++ */ ++ static int picLines; /* Number of lines in the block */ ++ static int picMinInd; /* Indentation of the region */ ++ ++ static int htmlVsize; ++ static int htmlUnit; ++ ++ htmlPictureBlock(begin, lines, indent, maxLen) ++ int begin; ++ int lines; ++ int indent; ++ int maxLen; ++ { ++ if(htmlOnce) { ++ if(begin) ++ printf("\n"); ++ } ++ else { ++ if(begin) ++ printf("\n"); ++ } ++ } ++ ++ /* set line width */ ++ htmlLineWidth(style) ++ int style; ++ { ++ /* */ ++ } ++ ++ htmlEllipse(x0, y0, x1, y1, style) ++ int x0, x1, y0, y1; ++ int style; ++ { ++ /* */ ++ } ++ ++ /* ++ * Draw line ++ * Only ({-1,0,1},{-1,0,1}) direction. ++ */ ++ htmlPicLine(x0, y0, x1, y1, style, vector) ++ int x0, x1, y0, y1; ++ int style; ++ int vector; ++ { ++ /* */ ++ } ++ ++ htmlPicArc(x, y, r, dir, style) ++ int x, y, r; ++ enum direction dir; ++ int style; ++ { ++ /* */ ++ } ++ ++ htmlPicText(s, xpos, vpos, factor) ++ char *s; ++ int xpos; ++ int vpos; ++ int factor; ++ { ++ /* */ ++ } ++ #endif ++ ++ ++ ++ htmlTitle(style, haifu, title, shozoku, number, date, name, renraku ++ #ifdef TITLE_SPECIAL ++ ,special8, special9 ++ #endif ++ ) ++ int style; ++ char **haifu; ++ char **title; ++ char **shozoku; ++ char **number; ++ char **date; ++ char **name; ++ char **renraku; ++ #ifdef TITLE_SPECIAL ++ char **special8, **special9; ++ #endif ++ { ++ char **s; ++ if (style == 0) { ++ putMacro(M_TITLE, ++ title, number, date, shozoku, haifu, name, renraku ++ #ifdef TITLE_SPECIAL ++ ,special8, special9 ++ #endif ++ ); ++ return; ++ } ++ } ++ ++ htmlTable(begin, end, tblp) ++ int begin; ++ int end; ++ struct table *tblp; ++ { ++ if(htmlOnce) { ++ if(rawOutput) { ++ int l; ++ ++ printf("

    \n");
    ++ 			for (l = begin; l < end; l++) {
    ++ 				htmlRawText(texts[l]->body);
    ++ 			}
    ++ 			printf("
    \n"); ++ } ++ else { ++ printf("\n"); ++ } ++ ++ } ++ else { ++ static int tbl_count=0; ++ printf("\n\n",tbl_count,begin,end); ++ ++ if(htmlHere) { ++ printf("

    \n", tbl_count); ++ } ++ else { ++ printf("

    Table here

    \n", ++ tbl_count); ++ } ++ tbl_count++; ++ } ++ } ++ ++ htmlCapsule(begin, type, center) ++ int begin; ++ int type; ++ int center; ++ { ++ static int count=0; ++ char *typeStr; ++ ++ if (crossRefer) { ++ switch (type) { ++ case FT_FIGURE: ++ typeStr = "figure"; ++ break; ++ case FT_TABLE: ++ typeStr = "table"; ++ break; ++ default: ++ fprintf(stderr, "PANIC(unknown capsule type)\n"); ++ exit(2); ++ break; ++ } ++ if (begin) { ++ count++; ++ printf("\n\n",count); ++ } ++ else { ++ printf("\n\n",count); ++ } ++ } ++ else /* short paper */ { ++ if (begin) { ++ printf("\n\n",count); ++ } ++ else { ++ printf("\n\n",count); ++ } ++ } ++ } ++ ++ htmlComment(begin, end) ++ int begin; ++ int end; ++ { ++ int l; ++ for (l = begin; l < end; l++) { ++ printf ("\n", codeCvt(texts[l]->body)); ++ } ++ } +diff -p -c -r -N orig-plain2-2.53/src/macro.c plain2/src/macro.c +*** orig-plain2-2.53/src/macro.c Fri Jan 7 05:34:40 1994 +--- plain2/src/macro.c Sun Aug 14 03:27:30 1994 +*************** char *fname; +*** 369,375 **** + } + if (ret == -1) + continue; +! s = (char *)malloc(strlen(defstr)); + strcpy(s, defstr); + outMacro[macroNum] = macroParse(s, macroNum, s); + } +--- 369,375 ---- + } + if (ret == -1) + continue; +! s = (char *)malloc(strlen(defstr)+1); + strcpy(s, defstr); + outMacro[macroNum] = macroParse(s, macroNum, s); + } +diff -p -c -r -N orig-plain2-2.53/src/output.c plain2/src/output.c +*** orig-plain2-2.53/src/output.c Fri Jan 7 05:34:46 1994 +--- plain2/src/output.c Wed Jan 19 19:08:44 1994 +*************** +*** 1,6 **** +--- 1,9 ---- + /* + * Copyright (C) 1991,1992,1993 NEC Corporation. + */ ++ /* ++ * modify by k-chinen@is.aist-nara.ac.jp, 1994 ++ */ + #ifndef lint + static char rcsid[] = + "$Id: plain2-2.53-html.94aug14.patch,v 1.1 1999/02/05 22:36:10 kohda Exp $ (NEC)"; +*************** static char rcsid[] = +*** 19,27 **** +--- 22,32 ---- + ?(textp)->body\ + :(textp)->body+(textp)->indent) + #endif ++ + /* + * Definition of Output driver routines. + */ ++ /***** roff *****/ + int roffPlain(), roffExample(), + roffListBlock(), roffDlistItem(), + roffListItem(), roffRawText(), roffSpace(), +*************** int roffPlain(), roffExample(), +*** 33,38 **** +--- 38,45 ---- + roffTable(), roffFTitle(), roffTitle(); + char *roffQuote1(), *roffQuote2(); + ++ ++ /***** TeX *****/ + int texPlain(), texExample(), + texListBlock(), texDlistItem(), + texListItem(), texRawText(), texSpace(), +*************** int texPlain(), texExample(), +*** 44,49 **** +--- 51,70 ---- + texTable(), texFTitle(), texTitle(); + char *texQuote1(), *texQuote2(); + ++ #ifdef HTML ++ /***** HTML *****/ ++ int htmlPlain(), htmlExample(), ++ htmlListBlock(), htmlDlistItem(), ++ htmlListItem(), htmlRawText(), htmlSpace(), ++ htmlCapsule(), htmlComment(), ++ #ifdef PICTURE ++ htmlPictureBlock(), htmlPicLine(), htmlPicArc(), ++ htmlPicText(), htmlLineWidth(), ++ #endif ++ htmlTable(), htmlFTitle(), htmlTitle(); ++ char *htmlQuote1(), *htmlQuote2(); ++ #endif ++ + struct outDev roffPut = { + roffPlain, roffExample, + roffListBlock, roffDlistItem, +*************** struct outDev texPut = { +*** 69,77 **** +--- 90,121 ---- + texTable, texFTitle, texTitle, + texQuote1, texQuote2, + }; ++ ++ #ifdef HTML ++ struct outDev htmlPut = { ++ htmlPlain, htmlExample, ++ htmlListBlock, htmlDlistItem, ++ htmlListItem, htmlRawText, htmlSpace, ++ htmlCapsule, htmlComment, ++ #ifdef PICTURE ++ htmlPictureBlock, htmlPicLine, htmlPicArc, ++ htmlPicText, htmlLineWidth, ++ #endif ++ htmlTable, htmlFTitle, htmlTitle, ++ htmlQuote1, htmlQuote2, ++ }; ++ #endif ++ ++ ++ #ifdef HTML + /* ++ * Output text in (roff, TeX or HTML) format. ++ */ ++ #else ++ /* + * Output text in (roff or TeX) format. + */ ++ #endif + + struct inline_mark { + char il_mark; +diff -p -c -r -N orig-plain2-2.53/src/picture.c plain2/src/picture.c +*** orig-plain2-2.53/src/picture.c Wed Dec 2 16:01:34 1992 +--- plain2/src/picture.c Wed Jan 19 19:09:26 1994 +*************** +*** 1,6 **** +--- 1,10 ---- + /* + * Copyright (C) 1991,1992 NEC Corporation. + */ ++ /* ++ * modify by k-chinen@is.aist-nara.ac.jp, 1994 ++ */ ++ + #ifndef lint + static char rcsid[]= + "$Id: plain2-2.53-html.94aug14.patch,v 1.1 1999/02/05 22:36:10 kohda Exp $ (NEC)"; +*************** int end; +*** 627,632 **** +--- 631,669 ---- + int l; + int maxLen; + int minInd; ++ ++ #ifdef HTML ++ static int pic_count=0; ++ if(put == &htmlPut) { ++ if(htmlOnce) { ++ if(rawOutput) { ++ printf("
    \n");
    ++ 		    for( l = begin; l < end; l++) {
    ++ 			htmlRawText(texts[l]->body);
    ++ 		    }
    ++ 		    printf("
    \n"); ++ } ++ else { ++ printf("\n"); ++ } ++ return ; ++ } ++ else { ++ printf("\n", ++ pic_count, begin, end); ++ if(htmlHere) { ++ printf("

    \n", pic_count); ++ } ++ else { ++ printf("

    Picture here

    \n", ++ pic_count); ++ } ++ pic_count++; ++ return ; ++ } ++ } ++ #endif /* HTML */ ++ + minInd = minIndent(begin, end); + maxLen = maxLength(begin, end); + if ((maxLen - minInd) * fontSize > pageWidth) +diff -p -c -r -N orig-plain2-2.53/src/plain2.c plain2/src/plain2.c +*** orig-plain2-2.53/src/plain2.c Fri Jan 7 18:40:47 1994 +--- plain2/src/plain2.c Wed Jan 19 19:09:44 1994 +*************** +*** 1,6 **** +--- 1,10 ---- + /* + * Copyright (C) 1991,1992,1994 NEC Corporation. + */ ++ /* ++ * modify by k-chinen@is.aist-nara.ac.jp, 1994 ++ */ ++ + #ifndef lint + static char rcsid[] = + "$Id: plain2-2.53-html.94aug14.patch,v 1.1 1999/02/05 22:36:10 kohda Exp $ (NEC)"; +*************** static char rcsid[] = +*** 12,17 **** +--- 16,44 ---- + #include "plain2.h" + #include "macro.h" + ++ #ifdef HTML ++ #define PLAIN2_USAGE_1 "\ ++ usage: plain2 [options] [files ...]\n\n\ ++ ---- parser options ---- ---- output options ----(default)\n\ ++ -table=dd: table factor [0-100](def=50) -roff: troff output\n\ ++ -exam=dd: example factor[0-100](def=50) -ms/-mm: troff macro (mm)\n\ ++ -indsec: sections can be indented -tex: tex output\n\ ++ -ktable:enable JIS keisen table -tstyle=ss:tex style\n\ ++ -ref: figure/picture reference -html: HTML output\n\ ++ -htmlonce: HTML (one path) output\n\ ++ -here: HTML table/picture ref.\n\ ++ -renum: renumbering only\n\ ++ -[no]listd:list decoration (on)\n\ ++ ---- Others ---- -[no]space:spacing (on)\n\ ++ -v: verbose output -[no]pre: preamble block (on)\n\ ++ -dLevel: debug level -[no]acursec: section numbers (off)\n\ ++ ----- experimental ---- -raw: quote special chars(off)\n\ ++ -pt=Size: font size -jis: JIS code output\n\ ++ -sjis: Shift-JIS code input/output\n\ ++ -f file: output customization\n\n" ++ #define VERSION "plain2 r2.53 1994/01 by A.Uchida C&C Open Systems Lab. NEC\n\ ++ \t(HTML output) by k-chinen@is.aist-nara.ac.jp, NAIST" ++ #else + #define PLAIN2_USAGE_1 "\ + usage: plain2 [options] [files ...]\n\ + ---- parser options ---- ---- output options ----(default)\n\ +*************** usage: plain2 [options] [files ...]\n\ +*** 29,40 **** + -sjis: Shift-JIS code input/output\n\ + -f file: output customization\n" + #define VERSION "plain2 r2.53 1994/01 by A.Uchida C&C Open Systems Lab. NEC" + +! extern char *getenv(); + extern char *optarg; + extern int optind; + extern struct macDefs roffMacros[], roffMsMacros[]; + extern struct macDefs texMacros[]; + /* + * Default parameters for Parsing + */ +--- 56,72 ---- + -sjis: Shift-JIS code input/output\n\ + -f file: output customization\n" + #define VERSION "plain2 r2.53 1994/01 by A.Uchida C&C Open Systems Lab. NEC" ++ #endif + +! extern char *getenv(); + extern char *optarg; + extern int optind; + extern struct macDefs roffMacros[], roffMsMacros[]; + extern struct macDefs texMacros[]; ++ #ifdef HTML ++ extern struct macDefs htmlMacros[]; ++ #endif ++ + /* + * Default parameters for Parsing + */ +*************** int texQuote = 0; +*** 64,69 **** +--- 96,105 ---- + int fontSize = 10; + int fontSpecified = 0; + int verbose = 0; ++ #ifdef HTML ++ int htmlOnce = 0; ++ int htmlHere = 0; ++ #endif + char *plain2Lib = NULL; + char *macroName = NULL; + char *texStyle = NULL; +*************** doPlain2() +*** 163,176 **** + + if (firstTime) { + firstTime = 0; + if (put == &roffPut) { + if (roffMacro == MS_MACRO) + initMacroDefs(roffMsMacros); + initMacroDefs(roffMacros); + } +! else if (put == &texPut) + initMacroDefs(texMacros); +- if (put == &texPut) { + if (halfCooked) { + texSetTrans(0); + } +--- 199,224 ---- + + if (firstTime) { + firstTime = 0; ++ #ifdef HTML ++ if (put == &htmlPut) { ++ initMacroDefs(htmlMacros); ++ /* sorry, nothing is change this "if" */ ++ if (halfCooked) { ++ htmlSetTrans(0); ++ } ++ else { ++ htmlSetTrans(1); ++ } ++ } ++ else ++ #endif + if (put == &roffPut) { + if (roffMacro == MS_MACRO) + initMacroDefs(roffMsMacros); + initMacroDefs(roffMacros); + } +! else if (put == &texPut) { + initMacroDefs(texMacros); + if (halfCooked) { + texSetTrans(0); + } +*************** char **xargv; +*** 407,412 **** +--- 455,476 ---- + OUTPUT_OPTION("-alfraw"); + halfCooked = 1; + } ++ #ifdef HTML ++ else if (strcmp(optarg, "tmlonce") == 0) { ++ OUTPUT_OPTION("-htmlonce"); ++ htmlOnce = 1; ++ put = &htmlPut; ++ } ++ else if (strcmp(optarg, "tml") == 0) { ++ OUTPUT_OPTION("-html"); ++ htmlOnce = 0; ++ put = &htmlPut; ++ } ++ else if (strcmp(optarg, "ere") == 0) { ++ OUTPUT_OPTION("-here"); ++ htmlHere = 1; ++ } ++ #endif + else goto usage; + break; + case 't': +diff -p -c -r -N orig-plain2-2.53/src/plain2.h plain2/src/plain2.h +*** orig-plain2-2.53/src/plain2.h Fri Jan 7 05:34:50 1994 +--- plain2/src/plain2.h Wed Jan 19 19:10:16 1994 +*************** +*** 19,24 **** +--- 19,28 ---- + * 2.4: 28/04/92 + * 2.5: 06/08/93 + */ ++ /* ++ * modify by k-chinen@is.aist-nara.ac.jp, 1994 ++ */ ++ + #define NEC_CCS /* NEC C&C Common Software Lab. dependent */ + + #define NTT_TEX /* NTT jlatex */ +*************** extern int accurateSecnum; /* Accurate +*** 203,208 **** +--- 207,216 ---- + extern int listDecor; /* List decoration */ + extern int reflectSpace; /* reflect space lines */ + extern int texQuote; /* Use \verb| | for tex output */ ++ #ifdef HTML ++ extern int htmlOnce; /* One/Multi-path flag for HTML */ ++ extern int htmlHere; /* flag of pic/tbl here or not */ ++ #endif + extern int indexEnabled; /* Enables Indexing */ + extern int fontSize; /* font size */ + extern int fontSpecified; /* font size specified */ +*************** struct outDev { +*** 309,314 **** +--- 317,325 ---- + }; + extern struct outDev roffPut; + extern struct outDev texPut; ++ #ifdef HTML ++ extern struct outDev htmlPut; ++ #endif + extern struct outDev *put; + + #define INLINE_BEGIN "((" +diff -p -c -r -N orig-plain2-2.53/src/plain2html plain2/src/plain2html +*** orig-plain2-2.53/src/plain2html +--- plain2/src/plain2html Sun Aug 14 02:27:11 1994 +*************** +*** 0 **** +--- 1,159 ---- ++ #!/usr/local/bin/tcsh ++ # ++ # plain2html: plain text to HTML file ++ # by k-chinen@is.aist-nara.ac.jp , 1994 ++ # ++ # NOTE: ++ # * This script will be running under csh or tcsh. ++ # * Handle with care for directory, because this script make ++ # a lot of temporary file and output file. ++ # ++ ++ ++ # ++ # require: ++ # ++ # program: ++ # csh or tcsh ++ # plain2 ( have -html option verison ) ++ # awk ++ # groff ( gtbl, gpic ) ++ # latex or jlatex ++ # dvi2ps ++ # convert ( convertable PS to Any-format version ) ++ # pnmcrop ( included PBMPLUS ) ++ # ghostscript ( called by convert when convert PS format ) ++ # ++ # script: ++ # pt2htcol.awk ( included this packeage ) ++ # ++ # ++ # input: ++ # $1 (plain text file name. e.g., README.j) ++ # ++ # output: ++ # $1:r.html (e.g., README.html) ++ # ++ # temporary file: ++ # _src, _cut.sh , _out.html , pt2empty.sty, _tmp.pnm ++ # TBL*.p TBL*.ps TBL*.src TBL*.tex TBL*.dvi TBL*.pnm ++ # PIC*.p PIC*.ps PIC*.src PIC*.tex PIC*.dvi PIC*.pnm ++ # ++ ++ ++ # ++ # Default values ++ # ++ set tex=1 ++ set roff=0 ++ set lib=/usr/local/lib/plain2 ++ ++ ++ # ++ # Check args. ++ # ++ if ( $#argv > 0 ) then ++ switch ($1) ++ case -tex: ++ set tex=1 ++ set roff=0 ++ shift ++ breaksw ++ case -roff: ++ set tex=0 ++ set roff=1 ++ shift ++ breaksw ++ default: ++ breaksw ++ endsw ++ endif ++ ++ if ( $#argv > 0 ) then ++ set target=$1 ++ else ++ cat << END_USAGE ++ plain2html: plain text to HTML file ++ by k-chinen@is.aist-nara.ac.jp NAIST , 1994 ++ ++ usage: plain2html [option] input-filename ++ ++ option: -tex TeX mode (use latex, dvi2ps) [defauts] ++ -roff roff mode (use groff) ++ ++ END_USAGE ++ exit ++ endif ++ ++ ++ ++ # ++ # Start ++ # convert document's main body. ++ # collect table/picture location and cut these. ++ # ++ ++ echo "Copy Target $target ." ++ cp $target _src ++ ++ echo "Process document main body" ++ plain2 -html -jis -here _src > _out.html ++ ++ echo "Collect Table/Picutre" ++ awk -f $lib/pt2htcol.awk _out.html > _cut.sh ++ ++ ++ ++ # ++ # Convert parts(table/picture) via LaTeX ++ # If you don't have jlatex substitute to "latex". ++ # ( jlatex is Japanese LaTeX ) ++ # ++ if ( $tex ) then ++ cat << END_STYLEFILE > pt2empty.sty ++ \\thispagestyle{empty} ++ \\pagestyle{empty} ++ END_STYLEFILE ++ cat << END_TEX_CUT >> _cut.sh ++ foreach i ( TBL*.p PIC*.p ) ++ echo "Part \$i process" ++ plain2 -tex -jis -tstyle=pt2empty \$i > \$i:r.tex ++ jlatex \$i:r.tex ++ dvi2ps \$i:r.dvi > \$i:r.ps ++ convert -density 144x144 \$i:r.ps \$i:r.pnm ++ pnmcrop -white \$i:r.pnm > _tmp.pnm ++ convert _tmp.pnm \$i:r.gif ++ rm -f \$i:r.ps \$i:r.dvi \$i:r.aux \$i:r.log \$i:r.tex \$i:r.p \$i:r.pnm ++ end ++ END_TEX_CUT ++ endif ++ ++ # ++ # Convert parts(table/picture) via GROFF ++ # If you don't have gorff substitute to ROFF-like program. ++ # ++ if ( $roff ) then ++ cat << END_ROFF_CUT >> _cut.sh ++ foreach i ( TBL*.p PIC*.p ) ++ echo "Part \$i process" ++ plain2 -roff -euc \$i > \$i:r.src ++ groff -me -t -p \$i:r.src > \$i:r.ps ++ convert -density 144x144 \$i:r.ps \$i:r.pnm ++ pnmcrop -white \$i:r.pnm > _tmp.pnm ++ convert _tmp.pnm \$i:r.gif ++ rm -f \$i:r.ps \$i:r.src \$i:r.p \$i:r.pnm ++ end ++ END_ROFF_CUT ++ endif ++ ++ # ++ # Run parts conversion script ++ # ++ echo "Cut Table/Picture" ++ $shell _cut.sh ++ ++ rm -f $target:r.html ++ mv _out.html $target:r.html ++ rm -f _cut.sh pt2empty.sty _src _tmp.pnm ++ ++ echo "Complete" +diff -p -c -r -N orig-plain2-2.53/src/pt2htcol.awk plain2/src/pt2htcol.awk +*** orig-plain2-2.53/src/pt2htcol.awk +--- plain2/src/pt2htcol.awk Wed Jan 19 11:20:18 1994 +*************** +*** 0 **** +--- 1,20 ---- ++ # ++ # pt2htcol.awk: plain2html's parts collection awk-script. ++ # by k-chinen@is.aist-nara.ac.jp , 1994 ++ # ++ # plain2's (with -html) output have "plain2:TABLE" and "plain2:PICTURE" ++ # sentence. It is mean that output have link to TABLE and PICTURE. ++ # Therefore, this script collect such sentence and make cutting script. ++ # ++ BEGIN{ ++ } ++ /^