I want to render some lines of code inside a tikz node:
\usemodule[tikz]
\definetyping[code][bodyfont=small,escape={`,`}]
\starttext
\tikzset{
code/.style={rectangle, rounded corners, draw=black}
}
\starttikzpicture[node distance=.7cm]
\node[code] (g1) {
\startcode
i = 1
t1 = 20
iloop: if i > t1 goto iexit
\stopcode
};
\stoptikzpicture
\stoptext
Which renders:
As you can see, all line breaks are missing. I managed to enhance this by using paragraphs:
\usemodule[tikz]
\definetyping[code][bodyfont=small,escape={`,`}]
\defineparagraphs[CodeNode][n=1]
\setupparagraphs[CodeNode][1][width=.5\textwidth]
\starttext
\tikzset{
code/.style={rectangle, rounded corners, draw=black}
}
\starttikzpicture[node distance=.7cm]
\node[code] (g1) {
\startCodeNode
\startcode
i = 1
t1 = 20
iloop: if i > t1 goto iexit
\stopcode
\stopCodeNode
};
\stoptikzpicture
\stoptext
This renders:
Which is more close to what I want, but I now needed to give a specific width. How can I create a node that automatically encloses the given code without giving a width?