How to post formatted Lisp code with the new Fancy Pants Reddit editor
Hi,
I've seen a few people recently struggling posting formatted code.
Let's say you have Lisp code in your Lisp editor and you want to use it in a Reddit post or comment:
https://i.redd.it/x7n9htwezb321.png <- code screenshot
Markdown mode
- Inline code with a pair of backticks: `this is code`
- code blocks: each line of code needs to have four spaces at the beginning.
Fancy Pants Editor
So, don't paste your Lisp source code as picture and don't paste it using the inline code button.
Use the code block button (!!!): and paste code into the grey field. see the picture here for the button bar:
The Fancy Pants Reddit editor buttons <- screenshot
It will then look like this:
#+genera
(defun dw-picture (&optional (fn 'sqrt))
(declare (symbol fn))
(check-type fn symbol)
(terpri)
(format t "Plot of function ~S~%" fn)
(terpri)
(let ((scaling (* 2 (/ (* *text-width-in-picas* 12) (* *units-to-show* 2))))
(*graphics-backend* :dw))
(graphics:with-room-for-graphics (*standard-output* 1000)
(graphics:with-graphics-translation (*standard-output* 500 500)
(graphics:with-graphics-scale (*standard-output* scaling (- scaling))
(moby-grid fn *standard-output*)))))
(terpri))
Make sure that the code is formatted like in your Lisp editor. Also make sure that the code was properly formatted and indented in your text editor. ;-) I also make sure in my Lisp editor, that I don't use 'tabs' in indentation -> use spaces.
Use the inline code </> button only for code which is inlined in your (text :paragraph) - it's only useful there.
As I moderator, I require that you try to post readable code - this is a question of respect for our readers. If you have any question about posting formatted code, then please feel free to ask and we will try to help.
Keep on posting!
Lispm
Posted Dec 9, 2018, 11:00 PM UTC · edited