From 576edc303564df0402350ff7a4c81fe179ac7929 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 4 May 2020 21:19:49 +0000 Subject: metanorma (4may20) git-svn-id: svn://tug.org/texlive/trunk@55010 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/metanorma/metanorma.cls | 132 ++++ .../tex/latex/metanorma/metanorma.cls.ltxml | 149 +++++ .../texmf-dist/tex/latex/metanorma/metanorma.xsl | 693 +++++++++++++++++++++ 3 files changed, 974 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/metanorma/metanorma.cls create mode 100644 Master/texmf-dist/tex/latex/metanorma/metanorma.cls.ltxml create mode 100644 Master/texmf-dist/tex/latex/metanorma/metanorma.xsl (limited to 'Master/texmf-dist/tex/latex') diff --git a/Master/texmf-dist/tex/latex/metanorma/metanorma.cls b/Master/texmf-dist/tex/latex/metanorma/metanorma.cls new file mode 100644 index 00000000000..894f9a860dc --- /dev/null +++ b/Master/texmf-dist/tex/latex/metanorma/metanorma.cls @@ -0,0 +1,132 @@ +% +% tex2mn 0.5.0 - converts Metanorma documents from LaTeX to AsciiDoc +% +% Copyright (C) 2019-2020 Ribose Inc. +% This project is available under the terms of the MIT License. +% + +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{metanorma} + [2019/07/07 Metanorma] + +\LoadClass{article} + +\RequirePackage{graphicx} +\RequirePackage{hyperref} +% TODO: what's the best baseline AMS setup? +\RequirePackage{amsmath} +\RequirePackage{subcaption} +\RequirePackage{enumitem} + +\RequirePackage{verbatim} + +\RequirePackage{xparse} + +%% RDF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% \RequirePackage{lxRDFa} +% Let's not introduce another (mostly trivial) dependency, and just embed it: +\DeclareRobustCommand{\lxRDFa}[2][]{} +\DeclareRobustCommand{\lxRDF}[2][]{} + +\NewDocumentCommand{\mn}{m} + {\lxRDF[#1]{property=mn:attributes}} + +%% Document attributes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\makeatletter + +\NewDocumentCommand{\set}{mm}{% + \lxRDF{property=#1,content=#2}% + \expandafter\def\csname metadata@#1\endcsname{#2}} + +\@onlypreamble\set + +\NewDocumentCommand{\get}{m} + {\csname metadata@#1\endcsname} + +\makeatother + +\NewDocumentCommand{\att}{om}{#2} + +%% General style %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% No indentation on paragraphs. +\setlength\parindent{0pt} + +%% Strikethrough %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% `normalem` avoids changes to the behaviour of emphasis. +\RequirePackage[normalem]{ulem} + +% We decouple the class' API from the package choice. +\let\textst\sout + +%% Blocks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\RequirePackage[framemethod=TikZ]{mdframed} + +\mdfdefinestyle{mnbase}{ + frametitlerule=true, + frametitlefont=\sffamily\bfseries\scshape\small, + linecolor=gray, +} + +% Admonitions + +\mdfdefinestyle{note}{linecolor=blue,frametitle=Note} +\mdfdefinestyle{tip}{linecolor=green,frametitle=Tip} +\mdfdefinestyle{important}{linecolor=yellow,frametitle=Important} +\mdfdefinestyle{caution}{linecolor=red,frametitle=Caution} +\mdfdefinestyle{warning}{linecolor=orange,frametitle=Warning} + +\newmdenv[style=mnbase,style=note]{note} +\newmdenv[style=mnbase,style=tip]{tip} +\newmdenv[style=mnbase,style=important]{important} +\newmdenv[style=mnbase,style=caution]{caution} +\newmdenv[style=mnbase,style=warning]{warning} + +% Requirement, recommendation and permission + +\mdfdefinestyle{requirement}{linecolor=gray,frametitle=Requirement} +\mdfdefinestyle{recommendation}{linecolor=gray,frametitle=Recommendation} +\mdfdefinestyle{permission}{linecolor=gray,frametitle=Permission} + +\newmdenv[style=mnbase,style=requirement]{requirement} +\newmdenv[style=mnbase,style=recommendation]{recommendation} +\newmdenv[style=mnbase,style=permission]{permission} + +% Specification, measurement target, verification and import + +\mdfdefinestyle{specification}{linecolor=lightgray,frametitle=Specification} +\mdfdefinestyle{measurement-target}{linecolor=lightgray,frametitle=Measurement target} +\mdfdefinestyle{verification}{linecolor=lightgray,frametitle=Verification} +\mdfdefinestyle{import}{linecolor=lightgray,frametitle=Import} + +\newmdenv[style=mnbase,style=specification]{specification} +\newmdenv[style=mnbase,style=measurement-target]{measurement-target} +\newmdenv[style=mnbase,style=verification]{verification} +\newmdenv[style=mnbase,style=import]{import} + +%% Terms and definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\NewDocumentCommand{\alt}{m}{{\large #1}\par} +\NewDocumentCommand{\deprecated}{m}{\textbf{DEPRECATED:} #1\par} +\NewDocumentCommand{\domain}{m}{\textbf{DOMAIN:} #1\par} + +\mdfdefinestyle{example}{linecolor=lightgray,frametitle=Example} +\mdfdefinestyle{source}{linecolor=lightgray,frametitle=Source} + +\newmdenv[style=mnbase,style=example]{example} +\newmdenv[style=mnbase,style=source]{source} + +%% Citation macros %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% TODO: handle localities formatting +\NewDocumentCommand{\mncite}{omo}{\cite[#1]{#2}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newlist{key}{description}{1} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Master/texmf-dist/tex/latex/metanorma/metanorma.cls.ltxml b/Master/texmf-dist/tex/latex/metanorma/metanorma.cls.ltxml new file mode 100644 index 00000000000..eb17757cb5a --- /dev/null +++ b/Master/texmf-dist/tex/latex/metanorma/metanorma.cls.ltxml @@ -0,0 +1,149 @@ +# +# tex2mn 0.5.0 - converts Metanorma documents from LaTeX to AsciiDoc +# +# Copyright (C) 2019-2020 Ribose Inc. +# This project is available under the terms of the MIT License. +# + +package LaTeXML::Package::Pool; + +use LaTeXML::Package; +use strict; +use warnings; + +LoadClass('article'); + +RequirePackage('lxRDFa'); +RequirePackage('graphicx'); +RequirePackage('hyperref'); +RequirePackage('amsmath'); +RequirePackage('subcaption'); + +RequirePackage('verbatim'); + +# NOTE: switching to ASCII encoding (inside the enveloping group) preserves quotes. +# Otherwise, they would be mapped to curly ones by Tex.pool.ltxml fontmaps and ligatures. +DefMacro('\mn Semiverbatim', + '{\fontencoding{ASCII}\lxRDF[#1]{property=mn:attributes}}'); + +# NOTE: let's avoid \mna until possible + +# NOTE: this fixes and specializes \lxRDFa +# \mna{xpath}{keywordpairs} +# Add RDF attributes to nodes specified by the xpath expression. +# DefConstructor('\mna Semiverbatim RequiredKeyVals:RDFa', sub { +# my ($document, $xpath, $kv) = @_; +# my ($save, @nodes); +# $xpath = ToString($xpath); +# $save = $document->getNode; +# @nodes = $document->findnodes($xpath, $save); +# Warn('expected', 'node', $document, +# "Expected to find a node for RDFa attributes at the xpath: " . $xpath) unless scalar(@nodes); +# my $attr = RDFAttributes($kv); +# foreach my $node (@nodes) { +# foreach my $k (sort keys %$attr) { +# # use direct method ($doc method doesn't skips about="", which we need!) +# $node->setAttribute($k => ToString($$attr{$k})); }} +# $document->setNode($save); }); + +## Document attributes ######################################################### + +DefMacro('\set Semiverbatim {}', + '{\fontencoding{ASCII}\lxRDF{property=#1,content=#2}}'); + +DefConstructor('\get Semiverbatim', + ""); + +DefConstructor('\att OptionalUndigested {}', + "#1#2"); + +## Strikethrough ############################################################### + +DefConstructor('\textst{}', + "#1"); + +## Blocks ###################################################################### + +# NOTE: this is modeled after quote's treatment in LaTeX.pool.ltxml +# NOTE: source are meant to be a single paragraph +DefEnvironment("{source}", + "#body", + # NOTE: this beforeDigest gives us a single

inside broken by , + # instead of multiple

splitted on multiple s (with no classes after the first one). + beforeDigest => sub { Let('\\\\', '\@block@cr'); Let('\par', '\@block@cr') }, + mode => 'text'); + +sub define_block { + my ($environment, $class) = @_; + DefEnvironment( + "{$environment}", + sub { + my ($document, %props) = @_; + $_[0]->maybeCloseElement('ltx:p'); # this starts a new vertical block + insertBlock( + $document, + $props{body}, + class => $class, + ); + }, + beforeDigest => sub { + Let('\par', '\inner@par'); + # Let('\\\\', '\inner@par'); + }, + # mode => 'text' + ); +} + +sub define_blocks { + my ($block, @modifiers) = @_; + foreach my $modifier (@modifiers) { + define_block("{$modifier}", "$block--$modifier"); + } +} + +define_block('quote', 'block-quote'); +define_block('example', 'block-example'); +define_block('reviewernote', 'block-sidebar'); +define_block('todo', 'block-admonition--todo'); +define_blocks('block-example', qw(requirement recommendation permission)); +define_blocks('block-open', qw(specification measurement-target verification import)); +define_blocks('block-admonition', qw(note tip important caution warning)); + +## Terms and Definitions ####################################################### + +DefMacro('\alt{}', '\lxRDF[#1]{property=alt}'); +DefMacro('\deprecated{}', '\lxRDF[#1]{property=deprecated}'); +DefMacro('\domain{}', '\lxRDF[#1]{property=domain}'); + +## Citation macros ############################################################# + +# NOTE: this is intended as a smarter version of +# DefMacro('\mncite[]{}[]','\cite[#1]{#2}\mn{#3,#1}'); +DefMacro('\mncite[]{}[]', sub { + my (@mn_attributes, @tokens); + push(@mn_attributes, ToString($_[3])) if $_[3]; + push(@mn_attributes, ToString($_[1])) if $_[1]; + push(@tokens, Invocation(T_CS('\cite'), $_[1], $_[2])); + # NOTE: we should be putting the ltx:rdf *inside* the ltx:cite + push(@tokens, Invocation(T_CS('\mn'), join(',', @mn_attributes))) if scalar(@mn_attributes); + return @tokens; +}); + +## Figures keys ################################################################ + +# NOTE: this is straight from LaTeXML/lib/LaTeXML/Package/enumitem.sty.ltxml +DefEnvironment('{key} OptionalUndigested', + "#body", + beforeDigest => sub { Let('\makelabel', '\descriptionlabel'); }, + properties => sub { beginItemize('description', '@desc'); }, + beforeDigestEnd => sub { Digest('\par'); }, + locked => 1, mode => 'text'); + +## LaTeX.pool.ltxml overrides ################################################## + +# NOTE: the original is '\normalfont\bfseries #1' but that's annoying since +# we want to just do +# to match description list labels and that would get us an undesired bold. +DefMacro('\descriptionlabel{}', '\normalfont #1'); + +1; diff --git a/Master/texmf-dist/tex/latex/metanorma/metanorma.xsl b/Master/texmf-dist/tex/latex/metanorma/metanorma.xsl new file mode 100644 index 00000000000..7814c49e327 --- /dev/null +++ b/Master/texmf-dist/tex/latex/metanorma/metanorma.xsl @@ -0,0 +1,693 @@ + + + + + + + + + + + + + + + + + [[Foreword]] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + **** + ____ + ```` + [smallcap]## + [strike]## + ^^ + ~~ + + + + + + + + + + + + + + + + + + + + + + + + + + + + [quote + + + + ] + + + + _____ + + + + + + + + + + + + + + + + + + + ] + + + + ==== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + + + + + + + + + + : + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ==== + + ==== + + + + + + + + + + + + + + *Key* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [stem] + ++++ + + ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + |=== + + |=== + + + + + + + + + + + | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + **** + + + + + + + + + + + + + + + + + + + = + ==== + + + + + + + + + + + + + + + + -- + + + + + + + + .... + + .... + + + + + + + + + [example] + + + + + + + + + + + [.source] + + + + + + + + ] + + + + + + + + + << + + + + + >> + + + + + + [bibliography] + + + + + + + + * + + + + + + + + + + + + + + * + + + + + + + {blank} + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3