Org writer: don't indent contents of code blocks.

We previously indented them by two spaces, following a
common convention.  Since the convention is fading, and
the indentation is inconvenient for copy/paste, we are
discontinuing this practice.

Closes #5440.
This commit is contained in:
John MacFarlane 2021-09-17 09:41:34 -07:00
parent 1487ee01fd
commit 57d93cca56
3 changed files with 25 additions and 25 deletions

View file

@ -154,7 +154,7 @@ blockToOrg (CodeBlock (_,classes,kvs) str) = do
let (beg, end) = case at of
[] -> ("#+begin_example" <> numberlines, "#+end_example")
(x:_) -> ("#+begin_src " <> x <> numberlines, "#+end_src")
return $ literal beg $$ nest 2 (literal str) $$ text end $$ blankline
return $ literal beg $$ literal str $$ text end $$ blankline
blockToOrg (BlockQuote blocks) = do
contents <- blockListToOrg blocks
return $ blankline $$ "#+begin_quote" $$

View file

@ -7,8 +7,8 @@
unsafePerformIO main
^D
#+begin_src haskell -n 42
main = putStrLn "Hello World!"
unsafePerformIO main
main = putStrLn "Hello World!"
unsafePerformIO main
#+end_src
```
@ -32,10 +32,10 @@
,CodeBlock ("",["commonlisp","numberLines","continuedSourceBlock"],[("org-language","lisp"),("startFrom","10")]) "(+ 2 2)\n"]
^D
#+begin_src lisp -n 20
(+ 1 1)
(+ 1 1)
#+end_src
#+begin_src lisp +n 10
(+ 2 2)
(+ 2 2)
#+end_src
```

View file

@ -81,9 +81,9 @@ E-mail style:
Code in a block quote:
#+begin_example
sub status {
print "working";
}
sub status {
print "working";
}
#+end_example
A list:
@ -115,21 +115,21 @@ And a following paragraph.
Code:
#+begin_example
---- (should be four hyphens)
---- (should be four hyphens)
sub status {
print "working";
}
sub status {
print "working";
}
this code block is indented by one tab
this code block is indented by one tab
#+end_example
And:
#+begin_example
this code block is indented by two tabs
this code block is indented by two tabs
These should not be escaped: \$ \\ \> \[ \{
These should not be escaped: \$ \\ \> \[ \{
#+end_example
--------------
@ -348,7 +348,7 @@ Multiple blocks with italics:
- /orange/ :: orange fruit
#+begin_example
{ orange code block }
{ orange code block }
#+end_example
#+begin_quote
@ -446,15 +446,15 @@ foo
This should be a code block, though:
#+begin_example
<div>
foo
</div>
<div>
foo
</div>
#+end_example
As should this:
#+begin_example
<div>foo</div>
<div>foo</div>
#+end_example
Now, nested:
@ -485,7 +485,7 @@ Multiline:
Code block:
#+begin_example
<!-- Comment -->
<!-- Comment -->
#+end_example
Just plain comment, with trailing spaces on the line:
@ -497,7 +497,7 @@ Just plain comment, with trailing spaces on the line:
Code:
#+begin_example
<hr />
<hr />
#+end_example
Hr's:
@ -728,7 +728,7 @@ Indented [[/url][thrice]].
This should [not][] be a link.
#+begin_example
[not]: /url
[not]: /url
#+end_example
Foo [[/url/][bar]].
@ -767,7 +767,7 @@ An e-mail address: [[mailto:nobody@nowhere.net][nobody@nowhere.net]]
Auto-links should not occur here: =<http://example.com/>=
#+begin_example
or here: <http://example.com/>
or here: <http://example.com/>
#+end_example
--------------
@ -810,7 +810,7 @@ This paragraph should not be part of the note, as it is not indented.
(as with list items).
#+begin_example
{ <code> }
{ <code> }
#+end_example
If you want, you can indent every line, but you can also be lazy and