1. rbeezer
  2. tex2sws


tex2sws / tex4ht-sage.cfg

%            Copyright 2010 Robert A. Beezer <beezer@ups.edu>
%  Distributed under the terms of the GNU General Public License (GPL),
%  version 2 or any later version.  The full text of the GPL is available at:
%                     http://www.gnu.org/licenses/
% tex4ht-sage.cfg
% Supplies info for jsmath version to tex4ht command line and preamble
%   2009/01/28  Modified to build sage worksheets, dropped font info
%   2010/02/20  Significant improvements, many from Robert Marik
% Call as   htlatex <tex-source-file> "tex4ht-sage.cfg" " -cunihtf -utf8"
%   Implements environments of the sagetex package
%   Wraps contents of these environments with the
%   tags <sage>,</sage> as markers.
%   Then a script converts contents to
%   SAGE worksheet cell format
%   CSS additions to fine-tune jsMath spacing
%       suggested by David Cervone (jsMath author)
% Managing unicode fonts
% ----------------------
%   To restore minus symbol '-' from its translation to &#x2212;
%   use method described in
%   http://www.cse.ohio-state.edu/~gurari/docs/tug-07/tug07-10.xht
%   i.e. copy the hypertext font encoding file
%   texmf/tex4ht/ht-fonts/mozilla/charset/unicode.4hf to the work
%   directory and add the following record to the file:
%   '&#x2212;' '' '-' ''
%   To restore "'" from its translation to &#x2019; search the same file 
%   unicode.4htf for line begining with '&#x2019;' and replace by 
%   +&#x2019;+ ++ +'+ ++
%   with this setting the word "don't" remains as is and not "don&#x2019;t"

% Driver for graphs (remember that style=Art does not wok well in TeX4ht)

% No labels printed in resulting svg without this setting


\def\tempc#1#2{\ScriptEnv{#1}{\ifvmode \IgnorePar \else \break\fi
{\ifvmode \IgnorePar \fi
  \EndP\HCode{</sage>}\EndNoFonts\csname par\endcsname\ShowPar}

\Css{/* jsMath suggested additions for spacing control */}
\Css{.jsMath_hiddenSpan {text-indent: 0px}}
\Css{.typeset {text-indent: 0px}} 

% ----------------------- Configuring output of \sage, \sagestr, \sageplot
% We read the outputs of Sage stored at \jobname.sout. 
% We read this file at \begin{document} to make ^ and _ work properly.
% As a sideeffect we have to redefine \@latex@warning@no@line 
% to suppress false warning related to multiply defined labels.
\InputIfFileExists{\jobname.sout}{}{\typeout{No file \jobname.sout.}}
}% restore \@latex@warning@no@line

% ----------------------- Configuring \sage, \sagestr, \sageplot
% The following lines produce input fields from \sage, \sagestr and
% \sageplot macros \sage and \sagestr simply pass the content,
% \sageplot wraps the content with show function
\def\savesage#1{\HCode{<sage>\Hnewline #1\Hnewline</sage>\Hnewline}}

% PNG graphics is O.K.
        {\Picture[pict]{\csname Gin@base\endcsname .png}}  

% JPG graphics is O.K.
        {\Picture[pict]{\csname Gin@base\endcsname .jpg}}  

 _st_.plot(\theST@plot, format='#2', _p_=#3)^^Jexcept:^^J
        {% changed by Robert Marik - no error for png pictures
         % since png graphics is O.K. with tex4ht 
         { \ST@inclgrfx{#1}{#2}}%
         \PackageWarning{sagetex}{Graphics file
         \ST@plotdir/plot-\theST@plot.#2\space on page \thepage\space
         cannot be used with DVI output. Use pdflatex or create an EPS
         file. Plot command is}}%
       }% end of changes related to png graphics
         \PackageWarning{sagetex}{Graphics file
         \ST@plotdir/plot-\theST@plot.#2\space on page \thepage\space
         does not exist. Plot command is}%


% ----------------------- Configuring inline math
% The following lines keep dollars as delimiters of mathematics
% and removes 
% ----------------------- End configuring inline math

% ----------------------- Configuring math
% removes html comments from math (causes bad rendering in some browsers)
% code from html-jsmath.4ht with removed \HCode{<!--l. \the\inputlineno-->}
    {\a:DviJsmath \mathltxtrue
       \IgnoreRule \ifx \a:@math\empty\else
               \Tg<\a:@math\space class="math"\Hnewline >\fi
    \noexpand\IgnorePar\else \noexpand\ShowPar\fi}%
    {\ifx \a:@math\empty\else \Tg</\a:@math>\fi \EndIgnoreRule
     \mathltxfalse \After:Math \b:DviJsmath \sv:ignore
% ----------------------- End configuring math

\def\tempc#1{\def\temp{\HCode{\string#1}\HCode{ }}\HLet#1\temp}