3 ms·
They’re not mentioned in the article, but org-mode does have syntax for source blocks (a little uglier than Commonmark/Github-flavor markdown’s blocks in my opi
by confounded 7y ago
They’re not mentioned in the article, but org-mode does have syntax for source blocks (a little uglier than Commonmark/Github-flavor markdown’s blocks in my opinion, but it does the same thing and works well).
- walkingolof 7y agoAnd you can execute that code too with Babel ———> https://orgmode.org/worg/org-contrib/babel/ https://orgmode.org/worg/org-contrib/babel/
- TeMPOraL 7y agoIt may seem uglier if you use it first time: #+BEGIN_SRC lisp (format t "Hello world!~&") #+END_SRC but it has two things going for it. One, it's consistent with other blocks, like BEGIN_QUOTE, BEGIN_EXAMPLE, BEGIN_VERSE, etc. (n.b. all four have a default shorthand that gets tab-expanded; <s. <q, <e and <v, respectively) , and with arbitrary user-defined blocks like BEGIN_whatever. Two, while #+BEGIN_SRC may seem only an unnecessarily verbose way of writing ```, things change when the block starts to look like this: #+NAME: advanced-block #+BEGIN_SRC lisp :package my-package :var foo=123 :var bar=asdf :noweb yes :exports both :eval never-export <<preamble>> (format t "Hello ~A!~&" <<some-other-block(param=3.14)>> ) #+END_SRC AKA. a named source block (so I can reference it elsewhere) of Lisp executing in selected Lisp package, with org mode variables injected into it, using noweb syntax (literate programming) for injecting other code blocks[0], which when exporting the document to a different format (say, PDF) will export both code and results of its evaluation, but will not automatically evaluate the code. This feature makes Org Mode essentially a kind of better Jupyter, with automatic support for any and all possible language that you can plug into Emacs, simultaneously. -- [0] -- here, it'll paste the literal contents of #+BEGIN_SRC block with #+NAME: preamble at the beginning, and then paste the results of executing a block with #+NAME: some-other-block, with value 3.14 for its :var param, at the end
- kqr 7y agoI have a slight preference for #+NAME: advanced-block #+HEADER: :noweb yes :exports both :eval never-export #+HEADER: :package my-package :var foo=123 :var bar=asdf #+BEGIN_SRC lisp <<preamble>> (format t "Hello ~A!~&" <<some-other-block(param=3.14)>> ) #+END_SRC (Just wanted to point out that the header format has even more flexibility than what you've shown!)