5 ms·
: Simple pre-formatted text such as for source code. : This also respects the line breaks. *bold* is not bold here. The trouble with that is you cannot eas
by skookumchuck 8y ago
: Simple pre-formatted text such as for source code.
: This also respects the line breaks. *bold* is not bold here.
The trouble with that is you cannot easily copy/paste code to/from it, because you'll need to manually add/subtract the : prefix. Delineating the section with:
```
Simple pre-formatted text such as for source code.
This also respects the line breaks. *bold* is not bold here.
```
is much more practical.
- confounded 8y agoThey’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 8y agoAnd you can execute that code too with Babel ———> https://orgmode.org/worg/org-contrib/babel/ https://orgmode.org/worg/org-contrib/babel/
- TeMPOraL 8y 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 8y 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!)
- adbge 8y agoM-x comment-region
- roenxi 8y agoThis deserves a little expansion - Org Mode makes the reasonable-in-context assumption that the user is familiar with Emacs. At that point, adding or removing a ':' is not a repetitive task. Then the ':' notation gains an advantage because selected lines can be copied and automatically keep their formatted status.
- jacobolus 8y agoIn any reasonable editor, “manually add/subtract the prefix” is an easy keyboard shortcut.
- zapzupnz 8y agoExcept one is not always able to use an editor, and assuming people are always able to do something is a great downfall of many products or standards made by people with specific uses cases in mind who think their experiences are universally applicable.
- jacobolus 8y agoI thought the writeup was about emacs org-mode. Who is planning to use that in a context where the text editor can’t handle basic features from 40+ years ago?
- zapzupnz 8y agoThe write up very specifically mentions it is about org-mode as a general purpose markup language. The very first line after the disclaimer even reads "Please do note that this is not about Emacs".
- etu 8y ago#+BEGIN_SRC sh #!/bin/sh echo "foobar" #+END_SRC That also works in org-mode, and then you get syntax highlighting for the language etc. It can even open that block to edit in a separate buffer with the right major mode loaded for that language.
- xemdetia 8y agoThe command is org-edit-special bound to C-c ' (by default I think). I use this to dump example blocks which I often use to catch terminal output as well as source code editing. Having structured outputs from test/investigation/exploring that you can rearrange and export to use as documentation for the next time/training costs so little time that I get upset when I can't do it.