LaTeXML

 view release on metacpan or  search on metacpan

lib/LaTeXML/Package/latexml.sty.ltxml  view on Meta::CPAN

# -*- mode: Perl -*-
# /=====================================================================\ #
# |  latexml.ltxml                                                      | #
# | Style file for latexml documents                                    | #
# |=====================================================================| #
# | Part of LaTeXML:                                                    | #
# |  Public domain software, produced as part of work done by the       | #
# |  United States Government & not subject to copyright in the US.     | #
# |---------------------------------------------------------------------| #
# | Bruce Miller <bruce.miller@nist.gov>                        #_#     | #
# | http://dlmf.nist.gov/LaTeXML/                              (o o)    | #
# \=========================================================ooo==U==ooo=/ #
package LaTeXML::Package::Pool;
use strict;
use warnings;
use LaTeXML::Package;
no warnings 'redefine';    # ????

#======================================================================
# LaTeXML Implementation of latexml customization bindings
#  * controlling various conversion options
#  * presentation customization
#  * semantic enhancement macros
#  * exposing internal functionality
#======================================================================

DefConditional('\iflatexml', sub { 1; });

#======================================================================
# Package Options
DeclareOption('ids',   sub { AssignValue('GENERATE_IDS' => 1, 'global'); });
DeclareOption('noids', sub { AssignValue('GENERATE_IDS' => 0, 'global'); });

DeclareOption('comments',   sub { AssignValue('INCLUDE_COMMENTS' => 1, 'global'); });
DeclareOption('nocomments', sub { AssignValue('INCLUDE_COMMENTS' => 0, 'global'); });

DeclareOption('tracing', sub {
    AssignValue(TRACING => (LookupValue('TRACING') || 0) | TRACE_ALL); });
DeclareOption('notracing', sub {
    AssignValue(TRACING => (LookupValue('TRACING') || 0) & ~TRACE_ALL); });
DeclareOption('profiling', sub {
    AssignValue(TRACING => (LookupValue('TRACING') || 0) | TRACE_PROFILE); });
DeclareOption('noprofiling', sub {
    AssignValue(TRACING => (LookupValue('TRACING') || 0) & ~TRACE_PROFILE); });

DeclareOption('mathparserspeculate',   sub { AssignValue('MATHPARSER_SPECULATE' => 1, 'global'); });
DeclareOption('nomathparserspeculate', sub { AssignValue('MATHPARSER_SPECULATE' => 0, 'global'); });

DeclareOption('guesstabularheaders',   sub { AssignValue(GUESS_TABULAR_HEADERS => 1, 'global'); });
DeclareOption('noguesstabularheaders', sub { AssignValue(GUESS_TABULAR_HEADERS => 0, 'global'); });

# 'nobibtex' intended to be used for arXiv-like build harnesses, where there
# is explicit instruction to only use ".bbl" and that bibtex will not be ran.
DeclareOption('bibtex',   sub { AssignValue('NO_BIBTEX' => 0, 'global'); });
DeclareOption('nobibtex', sub { AssignValue('NO_BIBTEX' => 1, 'global'); });

# Lexeme serialization for math formulas
DeclareOption('mathlexemes', sub { AssignValue('LEXEMATIZE_MATH' => 1, 'global'); });

# Finer control over which (if any) raw .sty/.cls files to include
DeclareOption('rawstyles',      sub { AssignValue('INCLUDE_STYLES'  => 1,             'global'); });
DeclareOption('localrawstyles', sub { AssignValue('INCLUDE_STYLES'  => 'searchpaths', 'global'); });
DeclareOption('norawstyles',    sub { AssignValue('INCLUDE_STYLES'  => 0,             'global'); });
DeclareOption('rawclasses',     sub { AssignValue('INCLUDE_CLASSES' => 1,             'global'); });
DeclareOption('localrawclasses', sub { AssignValue('INCLUDE_CLASSES' => 'searchpaths', 'global'); });
DeclareOption('norawclasses',    sub { AssignValue('INCLUDE_CLASSES' => 0, 'global'); });

# Avoid extra line-breaks in UnTeX
DeclareOption('breakuntex',   sub { AssignValue('SUPPRESS_UNTEX_LINEBREAKS' => 0, 'global'); });
DeclareOption('nobreakuntex', sub { AssignValue('SUPPRESS_UNTEX_LINEBREAKS' => 1, 'global'); });

DefConstructor('\lx@save@parameter{}{}', sub {
    $_[0]->insertPI('latexml', ToString($_[1]) => $_[2]); });
DefKeyVal('LTXML', 'dpi', 'Number', '', code => sub {
    $STATE->assignValue(DPI => ToString($_[1]));
    AtBeginDocument(Tokens(T_CS('\lx@save@parameter'), T_OTHER('DPI'), T_BEGIN, $_[1], T_END)); });
DefKeyVal('LTXML', 'magnify', 'Number', '', code => sub {
    AtBeginDocument(Tokens(T_CS('\lx@save@parameter'), T_OTHER('magnifiy'), T_BEGIN, $_[1], T_END)); });
DefKeyVal('LTXML', 'upsample', 'Number', '', code => sub {
    AtBeginDocument(Tokens(T_CS('\lx@save@parameter'), T_OTHER('upsample'), T_BEGIN, $_[1], T_END)); });
DefKeyVal('LTXML', 'zoomout', 'Number', '', code => sub {
    AtBeginDocument(Tokens(T_CS('\lx@save@parameter'), T_OTHER('zoomout'), T_BEGIN, $_[1], T_END)); });
DefKeyVal('LTXML', 'tokenlimit', 'Number', '', code => sub {
    $LaTeXML::TOKEN_LIMIT = int(ToString($_[1]));
    return; });
DefKeyVal('LTXML', 'iflimit', 'Number', '', code => sub {
    $LaTeXML::IF_LIMIT = int(ToString($_[1]));
    return; });
DefKeyVal('LTXML', 'absorblimit', 'Number', '', code => sub {
    $LaTeXML::ABSORB_LIMIT = int(ToString($_[1]));
    return; });
DefKeyVal('LTXML', 'pushbacklimit', 'Number', '', code => sub {
    $LaTeXML::PUSHBACK_LIMIT = int(ToString($_[1]));
    return; });

ProcessOptions(inorder => 1, keysets => ['LTXML']);
#======================================================================
# From latexml.sty
# Making these all be links, every time, seems in hindsight rather obnoxious.
# OTOH, would be nice to have an idiom to make (some of) them be links; or only the first one?
# [does this really belong here? or should this be disableable?]
DefConstructor('\URL[] Verbatim', "<ltx:ref href='#href'>?#1(#1)(#href)</ltx:ref>",
  properties => sub { (href => CleanURL($_[2])); });
DefMacro('\XML',      '\textsc{xml}');     # '\URL[\texttt{XML}]{http://www.w3.org/XML/}');
DefMacro('\SGML',     '\textsc{sgml}');    # '\URL[\texttt{HTML}]{http://www.w3.org/MarkUp/SGML/}');
DefMacro('\HTML',     '\textsc{html}');    #'\URL[\texttt{HTML}]{http://www.w3.org/html/}');
DefMacro('\XHTML',    '\textsc{xhtml}');   #'\URL[\texttt{XHTML}]{http://www.w3.org/TR/xhtml11/}');
DefMacro('\XSLT',     '\textsc{xslt}');    # '\URL[\texttt{XSLT}]{http://www.w3.org/Style/XSL/}');
DefMacro('\CSS',      '\textsc{css}');     #'\URL[\texttt{CSS}]{http://www.w3.org/Style/CSS/}');
DefMacro('\MathML',   '\texttt{MathML}');  # '\URL[\texttt{MathML}]{http://www.w3.org/Math/}');
DefMacro('\OpenMath', '\texttt{OpenMath}');  # '\URL[\texttt{OpenMath}]{http://www.openmath.org/}');
##DefMacro('\LaTeXML',  '\URL[\texttt{LaTeXML}]{http://dlmf.nist.gov/LaTeXML/}');
#DefMacro('\BibTeX','BibTeX');

# Link is maybe a bit pushy? (by default)
#DefMacro('\LaTeXML', '\URL[\LaTeXML@logo]{http://dlmf.nist.gov/LaTeXML/}');
DefMacro('\LaTeXML', '\LaTeXML@logo');



( run in 0.697 second using v1.01-cache-2.11-cpan-437f7b0c052 )