File: html.sty.ltxml

package info (click to toggle)
latexml 0.8.8-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,920 kB
  • sloc: xml: 109,048; perl: 30,224; sh: 179; javascript: 28; makefile: 13
file content (109 lines) | stat: -rw-r--r-- 5,014 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# -*- mode: Perl -*-
# /=====================================================================\ #
# |  html                                                               | #
# | Implementation for LaTeXML                                          | #
# |=====================================================================| #
# | 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;

RequirePackage('hyperref');
#**********************************************************************
# A quite perverse redefinition allows an optional arg after the \begin
# which presumably supplies some sort of style info....
# we'll ignore it, but we do at least have to parse
DefMacro('\begin[]{}', sub {
    my ($gullet, $style, $env) = @_;
    my $name = $env && ToString($env);
    if (LookupDefinition(T_CS("\\begin{$name}"))) {
      T_CS("\\begin{$name}"); }    # Magic cs!
    else {                         # If not defined, let stomach handle it.
      (T_CS('\begingroup'), T_CS("\\$name")); } });
#======================================================================
DefMacro('\latextohtml',                              '\LaTeX2\texttt{HTML}');
DefMacro('\htmladdnormallinkfoot{}{}',                '\href{#2}{#1}');
DefMacro('\htmladdnormallink{}{}',                    '\href{#2}{#1}');
DefMacro('\htmladdimg{}',                             '\hyperimage{#1}');
DefMacro('\externallabels Semiverbatim Semiverbatim', '');
DefMacro('\externalref{}',                            '');                       # ???
DefMacro('\externalcite',                             '\nocite');
DefMacro('\htmladdTOClink[]{}{}{}',                   '');
DefConstructor('\htmlrule OptionalMatch:*', '<ltx:rule/>');
DefConstructor('\HTMLrule OptionalMatch:*', '<ltx:rule/>');
DefConstructor('\htmlclear',                '<ltx:br/>');
DefMacro('\bodytext{}', '');
DefMacro('\htmlbody',   '');

DefConstructor('\hyperrefdef {} {}{} Semiverbatim', "<ltx:ref labelref='#label'>#1</ltx:ref>",
  properties => sub { (label => CleanLabel($_[4])); });

Let('\hyperrefhyper',   '\hyperrefdef');
Let('\hyperrefpagedef', '\hyperrefdef');
Let('\hyperrefnoref',   '\hyperrefdef');
Let('\hyperrefhtml',    '\hyperrefdef');

DefConstructor('\hypercite [] {}{} [] Semiverbatim',
"<ltx:cite>#4 <ltx:bibref bibrefs='#5'>?#2(<ltx:bibrefphrase>#2</ltx:bibrefphrase>)</ltx:bibref> #1</ltx:cite>");
DefMacro('\htmlcite{}{}', '\hypercite{#1}{}{#2}');
DefMacro('\htmlimage{}',  '');
DefMacro('\htmlborder{}', '');
DefEnvironment('{makeimage}',         '#body');
DefEnvironment('{tex2html_deferred}', '#body');
DefMacro('\htmladdtonavigation{}', '');

# These get excluded, since we probably don't even want to try to include html?
#DefEnvironment('{rawhtml}','');
#DefEnvironment('{htmlonly}','');
DefConstructorI(T_CS("\\begin{rawhtml}"), undef, '', reversion => '',
  afterDigest => [sub {
      my ($stomach, $whatsit) = @_;
      my $endmark = "\\end{rawhtml}";
      my $nlines  = 0;
      my ($line);
      my $gullet = $stomach->getGullet;
      $gullet->readRawLine;    # IGNORE 1st line (after the \begin{$name} !!!
      while (defined($line = $gullet->readRawLine) && ($line ne $endmark)) {
        $nlines++; }
      NoteLog("Skip rawhtml ($nlines lines)"); }]);

DefConstructorI(T_CS("\\begin{htmlonly}"), undef, '', reversion => '',
  afterDigest => [sub {
      my ($stomach, $whatsit) = @_;
      my $endmark = "\\end{htmlonly}";
      my $nlines  = 0;
      my ($line);
      my $gullet = $stomach->getGullet;
      $gullet->readRawLine;    # IGNORE 1st line (after the \begin{$name} !!!
      while (defined($line = $gullet->readRawLine) && ($line ne $endmark)) {
        $nlines++; }
      NoteLog("Skip htmlonly ($nlines lines)"); }]);

DefMacro('\html{}', '');
# I assume we should go ahead and try to include this material?
DefEnvironment('{latexonly}', '#body');
# If we get a plain \latexonly, instead of an environment,
# look for \latexonly{some material}
DefMacro('\latexonly', sub {
    my ($gullet) = @_;
    ($gullet->ifNext(T_BEGIN) ? T_CS('\latexonly@onearg') : T_CS('\begin{latexonly}')); });
DefMacro('\latexonly@onearg{}', '#1');

DefMacro('\latex{}',       '#1');
DefMacro('\latexhtml{}{}', '#1');

DefMacro('\strikeout{}',          '#1');
DefMacro('\htmlurl Semiverbatim', '\url{#1}');

DefMacro('\HTMLset{}{}',              '');
DefMacro('\htmlinfo OptionalMatch:*', '');
# Not implemented!
#**********************************************************************
1;