This post 
<https://groups.google.com/d/msg/leo-editor/QBvmeT0zQyM/I4jYcZmiAgAJ> shows 
a button that sends code to rust. Thomas adapted it for Graal/JS here 
<https://groups.google.com/d/msg/leo-editor/hweJvjeYiEM/bdNoNWniAwAJ>.

My original code contained a hack, which Thomas naturally used. The hack 
just removes @language directives.

My example was misleading. There is a much better way. Instead of the hack:

lines = p.b.split('\n')
prog = '\n'.join([
    line for line in lines if not line.startswith('@language')
])

scripts should do this instead:

s = c.atFileCommands.stringToString(
    p, p.b, forcePythonSentinels=False, sentinels=False)
prog = s.replace("\r\n", "\n")  # Use brute force. 

This removes all Leo directives and *also* supports @language and section 
references.

I found this code in one of the helpers of g.getScript. It's not so easy to 
use g.getScript directly, as you can see for yourself if you are interested.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/05ecd393-a45a-4647-b6c3-38cf1a1e89c0%40googlegroups.com.

Reply via email to