Am Montag, 23. März 2020 16:49:08 UTC+1 schrieb Edward K. Ream: 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. > > Both solutions seems to be flawed as none of them is filtering by language. Is this uncommon in leo-community? I often have nodes with multiple mixed languages or mixed plaintext and code. Both of those solutions would mix this plaintext with code or code of different languages together it seems.
-- 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/2b9a64bc-33ee-42f0-b606-a7846c7cc2b9%40googlegroups.com.
