Hi Offray,
the idea is basically the same. I used lstrip() to remove any leading space
characters so that
the split(' ', 1)[0] call will always return the first space delimited
token. Also, I don't think you need
to worry about always having a space at the end of the headline.
Jack
On Monday, January 6, 2014 11:05:07 AM UTC-5, Offray Vladimir Luna Cárdenas
wrote:
>
> Hi Jack,
>
> Your implementation seems pretty similar to the one of Terry. I just
> implemented that, because was the first I read. Just curious about the
> variations, between both of them.
>
> Cheers,
>
> Offray
>
> El 05/01/14 22:19, Jack Kuan escribió:
> > Hi,
> >
> > not sure about your other questions, but you can do:
> >
> > at_keywords = ['@config', '@ignore', '@biblio', '@ref']
> > if node.h.lstrip().split(' ', 1)[0] not in at_keywords:
> >
> > hope that helps.
> > Jack
> >
> > On Sunday, January 5, 2014 10:01:16 PM UTC-5, Offray Vladimir Luna
> Cárdenas wrote:
> >
> > Hi,
> >
> > Several years ago I had the epiphany of Leo with the idea of code
> as
> > data and data as code inside the Leo tree structure. The practical
> side
> > of it didn't come until recently, when I start to use @button nodes
> to
> > change the way I used Leo to export the tree as a flat file with
> light
> > markup. I started with txt2tags and recently I made a small script
> for
> > converting Leo trees to pandoc. You can see its source code here:
> >
> > http://pastebin.com/8RuRrGfX
> >
> > Is working well but I would like to make it better. So, some
> questions
> > about it:
> >
> > - I traverse the Leo tree looking for "@keywords" and treating the
> nodes
> > and headers accordingly. @keywords are detected with this code:
> >
> > ~~~{.code}
> > if not (node.h.startswith('@config') or
> > node.h.startswith('@ignore') or
> > node.h.startswith('@biblio') or
> > node.h.startswith('@ref')):
> >
> > ~~~
> >
> > but I would like to have a more succinct way to do it, maybe with a
> > list. I remember having problems with this:
> >
> > ~~~{.code}
> > if not (node.h.startswith(['@config', '@ignore', '@biblio', '@ref']
> > ~~~
> >
> > So, ¿there is any other and more elegant way to define a list of
> words
> > with @keywords that need to be treated in a special way?
> >
> > I have defined a "@ignore" keyword and the idea is to do nothing,
> not
> > only with that node but also with all the children. With this piece
> of
> > code I know how to treat the subnodes of the bibliography in a
> special way:
> >
> > ~~~{.code}
> > # Bibliographic references
> > elif node.h.startswith('@biblio'):
> > # Create the bibliography title
> > toFile.append('#'*level + ' ' + node.h[8:] + ' ' +
> '#'*level)
> > toFile.append('\n\n')
> > # Staring the yaml list
> > toFile.append('---')
> > toFile.append('references:')
> > # Put the bibliography introductory content. These must be yaml
> coments
> > toFile.append(node.b)
> > # Get all the subnodes (one for each bibliographic reference)
> > # and add the content. This content is in yaml format, following
> > # the pandoc conventions.
> > references = [node.copy().b for node in node.subtree()]
> > for reference in references:
> > toFile.append(reference)
> > # Ending the yaml list:
> > toFile.append('...')
> > ~~~
> >
> > but curiously I don't know how to say: do nothing if the node is
> > children of a "@ignore" parent node. ¿How can this be done? (I
> imagine
> > that @rst-ignore code can be used for this, but I don't know where
> to
> > look for it).
> >
> > It has been a long way from making outlines in Leo to
> document/organize
> > my stuff, to using Leo to change the way I wrote academical papers.
> > Thanks to all the community for being part of it and I hope to find
> a
> > way to make Leo more used in the academical context and outside the
> > programmers niche.
> >
> > Cheers,
> >
> > Offray
> >
> > ps: I know that reST can be used for writing academical papers and
> it
> > has native support on Leo, but this approach is more natural and
> organic
> > to my, mainly because of the use of yaml for bibliographic
> references
> > and the workflow that using yaml of zotero.
> >
> > ps2: There is another nice reST based editor, open source and free
> > software for academical writings that is online: https://notex.ch/I
> > would like to have a similar kind of experience to it on Leo. Yaml
> files
> > for configuration/customization, cursive and bold fonts redering
> inside
> > the body panel and figures previews and a better tool bar for
> supporting
> > writing. Where Leo is unbeatable is in its ability of using the Leo
> tree
> > to program all Leo behaviour even the treatment of the text and the
> > final output. NoTeX is even more difficult to install that Leo. In
> most
> > Linux distros, installing Leo is just a matter of typing a command,
> > while in Windows/Mac is a lot of geeky instructions just for having
> a
> > taste of its potential. NoTeX can be used online without
> installing, but
> > trying to have it running on your local machine seems like juggling
> with
> > a lot of moving parts.
> >
> > --
> > 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] <javascript:>.
> > To post to this group, send email to
> > [email protected]<javascript:>.
>
> > Visit this group at http://groups.google.com/group/leo-editor.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
>
>
--
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 http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.