# [NTG-context] an object representation of the node list of a paragraph: a lua table or a JSON

Hans Hagen j.hagen at xs4all.nl
Wed Jul 10 13:27:09 CEST 2019

On 7/10/2019 12:02 PM, mf wrote:
> Hello list,
> i'd like having an object representation of a typeset paragraph or even
> a page, preferably as a JSON object, but a Lua table is equally good.
>
> My reference is section "4.4 Node lists" of the CLD manual.
>
> Before writing an iterator over the list of nodes of a paragraph,
> figuring out all the possible nodes and their fields, i'm wondering if
> there's some hidden tool in the ConTeXt coffer to simplify the task.
\starttext
\setbox0\vbox{\input tufte }
\ctxlua{inspect(nodes.totable(tex.box[0]))}
\stoptext

\starttext
\setbox0\vbox{\input tufte }
\ctxlua{
require("util-jsn")
inspect(utilities.json.tojson(nodes.totable(tex.box[0])))
}
\stoptext

(or use the export)

-----------------------------------------------------------------