From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
Ramkumar KB <ramkumarkb@gmail.com>
Subject: Re: Running mtxrun in a continuous batch mode
Date: Tue, 3 Nov 2020 12:02:39 +0100 [thread overview]
Message-ID: <001a4cfc-d1ec-dbc9-0f2a-3d9bf613a035@xs4all.nl> (raw)
In-Reply-To: <CAMD5SRM=Ndxvkx=b2t-gogWmgZap_uCujWNHC_739qc9t2vGMQ@mail.gmail.com>
On 11/3/2020 1:55 AM, Ramkumar KB wrote:
> Hello,
>
> I am trying to run mtxrun in a batch process and read the available
> documentation here -
> https://wiki.contextgarden.net/Running_ConTeXt_without_a_shell
>
> My usecase is being able to create PDF docs based on the input data that
> comes in a JSON format (in a continuous batch process). In ConTeXt,
> thanks to the Lua engine, I am able to inject a JSON read from a file -
> and use the JSON in the tex file (here variable `tab` holds the JSON).
>
> How do I make this as a continuous webservice - in comes JSON and out
> comes the PDF ?
>
> \startluacode
> require("test-json")
> \stopluacode
>
> The name of the document is \ctxlua{tex.print(tab['documentName'])}
>
> Any tips or pointers would be much appreciated.
foo.cld :
require("util-jsn")
-- local str = io.loaddata("somefile.json")
local str = [[ {
"title": "Some JSON",
"text" : "Just an example.",
"data" : [
{ "a" : "first 1", "b" : "last 1" },
{ "b" : "last 2", "a" : "first 2" }
]
} ]]
local tmp = utilities.json.tolua(str)
context.starttext()
context.starttitle { title = tmp.title }
context(tmp.text) context.par()
context.starttabulate { "|c|c|" }
for i=1,#tmp.data do
local d = tmp.data[i]
context.NC()
context(d.a) context.NC()
context(d.b) context.NC()
context.NR()
end
context.stoptabulate()
context.stoptitle()
context.stoptext()
and then
context foo.cld
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2020-11-03 11:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 0:55 Ramkumar KB
2020-11-03 11:02 ` Hans Hagen [this message]
2020-11-04 3:48 ` Ramkumar KB
2020-11-04 11:24 ` Hans Hagen
2020-11-06 8:38 ` Ramkumar KB
2020-11-06 8:47 ` thierry horsin
2020-11-06 14:51 ` Aditya Mahajan
2020-11-07 1:29 ` Ramkumar KB
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=001a4cfc-d1ec-dbc9-0f2a-3d9bf613a035@xs4all.nl \
--to=j.hagen@xs4all.nl \
--cc=ntg-context@ntg.nl \
--cc=ramkumarkb@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).