Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When export is enabled, e.g., using \setupbackend[export=yes] then \definevimtyping[CODE][syntax=..., alternative=colorscheme] \startCODE ... \stopextCODE is exported as <vimtyping detail="colorscheme"> ... </vimtyping> And, \inlineCODE{...} is exported as <inlinevimtyping detail="colorscheme">...</inlinevimtyping> Each line is wrapped inside a `<verbatimline>...</verbatimline>` and each syntax group is wrapped inside `<syntaxgroup detail="vim....">...</syntaxgroup>`. See the updated documentation for details. The module ships with a default CSS file which can be included as \setupexport[cssfile=\vimtypingcssfile] This CSS file tries to mimic the default PDF output. If you want to tweak the output then it is recommended that you copy the default CSS file and modify it as appropriate.
- Loading branch information
Showing
13 changed files
with
806 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
%D \module | ||
%D [ file=t-syntax-groups, | ||
%D version=2020.06.29, | ||
%D title=\CONTEXT\ User Module, | ||
%D subtitle=Syntax highlighting support, | ||
%D author=Aditya Mahajan, | ||
%D date=\currentdate, | ||
%D copyright=Aditya Mahajan, | ||
%D email=adityam <at> ieee <dot> org, | ||
%D license=Simplified BSD License] | ||
|
||
\writestatus{loading}{Syntax highlighting groups (ver: 2020.06.29)} | ||
|
||
\startmodule [syntax-group] | ||
\usemodule [module-catcodes] | ||
|
||
\unprotectmodulecatcodes | ||
|
||
\def\colorscheme@name {} | ||
|
||
\def\syntaxgroup@id {syntaxgroup} | ||
\def\syntaxgroup@namespace {@@@@\syntaxgroup@id} | ||
\def\syntaxgroup@name {} | ||
|
||
\edef\t!vimsyntaxgroup {\syntaxgroup@id} | ||
\setelementbackendtag[\t!vimsyntaxgroup] | ||
\setelementnature [\t!vimsyntaxgroup][inline] | ||
|
||
|
||
\installparameterhandler \syntaxgroup@namespace \syntaxgroup@id | ||
\installsetuphandler \syntaxgroup@namespace \syntaxgroup@id | ||
\installstyleandcolorhandler \syntaxgroup@namespace \syntaxgroup@id | ||
|
||
\def\m!syntaxgroup{t-syntax-group} | ||
|
||
\def\definesyntaxgroup | ||
{\dodoubleargument\syntaxgroup@define} | ||
|
||
\starttexdefinition syntaxgroup@define [#1][#2] | ||
% #1 list name | ||
% #2 options | ||
\doifassignmentelse{#2} | ||
{ | ||
\def\syntaxgroup@get_parameters##1% | ||
{ | ||
\edef\syntaxgroup@name {\colorscheme@name##1} | ||
\setupsyntaxgroup[\syntaxgroup@name] | ||
[\s!parent=\syntaxgroup@namespace,\c!color=,\c!style=,\c!command=,#2] | ||
\doifsomething{\syntaxgroupparameter\c!color} | ||
{ | ||
\expanded{\definecolor[\syntaxgroup@namespace-##1-color] | ||
[\syntaxgroupparameter\c!color]} | ||
\setupsyntaxgroup[\syntaxgroup@name][\s!parent=\syntaxgroup@namespace,\c!color=\syntaxgroup@namespace-##1-color] | ||
} | ||
} | ||
}{ | ||
\def\syntaxgroup@get_parameters##1% | ||
{ | ||
\edef\syntaxgroup@name {\colorscheme@name##1} | ||
\expanded{\setupsyntaxgroup[\syntaxgroup@name] | ||
[\c!color=\namedsyntaxgroupparameter{\colorscheme@name#2}\c!color, | ||
\c!style=\namedsyntaxgroupparameter{\colorscheme@name#2}\c!style, | ||
\c!command=\namedsyntaxgroupparameter{\colorscheme@name#2}\c!command, | ||
]} | ||
|
||
% In MkII, \expanded messes up the definition of \currentsyntaxgroup | ||
\def\currentsyntaxgroup {\syntaxgroup@name} | ||
} | ||
} | ||
|
||
\processcommalist[#1]\syntaxgroup@get_parameters | ||
\stoptexdefinition | ||
|
||
\def\startcolorscheme% | ||
{\dosingleargument\colorscheme@start} | ||
|
||
\starttexdefinition colorscheme@start [#1] | ||
\pushmacro\colorscheme@name | ||
\setcolorscheme{#1} | ||
%\setupsyntaxgroup[\c!color=,\c!style=,\c!command=] | ||
\stoptexdefinition | ||
|
||
\def\stopcolorscheme | ||
{\popmacro\colorscheme@name} | ||
|
||
\def\setcolorscheme#1% | ||
{\edef\colorscheme@name{#1}} | ||
|
||
\starttexdefinition syntaxgroup [#1]#2 | ||
% #1 = style | ||
% #2 = content | ||
\begingroup | ||
\edef\syntaxgroup@name{\colorscheme@name#1}% | ||
\syntaxgroupparameter\c!before | ||
\iftracesyntaxgroups | ||
\syntaxgroup@show_values | ||
\fi | ||
\dostarttagged\t!vimsyntaxgroup{vim#1} | ||
\syntaxgroupparameter\c!command | ||
{ | ||
\externalfilter@attributes_start\syntaxgroup@id\c!style\c!color | ||
#2 | ||
\externalfilter@attributes_stop | ||
} | ||
\dostoptagged | ||
\syntaxgroupparameter\c!after | ||
\endgroup | ||
\stoptexdefinition | ||
|
||
%D Tracing macros | ||
|
||
\newif\iftracesyntaxgroups | ||
\let\tracesyntaxgroups\tracesyntaxgroupstrue | ||
|
||
\def\currentsyntaxgroup {\syntaxgroup@name} | ||
|
||
\starttexdefinition syntaxgroup@show_values | ||
\writestatus\m!syntaxgroup{color scheme : \colorscheme@name} | ||
\writestatus\m!syntaxgroup{current group: \syntaxgroup@name} | ||
\writestatus\m!syntaxgroup{command : \syntaxgroupparameter\c!command} | ||
\writestatus\m!syntaxgroup{style : \syntaxgroupparameter\c!style} | ||
\writestatus\m!syntaxgroup{color : \syntaxgroupparameter\c!color} | ||
\stoptexdefinition | ||
|
||
\protectmodulecatcodes | ||
\stopmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.