Hi and thank you Aditaya and again Hans. By the way, just for fun , is there a(n easy) way to get the linenumber in the tex file ? Thanks On 03/09/2021 18:04, ntg-context-request@ntg.nl wrote:
------------------------------
Message: 4 Date: Fri, 3 Sep 2021 14:16:40 +0200 From: Hans Hagen
To: mailing list for ConTeXt users Cc: Thierry Horsin Subject: Re: [NTG-context] getting line numbers Message-ID: <807e4b7c-97ae-e20e-3207-28393544c5e5@xs4all.nl> Content-Type: text/plain; charset=utf-8; format=flowed in this case, thinking a bit different is easier ...
\starttext
\startbuffer[MyBuffer] #include <iostream>
using namespace std; int mysum(int,int); int a; int b; int main () { a=2; b=9; cout << mysum(a,b) << endl; return 0; } int mysum(int a, int b) { return a+b; } \stopbuffer
We compile and run:
\typebuffer[MyBuffer][option=C]
\startluacode io.savedata("test.cpp",buffers.getcontent("MyBuffer")) --os.execute("g++ -o test test.cpp") --os.execute("./test > test.tmp") os.execute("echo done > test.tmp") buffers.assign("MyBuffer",io.loaddata("test.tmp")) \stopluacode
And get:
\typebuffer[MyBuffer]
Or just:
\typefile{test.tmp}
\stoptext
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
------------------------------
------------------------------
Message: 6 Date: Fri, 3 Sep 2021 09:53:58 -0400 (EDT) From: Aditya Mahajan
To: Thierry Horsin via ntg-context Subject: Re: [NTG-context] getting line numbers Message-ID: Content-Type: text/plain; charset=US-ASCII On Fri, 3 Sep 2021, Thierry Horsin via ntg-context wrote:
https://github.com/adityam/filter
Behind the scenes, it works by saving the content in an external file and then running it through any external program. It also allows for caching the result, and has many options for customizing the behavior.
Aditya