summaryrefslogtreecommitdiff
path: root/macros/context
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-04-27 03:03:41 +0000
committerNorbert Preining <norbert@preining.info>2020-04-27 03:03:41 +0000
commitae496a1c963576dfe63885afa818b2af745ed44a (patch)
tree62604706ca603c17f5f56fe646072d8d2cfab60c /macros/context
parent7d9d2e08fcab92adcc759e3f1e4bb0a15a63f220 (diff)
CTAN sync 202004270303
Diffstat (limited to 'macros/context')
-rw-r--r--macros/context/contrib/context-filter/VERSION2
-rw-r--r--macros/context/contrib/context-filter/doc/context/third/filter/filter.txt2
-rw-r--r--macros/context/contrib/context-filter/tex/context/third/filter/t-filter.mkiv10
-rw-r--r--macros/context/contrib/context-vim/VERSION2
-rw-r--r--macros/context/contrib/context-vim/doc/context/third/vim/vim.txt108
-rw-r--r--macros/context/contrib/context-vim/tex/context/third/vim/2context.vim56
-rw-r--r--macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv4
-rw-r--r--macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex12
8 files changed, 163 insertions, 33 deletions
diff --git a/macros/context/contrib/context-filter/VERSION b/macros/context/contrib/context-filter/VERSION
index 95c275e403..9e6f07d186 100644
--- a/macros/context/contrib/context-filter/VERSION
+++ b/macros/context/contrib/context-filter/VERSION
@@ -1 +1 @@
-2018.08.10
+2020.04.25
diff --git a/macros/context/contrib/context-filter/doc/context/third/filter/filter.txt b/macros/context/contrib/context-filter/doc/context/third/filter/filter.txt
index fd7ccee225..a4e24f39ce 100644
--- a/macros/context/contrib/context-filter/doc/context/third/filter/filter.txt
+++ b/macros/context/contrib/context-filter/doc/context/third/filter/filter.txt
@@ -1003,3 +1003,5 @@ Version History
- Support for `left` and `right`
- **2018-04-17**
- Support for `strip=yes` (which is now default).
+- **2020-04-25**
+ - Bugfix for MkIV (Replace `\@EA` by `\expandafter`)
diff --git a/macros/context/contrib/context-filter/tex/context/third/filter/t-filter.mkiv b/macros/context/contrib/context-filter/tex/context/third/filter/t-filter.mkiv
index 408a3d96b3..5db429a3d2 100644
--- a/macros/context/contrib/context-filter/tex/context/third/filter/t-filter.mkiv
+++ b/macros/context/contrib/context-filter/tex/context/third/filter/t-filter.mkiv
@@ -1,6 +1,6 @@
%D \module
%D [ file=t-filter,
-%D version=2018.08.10,
+%D version=2020.04.25,
%D title=\CONTEXT\ User Module,
%D subtitle=Filter,
%D author=Aditya Mahajan,
@@ -9,7 +9,7 @@
%D email=adityam <at> ieee <dot> org,
%D license=Simplified BSD License]
-\writestatus{loading}{Filter (ver: 2018.08.10)}
+\writestatus{loading}{Filter (ver: 2020.04.25)}
\startmodule [filter]
\usemodule [module-catcodes]
@@ -210,7 +210,7 @@
\begingroup % to keep assignments local
\edef\currentexternalfilter{#1}
- \setupexternalfilter[#1][\c!numbering=,\c!name=,\c!location=\v!text,#2]
+ \setupexternalfilter[#1][\c!escape=\v!off,\c!numbering=,\c!name=,\c!location=\v!text,#2]
\externalfilter@set_filenames
\doifelse{\externalfilterparameter\c!write}\v!no
@@ -295,10 +295,10 @@
\def\externalfilter@get_first_character_indeed#1#2\relax{#1}
\def\externalfilter@get_last_character#1%
- {\@EA\externalfilter@get_last_character_indeed#1\relax}
+ {\expandafter\externalfilter@get_last_character_indeed#1\relax}
\def\externalfilter@get_last_character_indeed#1#2%
- {\ifx#2\relax#1\else\@EA\externalfilter@get_last_character_indeed\@EA#2\fi}
+ {\ifx#2\relax#1\else\expandafter\externalfilter@get_last_character_indeed\expandafter#2\fi}
%D \subsubject {Setting font and color attributes}
%D I want to use the same interface for MkII and MkIV
diff --git a/macros/context/contrib/context-vim/VERSION b/macros/context/contrib/context-vim/VERSION
index 95c275e403..9e6f07d186 100644
--- a/macros/context/contrib/context-vim/VERSION
+++ b/macros/context/contrib/context-vim/VERSION
@@ -1 +1 @@
-2018.08.10
+2020.04.25
diff --git a/macros/context/contrib/context-vim/doc/context/third/vim/vim.txt b/macros/context/contrib/context-vim/doc/context/third/vim/vim.txt
index 801d1fb34c..11c17cf59e 100644
--- a/macros/context/contrib/context-vim/doc/context/third/vim/vim.txt
+++ b/macros/context/contrib/context-vim/doc/context/third/vim/vim.txt
@@ -73,6 +73,9 @@ on the ConTeXt wiki for detailed instructions.
Usage
-----
+Include the module
+
+ \usemodule[vim]
Suppose you want to syntax highlight Ruby. In particular, you want
@@ -112,7 +115,7 @@ defines three things:
\inlineRUBY{...}
- The contents of this environment are processed by a vim script
+ The contents of this macro are processed by a vim script
(`2context.vim`) and the result is read back in ConTeXt.
3. A macro
@@ -125,7 +128,15 @@ defines three things:
processing a url, see the _Processing remote files_ section of the
`t-filter` manual.
-In all the three cases, the `t-filter` module takes care of writing to external
+4. A macro
+
+ \processRUBYbuffer[...]
+
+ The argument to the macro is the name of a buffer, which is written to an
+ external file, processesd by `2context.vim` and the result is read back in
+ ConTeXt.
+
+In all the four cases, the `t-filter` module takes care of writing to external
file, processing by `2context.vim`, and reading the contents back to ConTeXt.
The `t-vim` module simply defines the macros that are used by `2context.vim`.
@@ -460,21 +471,27 @@ the bar starts from the first non-blank character.
Using TeX code in Comments
--------------------------
-Sometimes one wants to use TeX code in comments, especially for math. To
-enable this use
+Sometimes one wants to use TeX command in code. There are two different
+methods to do so.
+
+The first method is primarily aimed towards writing math in comments. To
+enable this, use
\definevimtyping
[...]
[...
- escape=on,
+ escape=comment,
]
-When `escape=on`, the `2context.vim` script passes the `Comment` syntax
-region (as identified by `vim`) verbatim to TeX. So, we may use TeX
-commands inside the comment region and they will be interpreted by TeX.
-For example
+For backward compatibility, this feature can also be enabled using
+`escape=on`.
- \definevimtyping[C][syntax=c, escape=on]
+When `escape=comment` is enabled, the `2context.vim` script passes the
+`Comment` syntax region (as identified by `vim`) verbatim to TeX. So, we may
+use TeX commands inside the comment region and they will be interpreted by
+TeX. For example
+
+ \definevimtyping[C][syntax=c, escape=comment]
\startC
/* The following function computes the roots of \m{ax^2+bx+c=0}
@@ -484,10 +501,79 @@ For example
\stopC
**Note** that only `\ { }` have their usual meaning inside the `Comment`
-region when `escape=on` is set. Thus, to enter a math expression, use
+region when `escape=comment` is set. Thus, to enter a math expression, use
`\m{...}` instead of `$...$`. Moreover, spaces are active inside the
math mode, so, as in the above example, avoid spaces in the math expressions.
+The second method is to imitate the behavior of `\starttyping` environment,
+where one can write arbitrary TeX commands in code inside `/BTEX ... /ETEX`
+delimiters. To enable this, use
+
+ \definevimtyping
+ [...]
+ [...
+ escape=command,
+ ]
+
+When `escape=command` is enabled, the `2context.vim` script defines a new
+syntax region using
+
+ syntax region ... start="/BTEX" end="/ETEX" transparent oneline containedin=ALL contains=NONE
+
+and passes content of this region verbatim to TeX. So, any TeX commands used
+inside this region are interpreted by TeX. For example,
+
+ \definevimtyping[C][syntax=c, escape=command]
+
+ \startC
+ /* Here is a comment describing a complicated function */
+ /BTEX\startframedtext[width=\textwidth,corner=round]/ETEX
+ double complicated (...)
+ {
+ ....
+ }
+ /BTEX\stopframedtext/ETEX
+ \stopC
+
+**Note** that as in the case for `escape=comment`, only `\ { }` have their
+usual meaning inside `/BTEX ... /ETEX`. Moreover, spaces are active
+characters. So, using a space between `\startframedtext` and `[` or between
+after the comma in the options to `\startframedtext` will result in an error.
+
+Clearly, `/BTEX ... /ETEX` is not a valid syntax in any language, so if these
+tags are used outside of a comment region (as is the case in the above
+example), the code will not compile. So, if the code also needs to run, then
+these annotations have to be restricted to the comment region of the code.
+
+Although, in practice, the use of both escape mechanisms is restricted to
+comments, the two mechanism have subtle differences. When using
+`escape=comment`, the `2context.vim` script simply passes the content of the
+comment region to TeX. This content is still typeset inside a
+`\SYN[Comment]{...}` group. While when using `escape=command`, the
+`2context.vim` script identifies the content of `/BTEX .. /ETEX` and passes it
+to TeX _without wrapping it insider any `\SYN[..]{...}` group_. This has an
+advantage when we want to use commands that cannot be used inside a group
+(e.g., `\inmargin`). For example, if we want to define a `\callout` macro that
+displays a note in the margin which we can refer to later, we can use:
+
+
+ \define[1]\callout{\inmargin{\rm #1}}
+ \definevimtyping[C][syntax=c, escape=command]
+
+ \startC
+ /* Here is a comment describing a complicated function */
+ double complicated (...)
+ {
+ ... // /BTEX\callout{Fancy trick!}/ETEX
+ }
+ \stopC
+
+Finally, note that the value of `escape` set using `\definevimtyping` is not
+used to `\inline<vim>typing`. If for some reason, you do need the escape
+mechanism for inline code, use
+
+ \inline<vim>typing[escape=command]{...}
+
Tuning color schemes
--------------------
diff --git a/macros/context/contrib/context-vim/tex/context/third/vim/2context.vim b/macros/context/contrib/context-vim/tex/context/third/vim/2context.vim
index 9c72ba1bd1..c83a731c5c 100644
--- a/macros/context/contrib/context-vim/tex/context/third/vim/2context.vim
+++ b/macros/context/contrib/context-vim/tex/context/third/vim/2context.vim
@@ -1,5 +1,5 @@
" Author : Aditya Mahajan <adityam [at] umich [dot] edu>
-" version : 2011.12.23
+" version : 2020.04.25
" license : Simplified BSD License
" This script is part of the t-vim module for ConTeXt. It is based on 2html.vim.
@@ -39,10 +39,22 @@ if !exists("highlight")
endif
" Set escapecomments
-if !exists("escapecomments")
- let escapecomments=0
+if exists("escapecomments")
+ let s:escapecomments=escapecomments " 0=off, 1=comments, 2=command
+else
+ let s:escapecomments=0
endif
+" Add a new syntax region to detect ConTeXt tags
+if s:escapecomments==2
+ syntax region vimtypingTEXcomment start="/BTEX" end="/ETEX" transparent oneline containedin=ALL contains=NONE
+
+ " Find the id of /BTEX ... /ETEX syntax region
+ let s:texcommentid = hlID("vimtypingTEXcomment")
+else
+ let s:texcommentid = -1 " Assuming that all ids are positive. Not documented
+end
+
let s:strip = strlen( matchstr( getline(s:lstart), '^\s*' ) )
" Find the smallest leading white space
@@ -74,6 +86,7 @@ let s:lnum = s:lstart
while s:lnum <= s:lstop
" Get the current line
let s:line = getline(s:lnum)
+
let s:len = strlen(s:line)
let s:new = ''
@@ -81,28 +94,53 @@ while s:lnum <= s:lstop
let s:col = s:strip + 1
while s:col <= s:len
let s:startcol = s:col " The start column for processing text
- let s:id = synID (s:lnum, s:col, 1)
- let s:col = s:col + 1
+
+ " Check if the next transprarent syntax is "vimtypingTEXcomment". If not,
+ " find the next non-transparent syntax id.
+ let s:id = synID (s:lnum, s:col, 0)
+ if s:id == s:texcommentid
+ let s:texcomment = 1
+ else
+ let s:texcomment = 0
+ let s:id = synID (s:lnum, s:col, 1)
+ endif
+ let s:col = s:col + 1
" Speed loop (it's small - that's the trick)
" Go along till we find a change in synID
- while s:col <= s:len && s:id == synID(s:lnum, s:col, 1)
+ while s:col <= s:len
+ " If there is a "vimtypingTEXcomment" inside another syntax id,
+ " "vimtypingTEXcomment" should get preference
+ let s:nextid = synID(s:lnum, s:col, 0)
+ if !s:texcomment && s:nextid != s:texcommentid
+ let s:nextid = synID(s:lnum, s:col, 1)
+ endif
+
+ if s:nextid != s:id
+ break
+ endif
+
let s:col = s:col + 1
endwhile
" Output the text with the same synID, with class set to {s:id_name}
let s:id = synIDtrans (s:id)
let s:id_name = synIDattr (s:id, "name", "gui")
- let s:temp = strpart(s:line, s:startcol - 1, s:col - s:startcol)
+ if s:texcomment
+ " Remove /BTEX and /ETEX which are 5 characters wide
+ let s:temp = strpart(s:line, s:startcol + 5 - 1, s:col - s:startcol - 5 - 5)
+ else
+ let s:temp = strpart(s:line, s:startcol - 1, s:col - s:startcol)
+ end
" Remove line endings (on unix machines reading windows files)
let s:temp = substitute(s:temp, '\r*$', '', '')
" It might have happened that that one has been the last item in a row, so
" we don't need to print in in that case
if strlen(s:temp) > 0
" Change special TeX characters to escape sequences.
- if !(escapecomments && s:id_name == "Comment")
+ if !(s:texcomment || (s:escapecomments == 1) && s:id_name == "Comment")
let s:temp = escape( s:temp, '\{}')
endif
- if !empty(s:id_name)
+ if !(s:texcomment || empty(s:id_name))
let s:temp = '\SYN[' . s:id_name . ']{' . s:temp . '}'
endif
let s:new = s:new . s:temp
diff --git a/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv b/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv
index 17019e1485..7c31c8f6a3 100644
--- a/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv
+++ b/macros/context/contrib/context-vim/tex/context/third/vim/t-syntax-highlight.mkiv
@@ -87,13 +87,13 @@
\forgetall
\usealignparameter\externalfilterparameter
- \doifinset{\externalfilterparameter\c!option}{\v!packed}
+ \doifinset{\v!packed}{\externalfilterparameter\c!option}
{\setupwhitespace[\v!none,\v!flexible]}%
\doadaptleftskip{\externalfilterparameter\c!margin}%
\setbreakpoints[compound]% Only works is `option=hyphenated` is set.
- \doifnotinset{\externalfilterparameter\c!option}{\v!hyphenated}
+ \doifnotinset{\v!hyphenated}{\externalfilterparameter\c!option}
{\language\minusone}%
\def\obeyedline{\strut\par}
diff --git a/macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex b/macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex
index 3cd83cdb2f..eb0adbfe7b 100644
--- a/macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex
+++ b/macros/context/contrib/context-vim/tex/context/third/vim/t-vim.tex
@@ -1,6 +1,6 @@
%D \module
%D [ file=t-vim,
-%D version=2018.04.17,
+%D version=2020.04.25,
%D title=\CONTEXT\ User Module,
%D subtitle=Vim syntax highlighting,
%D author=Aditya Mahajan,
@@ -9,7 +9,7 @@
%D email=adityam <at> ieee <dot> org,
%D license=Simplified BSD License]
-\writestatus{loading}{Vim syntax highlighting (ver: 2018.04.17)}
+\writestatus{loading}{Vim syntax highlighting (ver: 2020.04.25)}
\startmodule [vim]
\usemodule [filter] % loads module catcodes
@@ -129,7 +129,7 @@
-c "let contextstartline=\externalfilterparameter\c!start \letterbar\space %
let contextstopline=\externalfilterparameter\c!stop \letterbar\space %
let strip=\getvalue{\vimtyping@id-\c!strip-\externalfilterparameter\c!strip}" %
- -c "let escapecomments=\getvalue{\vimtyping@id-\c!escape-\externalfilterparameter\c!escape}" %
+ -c "let escapecomments=\getvalue{\vimtyping@id-\c!escape-\externalfilterparameter\c!escape}"
-c "let highlight=[\externalfilterparameter\c!highlight]" %
\vimrc_extras\space
-c "source \vimtyping@script_name" %
@@ -140,9 +140,14 @@
\setvalue{\vimtyping@id-\c!strip-\v!off}{0}
\setvalue{\vimtyping@id-\c!strip-\v!on}{1}
+\setvalue{\vimtyping@id-\c!escape-}{0} % Empty value
+
\setvalue{\vimtyping@id-\c!escape-\v!off}{0}
\setvalue{\vimtyping@id-\c!escape-\v!on}{1}
+\setvalue{\vimtyping@id-\c!escape-\v!comment}{1}
+\setvalue{\vimtyping@id-\c!escape-\v!command}{2}
+
% Undocumented ... but useful if the user makes a mistake
\setvalue{\vimtyping@id-\c!strip-\v!no}{0}
@@ -151,7 +156,6 @@
\setvalue{\vimtyping@id-\c!escape-\v!no}{0}
\setvalue{\vimtyping@id-\c!escape-\v!yes}{1}
-
\setupvimtyping
[% \c!tab=4,
% \c!start=1,