On Sat, Mar 18, 2017 at 3:58 PM, 123 456 <[email protected]> wrote:

> How ... do I get only the code part of a section?
>
> ​I'm not entirely sure what you mean by "section". The answers below
assume you mean a Leo node.

The answer to all such questions is to look for helpers in Leo's code
related to the topic. leoGlobals.py is a good place to start looking.

For all scripting-related issues, start looking in:

    @file leoGlobals.py-->g.Scripting

You could have found this section by looking for the 'execute-script'
command. Do this by searching for 'execute-script', including the single
quotes.  You will find c.executeScript.  It does a lot of things, but first
it calls g.getScript.

g.getScript has two helpers.  g.extractExecutableString is probably what
you want.  Its docstring is:

     '''
    Return all lines for the given @language directive.

    Ignore all lines under control of any other @language directive.
    '''

To find a node with a given section name, you can start looking in
leoAtFile.py. In the node:

    @file leoAtFile.py-->class AtFile-->at.Writing-->Writing 4.x utils...

you will find at.findSectionName. This scans text looking for << section
name >>.

In the node:

    @file leoAtFile.py-->class AtFile-->at.Writing-->Writing 4.x-->
    writing code lines...-->putRefLine & allies

you will find at.findReference, which searches a tree for a section
definition node.  This calls g.findReference, so once again we are back to
a function in leoGlobals.py.

> Is there a way to associate data in a section with one or more sections.
> Idea is a section can hold a bi-directional dictionary.
>
The answer will probably involve uA's
<http://leoeditor.com/customizing.html#adding-extensible-attributes-to-nodes-and-leo-files>.
​These *user attributes* can be attached to any node using p.u = aDict.

> Is there a way for a section to show raw and rendered views?
>
Again, I'm not sure what you mean by a section.  If you mean "the body text
of a node", then your script can create reStructuredText or markdown text
whose effect will be to show raw and rendered views.  Your script could
also create several nodes.

HTH. Please feel free to ask other questions.

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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to