ConTeXt: Use of t-vim module in table
Since t-vim
is built on top of t-filter
, you can can use the \process<filter>buffer
command to load an existing buffer:
\usemodule[vim]
\definevimtyping
[somecode]
[lines=split]
\definevimtyping
[RUBY]
[syntax=ruby]
\starttext
\startbuffer[ruby]
# Ruby program listing
print("Hello World")
\stopbuffer
\startbuffer[somecode]
test code
more lines
\stopbuffer
\bTABLE
\bTR
\bTD
\processsomecodebuffer[somecode]
\eTD
\bTD
\processRUBYbuffer[ruby]
\eTD
\eTR
\eTABLE
\stoptext
You could alternatively use the module ntb-to-xtb
, which lets you use xtables with natural table syntax (in other words: this lets you use TeXnicians solution without changing the code):
\usemodule[vim]
\usemodule[ntb-to-xtb]
\definevimtyping
[somecode]
[lines=split]
\definevimtyping
[RUBY]
[syntax=ruby]
\starttext
\bTABLE
\bTR
\bTD
\startsomecode
test code
more lines
\stopsomecode
\eTD
\bTD
\startRUBY
# Ruby program listing
print("Hello World")
\stopRUBY
\eTD
\eTR
\eTABLE
\stoptext
The output for both solutions is the same:
More of a comment than an answer: With xtables you may use verbatim material directly.
\usemodule[vim]
\definevimtyping
[somecode]
[lines=split]
\starttext
\typebuffer[visit]
\startxtable
\startxrow
\startxcell
\startsomecode
test code
\stopsomecode
\stopxcell
\stopxrow
\stopxtable
\stoptext