On Sun, 13 Oct 2013 12:10:41 -0700 (PDT)
wgw <[email protected]> wrote:
> Yes, that does seem like the solution, but is it possible to write that
> solution and then "attach" it to a new, user-defined directive, such as
> @autohead, which could then be used in place of @auto?
>
> In short, can the user create a new file output directives (to go along
> with @file, @auto, @nosent, etc) ?
>
> I just find it odd that we lose the headings in the @auto output.
There's no where to store them in the files generated by @auto, which
are basically plain files. @shadow stores them in a separate database.
But you actually want them to appear in the output file?
I was curious how short a script could be to write a file (with
headings):
open("/tmp/t.txt", 'w').write('\n'.join("%s\n%s"%(i.h, i.b) for i in
p.self_and_subtree()))
open("/tmp/t.txt", 'w').write('\n'.join("%s%s\n%s"%(" "*(i.level()-p.level()),
i.h, i.b) for i in p.self_and_subtree()))
without and with indentation, respectively.
What I've done when I want the headlines to appear in the output, for
example in the R statistical language, is write it with @shadow, and
make a button to add / update the heading into the first row of each
body, so headline and body content are:
find_mean
### find_mean #####################################################
<code for finding mean>
Here's that button code, but I'm not sure if it's working exactly
right, be careful.
# insert / update headlines as comments in @nosent R code
for nd in p.self_and_subtree_iter():
if nd.h and nd.h[0] == '@' or nd.b and nd.b[0] == '@':
continue
lines = nd.b.split('\n')
if lines[0].startswith('### '):
del lines[0]
if lines[0].strip():
lines[0:0] = [""]
lines[0:0] = [
"### %s %s" % (nd.h, "#"*(80-len(nd.h)-5)),
]
Cheers -Terry
> Thanks!
>
> Bill
>
> Le dimanche 13 octobre 2013 11:58:36 UTC-7, Fidel N a écrit :
> >
> > Hey:
> > If I understand correctly, what you need is the position property called
> > level.
> >
> > So depending on the number you get in c.p.level()
> > You get different string such as:
> >
> > for i in range(c.p.level()):
> > string.append(r"#@")
> > string.append(c.p.h)
> >
> > Then you add that string to the output file and add its body, then keep
> > going to the next node.
> >
> > On Sunday, October 13, 2013 8:52:57 PM UTC+2, wgw wrote:
> >>
> >> Is there are way to put the outline structure in a user-defined comment
> >> format? I want to generate a stripped down version of @file, where the
> >> only thing that would be indicated in the #@ comments would be the
> >> headings
> >> and their level. That comment string could be user-defined, so you might
> >> want "#####<legal numbering>" or other.
> >>
> >> This would of course lose the directives and so on, but retain the
> >> headings and their hierarchy. A file that is something between the @auto
> >> and the @file format. (Right now, I just reformat the @file and strip
> >> anything that isn't a node.)
> >>
> >> For example, if the leo headings are:
> >>
> >> a
> >> .b
> >> .c
> >> ..d
> >> e
> >>
> >> then the output file would indicate the outline structure by a proper
> >> stacking of #@ :
> >>
> >> #@ a
> >> code and comments
> >> #@#@ b
> >> code and comments
> >> #@#@ c
> >> code and comments
> >> #@#@#@ d
> >> code and comments
> >> #@ e
> >> code and comments
> >>
> >>
> >> Is there any easy way to achieve that output format?
> >>
> >> Thanks!
> >>
> >
>
--
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.