summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/stex/omtext
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-04-07 20:49:10 +0000
committerKarl Berry <karl@freefriends.org>2016-04-07 20:49:10 +0000
commitddfe3a4eaf95167482e923d4da3de2917a7dbfbb (patch)
tree0acc1bb60b37392451f5e79e00c33c487c19abcf /Master/texmf-dist/tex/latex/stex/omtext
parenta04ae5a947a6b06bc717719f6ad63e6de5cb5af6 (diff)
stex (7apr16)
git-svn-id: svn://tug.org/texlive/trunk@40320 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/stex/omtext')
-rw-r--r--Master/texmf-dist/tex/latex/stex/omtext/omtext.sty136
-rw-r--r--Master/texmf-dist/tex/latex/stex/omtext/omtext.sty.ltxml223
2 files changed, 93 insertions, 266 deletions
diff --git a/Master/texmf-dist/tex/latex/stex/omtext/omtext.sty b/Master/texmf-dist/tex/latex/stex/omtext/omtext.sty
index d57be46a147..1215638aeb9 100644
--- a/Master/texmf-dist/tex/latex/stex/omtext/omtext.sty
+++ b/Master/texmf-dist/tex/latex/stex/omtext/omtext.sty
@@ -7,14 +7,21 @@
%% omtext.dtx (with options: `package')
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
-\ProvidesPackage{omtext}[2012/01/28 v1.0 OMDoc Text Fragments]
-\DeclareOption{showmeta}{\PassOptionsToPackage{\CurrentOption}{metakeys}}
+\ProvidesPackage{omtext}[2016/04/06 v1.1 OMDoc Text Fragments]
+\newif\if@omtext@mh@\@omtext@mh@false
+\DeclareOption{mh}{\@omtext@mh@true
+\PassOptionsToPackage{\CurrentOption}{modules}}
\newif\ifindex\indextrue
\DeclareOption{noindex}{\indexfalse}
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{modules}}
\ProcessOptions
\ifindex\makeindex\fi
-\RequirePackage{sref}
+\if@omtext@mh@\RequirePackage{omtext-mh}\fi
+\RequirePackage{xspace}
+\RequirePackage{modules}
\RequirePackage{comment}
+\RequirePackage{mdframed}
+\RequirePackage{latexsym}
\srefaddidkey{omtext}
\addmetakey[]{omtext}{functions}
\addmetakey*{omtext}{display}
@@ -27,28 +34,46 @@
\addmetakey{omtext}{continues}
\addmetakey{omtext}{verbalizes}
\addmetakey{omtext}{subject}
+\define@key{omtext}{require}{\requiremodules{#1}{sms}}
+\define@key{omtext}{module}{\message{module: #1}\importmodule{#1}\def\omtext@theory{#1}}
\def\st@flow{flow}
+\newif\if@in@omtext\@in@omtextfalse
\def\omtext@pre@skip{\smallskip}
\def\omtext@post@skip{}
\providecommand{\stDMemph}[1]{\textbf{#1}}
-\newenvironment{omtext}[1][]{\bgroup\metasetkeys{omtext}{#1}\sref@label@id{this paragraph}%
-\def\lec##1{\@lec{##1}}
+\newenvironment{omtext}[1][]{\@in@omtexttrue%
+\bgroup\metasetkeys{omtext}{#1}\sref@label@id{this paragraph}%
+\def\lec##1{\@lec{##1}}%
\ifx\omtext@display\st@flow\else\omtext@pre@skip\par\noindent%
-\ifx\omtext@title\@empty\else\stDMemph{\omtext@title}: \fi\fi\ignorespaces}
-{\egroup\omtext@post@skip}
+\ifx\omtext@title\@empty%
+\ifx\omtext@start\@empty\else\stDMemph{\omtext@start}\xspace\fi%
+\else\stDMemph{\omtext@title}:\xspace%
+\ifx\omtext@start\@empty\else\omtext@start\xspace\fi%
+\fi% omtext@title empty
+\fi% omtext@display=flow
+\ignorespaces}
+{\egroup\omtext@post@skip\@in@omtextfalse}
\srefaddidkey{phrase}
\addmetakey{phrase}{style}
\addmetakey{phrase}{class}
\addmetakey{phrase}{index}
\addmetakey{phrase}{verbalizes}
\addmetakey{phrase}{type}
-\newenvironment{phrase}[1][]{\metasetkeys{phrase}{#1}}{}
-\def\nlex#1{\green{\sl{#1}}}
-\def\nlcex#1{*\green{\sl{#1}}}
+\addmetakey{phrase}{only}
+\newcommand\phrase[2][]{\metasetkeys{phrase}{#1}%
+\ifx\prhase@only\@empty\only<\phrase@only>{#2}\else #2\fi}
+\providecommand\textsubscript[1]{\ensuremath{_{#1}}}
+\newcommand\corefs[2]{#1\textsubscript{#2}}
+\newcommand\coreft[2]{#1\textsuperscript{#2}}
+\newcommand\nlex[1]{\green{\sl{#1}}}
+\newcommand\nlcex[1]{*\green{\sl{#1}}}
\def\@sinlinequote#1{``{\sl{#1}}''}
\def\@@sinlinequote#1#2{\@sinlinequote{#2}~#1}
-\newcommand{\sinlinequote}[2][]
+\newcommand\sinlinequote[2][]
{\def\@opt{#1}\ifx\@opt\@empty\@sinlinequote{#2}\else\@@sinlinequote\@opt{#2}\fi}
+\newcommand\vdec[1]{#1}
+\newcommand\vids[2][]{#2}
+\newcommand\vrest[2][]{#2}
\def\begin@sblockquote{\begin{quote}\sl}
\def\end@sblockquote{\end{quote}}
\def\begin@@sblockquote#1{\begin@sblockquote}
@@ -56,41 +81,66 @@
\newenvironment{sblockquote}[1][]
{\def\@opt{#1}\ifx\@opt\@empty\begin@sblockquote\else\begin@@sblockquote\@opt\fi}
{\ifx\@opt\@empty\end@sblockquote\else\end@@sblockquote\@opt\fi}
+\newenvironment{sboxquote}[1][]
+{\def\@@src{#1}\begin{mdframed}[leftmargin=.5cm,rightmargin=.5cm]}
+{\@lec{\rm\@@src}\end{mdframed}}
\providecommand{\@@lec}[1]{(#1)}
-\def\@lec#1{\strut\hfil\strut\null\nobreak\hfill\hbox{\@@lec{#1}}}
+\def\@lec#1{\strut\hfil\strut\null\nobreak\hfill\@@lec{#1}}
\def\lec#1{\@lec{#1}\par}
\newcommand\mygraphics[2][]{\includegraphics[#1]{#2}}
-\newcommand\mycgraphics[2][]{\begin{center}\includegraphics[#1]{#2}\end{center}}
-\newcommand\mybgraphics[2][]{\fbox{\includegraphics[#1]{#2}\end{center}}}
-\newcommand{\omdoc@index}[2][]{\ifindex\def\@test{#1}%%
-\ifx\@test\@empty\def\@@idx{#2}\else\def\@@idx{#1}\fi%
-\@ifundefined{mod@id}{\index{\@@idx @#2}}%
-{\index{\@@idx @{\importmodule{\mod@id} #2}}\fi}}
-\newcommand{\indexalt}[3][]{{#2}\omdoc@index[#1]{#3}} % word in text and index
-\newcommand{\indextoo}[2][]{{#2}\omdoc@index[#1]{#2}} % word in text and index
-\newcommand{\@twin}[3][]{\ifindex\def\@test{#1}%%
-\ifx\@test\@empty\def\@@idx{#2}\else\def\@@idx{#1}\fi%
-\@ifundefined{mod@id}
-{\index{\@@idx @#2!#3}%
-\ifx\@test\@empty\def\@@idx{#3}\else\def\@@idx{#1}\fi%
-\index{\@@idx @#2!#3}}%
-{\index{\@@idx @{\importmodule{\mod@id} #2}!{\importmodule{\mod@id} #3}}%
-\ifx\@test\@empty\def\@@idx{#3}\else\def\@@idx{#1}\fi%
-\index{\@@idx @{\importmodule{\mod@id} #3}!{\importmodule{\mod@id} #2}}\fi}}
-\newcommand{\twinalt}[4][]{#2\@twin[#1]{#3}{#4}}
-\newcommand{\twintoo}[3][]{{#2 #3}\@twin[#1]{#2}{#3}} % and use the word compound too
-\newcommand{\@atwin}[4][]{\ifindex\def\@test{#1}%%
-\ifx\@test\@empty\def\@@idx{#2}\else\def\@@idx{#1}\fi%
-\@ifundefined{mod@id}%
-{\index{\@@idx @#2!#3!#4}%
-\ifx\@test\@empty\def\@@idx{#3}\else\def\@@idx{#1}\fi
-\index{\@@idx @#3!#2 (#4)}}%
-{\index{\@@idx @{\importmodule{\mod@id} #2}!{\importmodule{\mod@id} #3}!{\importmodule{\mod@id} #4}}
-\ifx\@test\@empty\def\@@idx{#3}\else\def\@@idx{#1}\fi%
-\index{\@@idx @{\importmodule{\mod@id} #3}!{\importmodule{\mod@id} #2} ({\importmodule{\mod@id} #4})}\fi}}
-\newcommand{\atwinalt}[5][]{#2\@atwin[#1]{#3}{#4}{#4}}
-\newcommand{\atwintoo}[4][]{{#2 #3 #4}\@atwin[#1]{#2}{#3}{#4}} % and use it too
-\def\omspace#1{\hspace*{#1}}
+\newcommand\mycgraphics[2][]{\begin{center}\mygraphics[#1]{#2}\end{center}}
+\newcommand\mybgraphics[2][]{\fbox{\mygraphics[#1]{#2}}}
+\newcommand\mycbgraphics[2][]{\begin{center}\fbox{\mygraphics[#1]{#2}}\end{center}}
+\addmetakey{omdoc@index}{at}
+\addmetakey[false]{omdoc@index}{loadmodules}[true]
+\newcommand\omdoc@indexi[2][]{\ifindex%
+\metasetkeys{omdoc@index}{#1}%
+\@bsphack\begingroup\@sanitize%
+\protected@write\@indexfile{}{\string\indexentry%
+{\ifx\omdoc@index@at\@empty\else\omdoc@index@at @\fi%
+\ifx\omdoc@index@loadmodules\@true%
+\string\withusedmodules{\@ifundefined{mod@id}\used@modules\mod@id}{#2}%
+\else #2\fi% loadmodules
+}{\thepage}}%
+\endgroup\@esphack\fi}%ifindex
+\newcommand\omdoc@indexii[3][]{\ifindex%
+\metasetkeys{omdoc@index}{#1}%
+\@bsphack\begingroup\@sanitize%
+\protected@write\@indexfile{}{\string\indexentry%
+{\ifx\omdoc@index@at\@empty\else\omdoc@index@at @\fi%
+\ifx\omdoc@index@loadmodules\@true%
+\string\withusedmodules{\@ifundefined{mod@id}\used@modules\mod@id}{#2}!%
+\string\withusedmodules{\@ifundefined{mod@id}\used@modules\mod@id}{#3}%
+\else #2!#3\fi% loadmodules
+}{\thepage}}%
+\endgroup\@esphack\fi}%ifindex
+\newcommand\omdoc@indexiii[4][]{\ifindex%
+\metasetkeys{omdoc@index}{#1}%
+\@bsphack\begingroup\@sanitize%
+\protected@write\@indexfile{}{\string\indexentry%
+{\ifx\omdoc@index@at\@empty\else\omdoc@index@at @\fi%
+\ifx\omdoc@index@loadmodules\@true%
+\string\withusedmodules{\@ifundefined{mod@id}\used@modules\mod@id}{#2}!%
+\string\withusedmodules{\@ifundefined{mod@id}\used@modules\mod@id}{#3}!%
+\string\withusedmodules{\@ifundefined{mod@id}\used@modules\mod@id}{#4}%
+\else #2!#3\fi% loadmodules
+}{\thepage}}%
+\endgroup\@esphack\fi}%ifindex
+\newcommand\indexalt[3][]{{#2}\omdoc@indexi[#1]{#3}} % word in text and index
+\newcommand\indextoo[2][]{{#2}\omdoc@indexi[#1]{#2}} % word in text and index
+\newcommand\@twin[3][]{\omdoc@indexii[#1]{#2}{#3}\omdoc@indexii[#1]{#3}{#2}}
+\newcommand\twinalt[4][]{#2\@twin[#1]{#3}{#4}}
+\newcommand\twintoo[3][]{{#2 #3}\@twin[#1]{#2}{#3}} % and use the word compound too
+\newcommand\@atwin[4][]{\omdoc@indexiii[#1]{#2}{#3}{#4}\omdoc@indexii[#1]{#3}{#2 (#4)}}
+\newcommand\atwinalt[5][]{#2\@atwin[#1]{#3}{#4}{#4}}
+\newcommand\atwintoo[4][]{{#2 #3 #4}\@atwin[#1]{#2}{#3}{#4}} % and use it too
+\newcommand\hateq{\ensuremath{\hat=}\xspace}
+\newcommand\hatequiv{\ensuremath{\hat\equiv}\xspace}
+\@ifundefined{ergo}%
+{\newcommand\ergo{\ensuremath{\leadsto}\xspace}}%
+{\renewcommand\ergo{\ensuremath{\leadsto}\xspace}}%
+\newcommand{\reflect@squig}[2]{\reflectbox{$\m@th#1\rightsquigarrow$}}%
+\newcommand\ogre{\ensuremath{\mathrel{\mathpalette\reflect@squig\relax}}\xspace}%
\endinput
%%
%% End of file `omtext.sty'.
diff --git a/Master/texmf-dist/tex/latex/stex/omtext/omtext.sty.ltxml b/Master/texmf-dist/tex/latex/stex/omtext/omtext.sty.ltxml
deleted file mode 100644
index 7d781b74e53..00000000000
--- a/Master/texmf-dist/tex/latex/stex/omtext/omtext.sty.ltxml
+++ /dev/null
@@ -1,223 +0,0 @@
-package LaTeXML::Package::Pool;
-use strict;
-use LaTeXML::Package;
-use Cwd qw(cwd abs_path);
-DeclareOption('noindex','');
-RequirePackage('sref');
-Tag('omdoc:metadata',afterOpen=>\&numberIt,afterClose=>\&locateIt,autoClose=>1,autoOpen=>1);
-sub declareFunctions{
- my ($stomach,$whatsit) = @_;
- my $keyval = $whatsit->getArg(1);
- my $funval = KeyVal($keyval,'functions') if KeyVal($keyval,'functions');
- my @funsymbs = ParseKeyValList($funval);
- #Unread the function declarations at the Gullet
- foreach (@funsymbs) {
- $stomach->getGullet->unread(Tokenize('\lxDeclare[role=FUNCTION]{$'.$_.'$}')->unlist);
- }
- return;
-}
-Tag('omdoc:CMP', afterOpen => sub {AssignValue('_LastSeenCMP', $_[1], 'global');return;});#$
-DefParameterType('IfBeginFollows', sub {
- my ($gullet) = @_;
- $gullet->skipSpaces;
- my $next = $gullet->readToken;
- $gullet->unread($next);
- $next = ToString($next);
- #Hm, falling back to regexp handling, the $gullet->ifNext approach didn't work properly
- return 1 unless ($next=~/^\\begin/);
- return;
- },
- reversion=>'', optional=>1);
-DefKeyVal('omtext','functions','Undigested');
-DefKeyVal('omtext','display','Semiverbatim');
-DefKeyVal('omtext','for','Semiverbatim');
-DefKeyVal('omtext','from','Semiverbatim');
-DefKeyVal('omtext','type','Semiverbatim');
-DefKeyVal('omtext','title','Plain'); #Math mode in titles.
-DefKeyVal('omtext','start','Plain'); #Math mode in start phrases
-DefKeyVal('omtext','theory','Semiverbatim');
-DefKeyVal('omtext','continues','Semiverbatim');
-DefKeyVal('omtext','verbalizes','Semiverbatim');
-DefEnvironment('{omtext} OptionalKeyVals:omtext',
- "<omdoc:omtext "
- . "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')')() "
- . "?&KeyVal(#1,'type')(type='&KeyVal(#1,'type')')() "
- . "?&KeyVal(#1,'for')(for='&KeyVal(#1,'for')')() "
- . "?&KeyVal(#1,'from')(from='&KeyVal(#1,'from')')()>"
- . "?&KeyVal(#1,'title')(<dc:title>&KeyVal(#1,'title')</dc:title>)()"
- . "<omdoc:CMP>"
- . "?&KeyVal(#1,'start')(<ltx:text class='startemph'>&KeyVal(#1,'start')</ltx:text>)()"
- . "#body"
- ."</omdoc:omtext>");
-sub DefCMPEnvironment {
- my ($proto, $replacement, %options) = @_;
- my @before = $options{beforeDigest} ? ($options{beforeDigest}) : ();
- push(@before, \&useCMPItemizations);
- $options{beforeDigest} = \@before;
- my @after = $options{afterDigestBegin} ? ($options{afterDigestBegin}) : ();
- push(@after, \&declareFunctions);
- $options{afterDigestBegin} = \@after;
- DefEnvironment($proto, $replacement, %options);
-}
-sub DefCMPConstructor {
- my ($proto, $replacement, %options) = @_;
- my @before = $options{beforeDigest} ? ($options{beforeDigest}) : ();
- push(@before, \&useCMPItemizations);
- $options{beforeDigest} = \@before;
- DefConstructor($proto, $replacement, %options);
-}#$
-DefKeyVal('phrase','id','Semiverbatim');
-DefKeyVal('phrase','style','Semiverbatim');
-DefKeyVal('phrase','class','Semiverbatim');
-DefKeyVal('phrase','index','Semiverbatim');
-DefKeyVal('phrase','verbalizes','Semiverbatim');
-DefKeyVal('phrase','type','Semiverbatim');
-DefConstructor('\phrase OptionalKeyVals:phrase {}',
- "<ltx:text %&KeyVals(#1)>#2</ltx:text>");
-DefConstructor('\nlex{}',
- "<ltx:text class='nlex'>#1</ltx:text>");
-DefConstructor('\nlcex{}',
- "<ltx:text type='nlcex'>#1</ltx:text>");
-DefConstructor('\sinlinequote [] {}',
- "<ltx:quote type='inlinequote'>"
- . "?#1(<dc:source>#1</dc:source>\n)()"
- . "#2"
- . "</ltx:quote>");
-DefEnvironment('{sblockquote} []',
- "?#1(<omdoc:omtext type='quote'>"
- . "<dc:source>#1</dc:source>"
- . "#body"
- . " </omdoc:omtext>)"
- . "(<ltx:quote>#body</ltx:quote>)");
-DefConstructor('\lec{}',
- "\n<omdoc:note type='line-end-comment'>#1</omdoc:note>");
-RawTeX('
-\newcommand\mygraphics[2][]{\includegraphics[#1]{#2}}
-\newcommand\mycgraphics[2][]{\begin{center}\includegraphics[#1]{#2}\end{center}}
-\newcommand\mybgraphics[2][]{\fbox{\includegraphics[#1]{#2}\end{center}}}
-');
-DefConstructor('\indextoo[]{}',
- "<omdoc:idx>"
- . "<omdoc:idt>#2</omdoc:idt>"
- . "<omdoc:ide ?#1(sort-by='#1')()>"
- . "<omdoc:idp>#2</omdoc:idp>"
- . "</omdoc:ide>"
- ."</omdoc:idx>");
-DefConstructor('\indexalt[]{}{}',
- "<omdoc:idx>"
- . "<omdoc:idt>#2</omdoc:idt>"
- . "<omdoc:ide ?#1(sort-by='#1')()>"
- . "<omdoc:idp>#3</omdoc:idp>"
- . "</omdoc:ide>"
- ."</omdoc:idx>");
-DefConstructor('\twintoo[]{}{}',
- "<omdoc:idx>"
- . "<omdoc:idt>#2 #3</omdoc:idt>"
- . "<omdoc:ide ?#1(sort-by='#1')()>"
- . "<omdoc:idp>#2</omdoc:idp>"
- . "<omdoc:idp>#3</omdoc:idp>"
- . "</omdoc:ide>"
- ."</omdoc:idx>");
-DefConstructor('\twinalt[]{}{}{}',
- "<omdoc:idx>"
- . "<omdoc:idt>#2</omdoc:idt>"
- . "<omdoc:ide ?#1(sort-by='#1')()>"
- . "<omdoc:idp>#2</omdoc:idp>"
- . "<omdoc:idp>#3</omdoc:idp>"
- . "</omdoc:ide>"
- ."</omdoc:idx>");
-DefConstructor('\atwintoo[]{}{}{}',
- "<omdoc:idx>"
- . "<omdoc:idt>#2 #3</omdoc:idt>"
- . "<omdoc:ide ?#1(sort-by='#1')()>"
- . "<omdoc:idp>#2</omdoc:idp>"
- . "<omdoc:idp>#3</omdoc:idp>"
- . "<omdoc:idp>#4</omdoc:idp>"
- . "</omdoc:ide>"
- ."</omdoc:idx>");
-
-DefConstructor('\atwinalt[]{}{}{}{}',
- "<omdoc:idx>"
- . "<omdoc:idt>#2</omdoc:idt>"
- . "<omdoc:ide ?#1(sort-by='#1')()>"
- . "<omdoc:idp>#2</omdoc:idp>"
- . "<omdoc:idp>#3</omdoc:idp>"
- . "<omdoc:idp>#4</omdoc:idp>"
- . "</omdoc:ide>"
- ."</omdoc:idx>");
-# needed? DefConstructor('\par',sub { $_[0]->maybeCloseElement('ltx:p'); },alias=>"\\par\n");
-Tag('omdoc:CMP', autoClose=>1, autoOpen=>1);
-Tag('omdoc:omtext', autoClose=>1, autoOpen=>1);
-DefConstructor('\footnote[]{}',
- "<omdoc:note type='foot' ?#1(mark='#1')>#2</omdoc:note>");
-DefConstructor('\footnotemark[]',"");
-DefConstructor('\footnotetext[]{}',
- "<omdoc:note class='foot' ?#1(mark='#1')>#2</omdoc:note>");
-Tag('omdoc:omtext',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('omdoc:omgroup',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('omdoc:CMP',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('omdoc:idx',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('omdoc:ide',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('omdoc:idt',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('omdoc:note',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('omdoc:metadata',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('omdoc:meta',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('omdoc:resource',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('ltx:p',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('ltx:tabular',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('ltx:thead',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('ltx:td',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('ltx:tr',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-Tag('ltx:caption',afterOpen=>\&numberIt,afterClose=>\&locateIt);
-sub numberIt {
- my($document,$node,$whatsit)=@_;
- my(@parents)=$document->findnodes('ancestor::*[@xml:id]',$node);
- my $prefix= (@parents ? $parents[$#parents]->getAttribute('xml:id')."." : '');
- my(@siblings)=$document->findnodes('preceding-sibling::*[@xml:id]',$node);
- my $n = scalar(@siblings)+1;
- my $id = ($node -> getAttribute('xml:id'));
- my $localname = $node->localname;
- $node->setAttribute('xml:id'=>$prefix."$localname$n") unless $id;
- my $about = $node -> getAttribute('about');
- $node->setAttribute('about'=>'#'.$node->getAttribute('xml:id')) unless $about;
- #Also, provide locators:
- my $locator = $whatsit->getProperty('locator');
- #Need to inherit locators if missing:
- $locator = (@parents ? $parents[$#parents]->getAttribute('stex:srcref') : '') unless $locator;
- if ($locator) {
- # There is a BUG with namespace declarations (or am I using the API wrongly??) which
- # does not recognize the stex namespace. Hence, I need to redeclare it...
- my $parent=$document->getNode;
- if(! defined $parent->lookupNamespacePrefix("http://kwarc.info/ns/sTeX"))
- { # namespace not already declared?
- $document->getDocument->documentElement->setNamespace("http://kwarc.info/ns/sTeX","stex",0);
- }
- $node->setAttribute('stex:srcref'=>$locator);
- }return;}
-
-sub locateIt {
- my($document,$node,$whatsit)=@_;
- #Estimate trailer locator:
- my $trailer = $whatsit->getProperty('trailer');
- return unless $trailer; #Nothing we can do if the trailer isn't defined
- $trailer = $trailer->getLocator;
- return unless ($trailer && $trailer!~/^\s*$/); #Useless if broken
- my $locator = $node->getAttribute('stex:srcref');
- if ($locator) {
- $locator =~ /^(.+from=\d+;\d+)/;
- my $from = $1;
- $trailer =~ /(,to=\d+;\d+.+)$/;
- my $to = $1;
- $locator = $from.$to;
- } else {
- $locator = $trailer; #This should never happen
- }
- my $parent = $document->getNode;
- if(! defined $parent->lookupNamespacePrefix("http://kwarc.info/ns/sTeX"))
- { # namespace not already declared?
- $document->getDocument->documentElement->setNamespace("http://kwarc.info/ns/sTeX","stex",0);
- }
- $node->setAttribute('stex:srcref' => $locator);
- return;
-}
-1;