I am looking at your "generate book with ps image" patch.
>>> For this workaround, I have to add a new environment "psxtcnooutput"
>>> in htex2input.awk and discard it by "skip-graphics.awk" for normal
>>> spool file generation.
>>
>> My feeling is that this is not necessary. I even do not quite
>> understand what the meaning of psxtcnooutput is. If I am not
>> completely wrong then
>> the commands inside \psXtc are anyway not run.
>
> With current HEAD, commands inside \psXtc are not run.
> My patch changes that. But the workaround changes that again,
> "skip-graphics.awk" is used to discard commands inside \psXtc to
> produce spool files. Then another run without "skip-graphics.awk"
> to produce the graphic files.
I somehow feel, that this complicates things.
Can we discuss the overall strategy here? The reason is that I would
like to ensure that the HyperDoc generation does not break.
As far as I understand and what I read from Makefile.in is that you
create with htex2input.awk two .input files. One is directly output and
is responsible for creating the graphics files (target
${HTEX_PICS_INPUT}) and the other one pipes that file through
skip-graphics.awk (target ${HTEX_FILES_INPUT}) to generate the .spool file.
Perhaps not a big deal but I looked through the \psXtc commands and to
me it seems that there are only a view cases that commands contained
inside \xtc are needed as a preparation step for \psXtc.
I would actually like to run only those preparation steps together with
the draw commands that produce the .ps files.
Second issue. Also not a big deal, but I was wondering about the newly
introduced src/input/ug-pics.input file. What I learned is that this
file is only there, because every \psXtc now creates a .ps file you have
changed htex2input.awk in such a way that it issues
print "write(%, \"tmp/" $0 "\", \"postscript\"); close(%)"
In particular, the "close(%)" causes the viewport to disappear although
there might be another command afterwards (like a "rotate(vp, 0, -90)"
in chapter 10) that works on the same viewport and produces another .ps
file. Seemingly, our patch puts these extra commands into ug-pics.input.
Yes, that works, but I am not so happy with moving the build logic to
separate handcrafted files.
I would like to suggest the following:
Change htex2input.awk (from "master") in such a way, that is produces
the same tmp/*.input file as in master and additionally a
tmp/pics-*.input file that only contains the commands needed to produce
all the pictures that appear in the respective .htex file.
For that to work we must mark places in the .htex file that have
preparation commands for the \psXtc stuff, like
\xtc{
Extract the space component of \spad{vp}.
}{
\spadcommand{sp := subspace(vp)\bound{d5}\free{d1}}
}
in chapter 10. Simply replacing \xtc by \xtcX and a few changes in
htex2input.awk should be enough.
To overcome the need for the handcrafted ug-pics.input file I suggest
the following.
htex2input.awk has a global variable openViewportExists that is
initialized to 0 at the beginning and set to 1 after any treatment of a
\psXtc command.
Note that in the HyperDoc documentation we find that the places where
viewports are newly created are already properly marked (mod bugs).
https://github.com/fricas/fricas/blob/master/src/doc/ht/HTXAdvPage5.ht#L23
That information can be used. \graphpaste is actually \spadgraph inside
the .htex file and they should only appear inside \psXtc. So, whenever
htex2input.awk sees \spadgraph and openViewportExists==1 then the
the command "close(OPENVIEWPORT)" has to be written to
'tmp/pics-*.input'. Yes, that means that htex2input.awk also must
remember the last created viewport. But that can be done. For
"\spadgraph{vp := draw(...)}" htex2input.awk writes out
OPENVIEWPORT := vp := draw(...)
to the tmp/pics-*.input file. And, of course, htex2input.awk, must contain
END {if (openViewportExists==1) {print "close(OPENVIEWPORT)"}}
Qian, what do you think?
Additionally, the HyperDoc side of the documentation generation only
uses the first two arguments of \psXtc, so we are free to redefine the
meaning of the third one.
That currently always contains something like
\epsffile[0 0 295 295]{
ribbon2.ps}
from which the filename is extracted. The stuff inside the square
brackets is not used (as far as I can see). So it would be enough to
simply change that so that \psXtc simply looks like
\psXtc{
some text
}{
\spadgraph{...}
}{
ribbon2.ps
}
However, I am not 100% sure whether we should do that, since the \psXtc
command should then also translate to
\includegraphics{
ribbon2.ps}
when it comes to .spool -> .tex translation. I think we do not need it
now, but having only the filename in \psXtc basically prevents us from
giving optional arguments to \includegraphics. OK, we could change
\psXtc{... to \psXtc[options]{ then and move the options to the
\includegraphics.
Opinions?
Ralf