indents aren't working for me when generating text
Hi,
I don't know if I'm doing something wrong, but I've tried both Textgen and gText, and neither are outputting indentations when I use the indent nodes. As gText uses Textgen to output, I'm guessing the problem lies in Textgen somewhere.
Is there a trick to this, or is it just broken?
I'm running 1.5.1. I tried to get 2.0 running, but it was throwing an exception on startup.
Please sign in to leave a comment.
Hi!
Here is brief description of how to use line indentations in Textgen language aspect:
you can increase indent level by wrapping some parts of Textgen definition into "with indent" block:
and you can _explicitly_ insert current indent into the buffer by using intent buffer statement:
so, following construction
will produce "public" word prefixed by two indents.
i did run into the same problem.
I'm using 2.0M5. And i have a textgen, where i use "with indention". Also tried indent buffer;
Perhaps there is some bug in it... But it is working in the java-textgen...
append \n ; indent buffer ; append ${node.localVariableDeclaration} {;} ;In addition, you can try calling
instructions instead of using
with indent { // text gen for child nodes }I just created a new project to test the indent stuff and it didn't work there again.
TestProject.zip (59KB)
You can look at the generated file:
"With indent" and "increase depth" don't seem to work.
The only thing working seems to be indent buffer. But I'm not sure how it is working....
instruction is just a way to insert corresponding indent into the current place in a buffer, so you should put it on each line. I modified text gen of your sample project to produce correct output:
text gen component for concept JustSomeTest { extension : (node)->string { "txt"; } encoding : utf-8 (node, context, buffer)->void { append {just some test } ${node.name} { {} \n ; with indent { indent buffer ; append {test: } ${node.test} \n ; append \n ; indent buffer ; append {child stuff:} \n ; with indent { append $list{node.childStuff} ; } } append {}} ; } }text gen component for concept ChildConcept { (node, context, buffer)->void { indent buffer ; append {child: } ${node.childtext} \n ; } }so it works rather well:
just some test this is cool { test: so cool! child stuff: child: firstchild child: secondchild child: third }I though "with indent" would do the job and indent all lines that are in this block automatically...