Hi Mike,
Thanks for the feedback. The key is indeed that this type of transformation can only truly deliver its power if it sits before observable. Your assessment is spot-on. I’m fine with either option. (although ganja.js currently does not know what variables are from what scope and simply doesn’t touch any of them).
For now, I’ve upgraded ganja so that inline can also be used as template function - it makes the template approach as simple as I can get it :
Algebra = require("ganja.js")
p2 = Algebra(2,0,1).inline
some_point = p2`1e12+.5e02`
some_expression = p2`2*${some_point}`
For those libs that are true js->js (like ganja or say prepack) it would really be killer to be able to keep syntax highlighting. (ganja’s operators and syntax have been painfully restricted to keep editor features valid)
I have no brilliant suggestions for how that would be most elegantly specified in observable - one idea is to augment template string functions with extra properties. (i.e. specify for a template function what syntax highlighter to use, and if its a ‘before’ or ‘after’ template)
var templateFunc = Algebra(2,0,1).inline;
templateFunc.syntaxHighlight = 'javascript';
templateFunc.beforeObservable = true;
This would give an ‘in’ to also do syntax highlighting on html,svg,tex, …
Just a thought.
Cheers,
S.