Skip to content

Instantly share code, notes, and snippets.

@pthom
Last active August 1, 2020 21:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pthom/c1166fe674781f1e4f75cf27be84fd66 to your computer and use it in GitHub Desktop.
Save pthom/c1166fe674781f1e4f75cf27be84fd66 to your computer and use it in GitHub Desktop.
literate_programming_editor

I sometimes dream of a source code editor that would allow inline diagrams and nicele rendered documentation and or equations. This could apply to any language that has support for multiline comments.

For example, a code like this, (where md stands for markdown)

/*md
Square value of *any* type
* please remember to set to rocket on fire before launch!
*/
template<typename T>int square(T v) {
    return v * v;
}

would render like:

Square value of any type

  • please remember to set to rocket on fire before launch! + Edit
template<typename T>int square(T v) {
    return v * v;
}

And a code like this (where the plantuml markup would be rendered by plantuml

/*md
Below is a diagram
*/

/*plantuml
@startuml
B *-- A
@enduml
*/

struct A { 
}

struct B {
    A a;
}

Would render like

Below is a diagram                         + Edit

a                         + Edit

struct A { 
}

struct B {
    A a;
}
@rushsteve1
Copy link

Much of this is supported in Emacs Org-Mode using the tools provided by the Babel module. Org-Mode supports various formatting (bold, italics, etc.), inline images, and PlantUML themselves have a page on using PlantUML with Org-Mode.

Source blocks within Org-Mode can also be easily opened in a separate buffer where you get the full editing features of that language. Once the buffer is closed your changes are put back in the document.

@boltex
Copy link

boltex commented Aug 1, 2020

Yeah - what about "Leo editor" and soon to be 'leoInteg' ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment