@@ -14,19 +14,25 @@ all: pdf
1414 rm -fr ${TMPDIR}
1515
1616copy_eus_tex :
17- exit
1817 -mkdir -p ${TMPDIR} /fig
1918 cp ../eus/doc/jlatex/* .tex ${TMPDIR}
2019 cp ../eus/doc/jlatex/* .sty ${TMPDIR}
2120 cp -r ../eus/doc/jlatex/fig/* ./fig/* ${TMPDIR} /fig/
22- for x in ${TMPDIR} /fig/* .jpg; do ebb -b $$ x; extractbb $$ x; done
21+ (cd ${TMPDIR} ; for x in fig/* .ps; do ps2ps $$ x $$ x.new; mv $$ x.new $$ x; done) # ## ???? we need to run ps2ps to pass gs??
22+ (cd ${TMPDIR} ; for x in fig/* .jpg; do extractbb $$ x; done) # workaround for https://github.com/backtracking/bibtex2html/issues/9
2323 cp * .tex ${TMPDIR}
2424 platex --version | grep utf8 || nkf --in-place -e ${TMPDIR} /* .tex
2525 for x in irtrobot irtmodel irtsensor irtscene irtdyna irtgeo irtgl irtutil irtviewer irtx irtmath irtbvh irtcollada irtgraph irtimage irtpointcloud png pqp; do\
2626 irteusgl ../eus/lib/llib/documentation.l " (make-document \" ../irteus/$$ x.l\" \" ${TMPDIR} /$$ x-func.tex\" )" " (exit)" ; \
2727 done
2828
29- toc : copy_eus_tex
29+ current.tex :
30+ echo " % CURRENT_TAG" > ${TMPDIR} /current.tex
31+ echo " \\\\ newcommand{\\\\ eusversion}[0]{" ` cd ../eus; git describe --tags $$ (git rev-list --tags --max-count=1) | sed s/EusLisp-//` " }" >> ${TMPDIR} /current.tex
32+ echo " \\\\ newcommand{\\\\ irteusversion}[0]{" ` git describe --tags $$ (git rev-list --tags --max-count=1)` " }" >> ${TMPDIR} /current.tex
33+ cat ${TMPDIR} /current.tex
34+
35+ toc : copy_eus_tex current.tex
3036 (cd ${TMPDIR} ; makeindex jmanual.tex)
3137
3238dvi : toc
@@ -45,17 +51,46 @@ clean:
4551distclean : clean
4652 rm -f * .dvi * .pdf
4753
48- html : copy_eus_tex
49- nkf --in-place -u ${TMPDIR} /* .tex
50- mkdir ${TMPDIR} /html
51- sed -i ' s@^\(\\\usepackage.*{hyperref}\)@%\1@' ${TMPDIR} /jmanual.tex
52- sed -i ' s@\\\documentclass\[\]{jarticle}@\\\documentclass\[\]{article}@' ${TMPDIR} /jmanual.tex
53- sed -i ' s@^\\\ifnum 42146@%\\\ifnum 42146@' ${TMPDIR} /jmanual.tex
54- (cd ${TMPDIR} ; charset=" UTF-8" latex2html -dir ${TMPDIR} /html -local_icons -auto_prefix -iso_language JP jmanual)
54+ html : dvi
55+ mkdir -p ${TMPDIR} /html
56+ (cd ${TMPDIR} ; TRANSPARENT_COLOR=" #ffffff" charset=" UTF-8" latex2html -dir ${TMPDIR} /html -local_icons -split +3 -auto_prefix -init_file ${PWD} /../eus/doc/latex/.latex2html-init -iso_language JP -address " This document was generated using the LaTeX2HTML translator on ` date` from <a href=\" http://github.com/euslisp/jskeus.git\" >jskeus</a> version <a href=\" http://github.com/euslisp/jskeus/commit/` git -C ${PWD} rev-parse --verify HEAD` \" >` git log -1 --oneline` </a>" -html_version=" 4.0,unicode" jmanual)
57+ (cd ${TMPDIR} /html; for imgfile in jmanual-img* .png; do pngtopnm $$ imgfile > /tmp/$$ imgfile.pnm; pnmtopng -transparent white /tmp/$$ imgfile.pnm > $$ imgfile || echo " Failed to convert $$ imgfile" ; done)
5558 (cd ${TMPDIR} /html; sed -i ' s@</TITLE>@</TITLE>\n<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">@' j* .html index.html)
56- sed -i ' s@%\(\\\usepackage.*{hyperref}\)@\1@' ${TMPDIR} /jmanual.tex
57- sed -i ' s@\\\documentclass\[\]{article}@\\\documentclass\[\]{jarticle}@' ${TMPDIR} /jmanual.tex
58- sed -i ' s@^%\\\ifnum 42146@\\\ifnum 42146@' ${TMPDIR} /jmanual.tex
5959 cp -r ${TMPDIR} /html ./
60- rm -fr ${TMPDIR}
60+
61+ latex.py :
62+ wget https://raw.githubusercontent.com/jobh/latex.py/master/latex.py
63+
64+ rst : current.tex copy_eus_tex latex.py
65+ cp latex.py ../eus/doc/latex/preamble.tex ${TMPDIR}
66+ for file in ${TMPDIR} /* .tex; do \
67+ name=` basename $$ file .tex` ; \
68+ if [ \" $$ name\" = \" test\" -o \" $$ name\" = \" jmanual\" ]; then continue ; fi ; \
69+ echo \" Converting $$ name.tex to $$ name.rst\" ; \
70+ (cd ${TMPDIR} ; python3 latex.py -2 -L preamble.tex $$ name.tex > /tmp/tmp_$$ name.tex); \
71+ pandoc /tmp/tmp_$$ name.tex -o $$ name.rst -V documentclass=ltjarticle --latex-engine=lualatex; \
72+ sed -i ' s@.. figure:: \(.*\).ps@.. figure:: \1.png@g' $$ name.rst; # use png for figures \
73+ done
74+ for file in ../eus/doc/jlatex/fig/* .ps; do \
75+ name=` basename $$ file .ps` ; \
76+ echo \" Converting $$ name.ps to $$ name.png\" ; # ## ???? we need to run ps2ps to pass gs?? does not happy with pstopnm \
77+ pstopnm -stdout ../eus/doc/jlatex/fig/$$ name.ps | pnmflip -rotate270 | pnmtopng - > fig/$$ name.png; \
78+ done
79+ cp jmanual.tex /tmp/jmanual.tex
80+ sed -i ' s@\\input{\(.*\)}@..include:: \1\n@g' /tmp/jmanual.tex # ## convert \input in tex to bypass pandoc EXCEPT current
81+ sed -i ' /..include:: current/r ${TMPDIR}/current.tex' /tmp/jmanual.tex # ## convert \input in tex to bypass pandoc EXCEPT current
82+ sed -i ' s@\\part{\(.*\)}@.. toctree:: \1@' /tmp/jmanual.tex # convert \part in tex to bypass pandoc
83+ sed -i ' :a;/^[^%].*\\\\$$/{N;s/\\\\\n//;ba}' /tmp/jmanual.tex # concatinate title/author multi lines
84+ sed -i ' /^\\vspace{10mm}$$/d' /tmp/jmanual.tex # remove vspace{10mm} within title to pass pandoc
85+ pandoc --no-wrap -s /tmp/jmanual.tex -o jmanual.rst -V documentclass=ltjarticle --latex-engine=lualatex
86+ sed -i
' [email protected] :: \(.*\)@ \1@' jmanual.rst
# restore ..include for rst87+ sed -i ' s@.. toctree:: \(.*\)@.. toctree::\n :maxdepth: 2\n :caption: \1@' jmanual.rst # restore ..toctree for rst
88+ sed -i ' s@\*\* \*\*@\*\*\n\*\*@g' jmanual.rst # add newline after ** ** in title
89+ sed -i ' s@** -\(.*\)$$@**\n\n-\1\n@' jmanual.rst # add newline before -ロボットモデリングの拡張 in title
90+ sed -i -ne ' 3!{p;d;};h;n;p;g;p' jmanual.rst # # swap 2nd and 3rd line
91+ sed -i -ne ' 4!{p;d;};h;n;:1;7!{N;b1};G;h;n;p;g;p' jmanual.rst # # swap lines https://www.unix.com/shell-programming-and-scripting/85230-swapping-switching-2-lines-using-sed.html
92+ sed -i -ne ' 2h;2!H;$${g;s/\n/ /;p}' jmanual.rst # # concatenate EusLisp and Reference Manual (https://unix.stackexchange.com/questions/188264/want-to-substitute-only-first-occurence-with-sed)
93+ sed -i ' s/^:Author:/:Authors: -/' jmanual.rst # use :authors: insteqad of :author:
94+ sed -ie ' /^:Authors:/ {p;s/.*//;N; s/\n/\ \ \ \ \ \ \ \ \ \ -\ /;}' jmanual.rst # add authors after :authors:
95+ head -n 20 jmanual.rst
6196
0 commit comments