| Search internet |
The render-txt function of the previous section was custom made for the txt construct. Now consider the more complex problem of defining a new rendering operator which can be re-used in the right hand side of many different rendering definitions.
As a motivating example consider a 'newline pair' construct which renders as a newline and evaluates as a pair:


The above looks ok, but if we use indexed variables in the value definition, the rendering looks quite bad:

An indexed variable has a subscript operator as principal operator. The subscript operator takes two parameters. When used, the second parameter is rendered as a subscript of the first parameter as can be seen in the right hand side of the definition above. When shown, it looks as in the left hand side above.
The problem is that the value definition construct
renders its first argument using show rendering. The rendering definition of the value definition construct reads:
tex show define value define x as y end define as "
[ "[ texshow x end texshow ]"
\mathrel{\dot{=}} "[ y ]"
]" end define
The texshow...end texshow rendering operator causes all of x to be show rendered.
If you try to find where the texshow construct is defined, you will search in vain. The texshow construct has the behavior it has because it has arity one and no value definition. The default renderer treats all constructs with arity one and no value as a texshow construct. To find the line of code which implements this, go to the lgc page and locate the definition of lgc-render-eval in the section named 'rendering evaluator'. The penultimate line of the definition switches to show rendering for constructs with arity one.
To get indexed variables look right, we define a new value definition construct:

![tex show define root value define x as y end define as "
[ "[ texrootshow x end show ]"
\mathrel{\dot{\equiv}} "[ y ]"
]" end define tex show define root value define x as y end define as "
[ "[ texrootshow x end show ]"
\mathrel{\dot{\equiv}} "[ y ]"
]" end define](../../renderings/0B4696C087FE9CC562689A0F03E060A4125FC17B.png)
The next section defines texrootshow such that it shows the principal operator of x but renders the rest of x normally. That makes indexed variables look right:

| Search logiweb.eu |