starting with leo writing literate python

31 views
Skip to first unread message

Eric S. Johansson

unread,
Feb 2, 2017, 5:06:37 AM2/2/17
to leo-editor
back way too many years ago I started literate programming with cweb.  I'm returning to LP using leo but either I'm missing a feature or the approach has changed.  back in cweb days I wrote each section with a narrative and then a code section.  I've started importing an existing bit of code and got the code section right but I can't figure out how to create a narrative section.

Edward K. Ream

unread,
Feb 2, 2017, 5:19:08 AM2/2/17
to leo-editor
On Thu, Feb 2, 2017 at 1:09 AM, Eric S. Johansson <ynotla...@gmail.com> wrote:
back way too many years ago I started literate programming with cweb.  I'm returning to LP using leo but either I'm missing a feature or the approach has changed.  back in cweb days I wrote each section with a narrative and then a code section.  I've started importing an existing bit of code and got the code section right but I can't figure out how to create a narrative section.

​Use:

@ your narrative, continued over several lines
@c
your code​

However, this colorizers the narrative as a python comment. A workaround is:

@language python # Required
@
@language rest
@wrap (optional)
Narrative, now *colored* using reStructuredText.
@c
@language python
def spam():
    pass

Yes, this is clumsy. Worse, it puts sentinel comments in the narrative.

The timing of your question is excellent.  I have been working on the colorizer for several weeks.  It may be possible to colorize all doc parts using reStructuredText.  I'll look into this today.

Edward

Edward K. Ream

unread,
Feb 2, 2017, 6:02:02 AM2/2/17
to leo-editor
On Thu, Feb 2, 2017 at 4:19 AM, Edward K. Ream <edre...@gmail.com> wrote:

It may be possible to colorize all doc parts using reStructuredText.  I'll look into this today.

​Done in master at 66b8533.  This is a super improvement to Leo.

Edward
Reply all
Reply to author
Forward
0 new messages