[NTG-context] copy & paste source code from documents

Hans Hagen pragma at wxs.nl
Sat Nov 26 11:40:03 CET 2016

On 11/26/2016 7:52 AM, Tobias Berndt wrote:
> Dear List,
> currently, I have to compose technical documents with a lot of source code in it. There're readers demands for a way to copy&paste this source code directly from those documents into their terminals. I tried ConTeXt’s attachment functionality, it is … ok. But most people don’t like files attatched to PDFs. Moreover, they must open it in an editor before getting contents in terminals. So,

normally a viewer is quite restricted out of security reasons

> is there any possibility in ConTeXt/Lua a document reader can click on a source code statement and the content of an external file (the plain code, without any typesetting) will be loaded into the clipboard, so that they can paste this plain source code into their terminal programs to use it directly?

here is an option (the last examples need an upcoming beta as i added 
better space support for verbatim comments)



for i=1,10 do


currently: \comment{\cldcontext{buffers.getcontent("a")}}


hacked: \comment{\cldcontext{string.gsub(buffers.getcontent("a"),


new, space honored, still hack: 


new, buffer honored: \comment[buffer=a]{}


idem: \comment[space=yes,buffer=a]{}




                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: oeps.pdf
Type: application/pdf
Size: 9802 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20161126/c78e0531/attachment-0001.pdf>

More information about the ntg-context mailing list