Skip to content

Instantly share code, notes, and snippets.

@ul

ul/output.txt Secret

Last active November 6, 2017 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ul/0e04ecc600b2c975e863baf1f41e0e4b to your computer and use it in GitHub Desktop.
Save ul/0e04ecc600b2c975e863baf1f41e0e4b to your computer and use it in GitHub Desktop.
["" [[path "" body ["(define (id x)" " x)"]]] "" [[path "" body [" (define x 1)" " <<id>>" " (id x)"]]] "" [[path "test2.ss" body [" :paddle no" " (define y 2)" " <<id>>" " (id x)"]]] "" [[path "test.ss" body [" :paddle no" " ;; ok" " <<test2.ss>>"]]]]
input: {
Test for tangle.red.
#+NAME: id
#+BEGIN_SRC scheme
(define (id x)
x)
#+END_SRC
boo
#+BEGIN_SRC scheme
(define x 1)
<<id>>
(id x)
#+END_SRC
yadaydya
#+NAME: test2.ss
#+BEGIN_SRC scheme :tangle test2.ss :paddle no
(define y 2)
<<id>>
(id x)
#+END_SRC
bla-b;a
#+BEGIN_SRC scheme :tangle test.ss :paddle no
;; ok
<<test2.ss>>
#+END_SRC
}
src-name: ["#+NAME:" any space copy name to newline]
src-path: [":tangle" some space copy path to [space thru newline | newline]]
src-begin: ["#+BEGIN_SRC" thru [src-path | copy path none newline]]
src-end: ["#+END_SRC"]
src-collect: [
keep (copy name)
collect keep (reduce ['path (copy path) 'body (split body newline)])
]
src-body: [src-begin copy body to src-end src-collect]
code: [[ src-name | copy name none] src-body ]
prose: [thru newline]
doc: [some [code | prose] to end]
probe parse input [collect doc]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment