git.iko.soy/typeable/pandoc
on master help sign in
Org writer: always indent src blocks content by 2 spaces

Emacs always uses two spaces when indenting the content of src blocks, e.g., when exiting a `C-c '` edit-buffer. Pandoc used to indent contents by the space-equivalent of one tab, but now always uses two spaces, too. Closes: #5440

commitda9638e6a372d2707cf10d459b8444292ab9de27 authorAlbert Krewinkel <albert@zeitkraut.de> dateSun 12 May 2019, 14:19 (7 years ago) parent5c7ad59
3 files changed+27−29
src/Text/Pandoc/Writers/Org.hs+1−3 test/command/5178.md+6−6 test/writer.org+20−20
src/Text/Pandoc/Writers/Org.hs+1−3
@@ -169,8 +169,6 @@ blockToOrg (Header level attr inlines) = do
169169 else cr <> nest (level + 1) (propertiesDrawer attr)
170170 return $ headerStr <> " " <> contents <> drawerStr <> blankline
171171blockToOrg (CodeBlock (_,classes,kvs) str) = do
172− opts <- gets stOptions
173− let tabstop = writerTabStop opts
174172 let startnum = maybe "" (\x -> ' ' : trimr x) $ lookup "startFrom" kvs
175173 let numberlines = if "numberLines" `elem` classes
176174 then if "continuedSourceBlock" `elem` classes
@@ -181,7 +179,7 @@ blockToOrg (CodeBlock (_,classes,kvs) str) = do
181179 let (beg, end) = case at of
182180 [] -> ("#+BEGIN_EXAMPLE" ++ numberlines, "#+END_EXAMPLE")
183181 (x:_) -> ("#+BEGIN_SRC " ++ x ++ numberlines, "#+END_SRC")
184− return $ text beg $$ nest tabstop (text str) $$ text end $$ blankline
182+ return $ text beg $$ nest 2 (text str) $$ text end $$ blankline
185183blockToOrg (BlockQuote blocks) = do
186184 contents <- blockListToOrg blocks
187185 return $ blankline $$ "#+BEGIN_QUOTE" $$
test/command/5178.md+6−6
@@ -7,19 +7,19 @@
77 unsafePerformIO main
88^D
99#+BEGIN_SRC haskell -n 42
10− main = putStrLn "Hello World!"
11− unsafePerformIO main
10+ main = putStrLn "Hello World!"
11+ unsafePerformIO main
1212#+END_SRC
1313```
1414
1515```
1616% pandoc -f org -t native
1717#+BEGIN_SRC lisp -n 20
18− (+ 1 1)
18+ (+ 1 1)
1919#+END_SRC
2020
2121#+BEGIN_SRC lisp +n 10
22− (+ 2 2)
22+ (+ 2 2)
2323#+END_SRC
2424^D
2525[CodeBlock ("",["commonlisp","numberLines"],[("org-language","lisp"),("startFrom","20")]) "(+ 1 1)\n"
@@ -32,10 +32,10 @@
3232,CodeBlock ("",["commonlisp","numberLines","continuedSourceBlock"],[("org-language","lisp"),("startFrom","10")]) "(+ 2 2)\n"]
3333^D
3434#+BEGIN_SRC lisp -n 20
35− (+ 1 1)
35+ (+ 1 1)
3636#+END_SRC
3737
3838#+BEGIN_SRC lisp +n 10
39− (+ 2 2)
39+ (+ 2 2)
4040#+END_SRC
4141```
test/writer.org+20−20
@@ -92,9 +92,9 @@ E-mail style:
9292 Code in a block quote:
9393
9494 #+BEGIN_EXAMPLE
95− sub status {
96− print "working";
97− }
95+ sub status {
96+ print "working";
97+ }
9898 #+END_EXAMPLE
9999
100100 A list:
@@ -127,21 +127,21 @@ And a following paragraph.
127127Code:
128128
129129#+BEGIN_EXAMPLE
130− ---- (should be four hyphens)
130+ ---- (should be four hyphens)
131131
132− sub status {
133− print "working";
134− }
132+ sub status {
133+ print "working";
134+ }
135135
136− this code block is indented by one tab
136+ this code block is indented by one tab
137137#+END_EXAMPLE
138138
139139And:
140140
141141#+BEGIN_EXAMPLE
142− this code block is indented by two tabs
142+ this code block is indented by two tabs
143143
144− These should not be escaped: \$ \\ \> \[ \{
144+ These should not be escaped: \$ \\ \> \[ \{
145145#+END_EXAMPLE
146146
147147--------------
@@ -364,7 +364,7 @@ Multiple blocks with italics:
364364- /orange/ :: orange fruit
365365
366366 #+BEGIN_EXAMPLE
367− { orange code block }
367+ { orange code block }
368368 #+END_EXAMPLE
369369
370370 #+BEGIN_QUOTE
@@ -463,15 +463,15 @@ foo
463463This should be a code block, though:
464464
465465#+BEGIN_EXAMPLE
466− <div>
467− foo
468− </div>
466+ <div>
467+ foo
468+ </div>
469469#+END_EXAMPLE
470470
471471As should this:
472472
473473#+BEGIN_EXAMPLE
474− <div>foo</div>
474+ <div>foo</div>
475475#+END_EXAMPLE
476476
477477Now, nested:
@@ -502,7 +502,7 @@ Multiline:
502502Code block:
503503
504504#+BEGIN_EXAMPLE
505− <!-- Comment -->
505+ <!-- Comment -->
506506#+END_EXAMPLE
507507
508508Just plain comment, with trailing spaces on the line:
@@ -514,7 +514,7 @@ Just plain comment, with trailing spaces on the line:
514514Code:
515515
516516#+BEGIN_EXAMPLE
517− <hr />
517+ <hr />
518518#+END_EXAMPLE
519519
520520Hr's:
@@ -751,7 +751,7 @@ Indented [[/url][thrice]].
751751This should [not][] be a link.
752752
753753#+BEGIN_EXAMPLE
754− [not]: /url
754+ [not]: /url
755755#+END_EXAMPLE
756756
757757Foo [[/url/][bar]].
@@ -792,7 +792,7 @@ An e-mail address: [[mailto:nobody@nowhere.net][nobody@nowhere.net]]
792792Auto-links should not occur here: =<http://example.com/>=
793793
794794#+BEGIN_EXAMPLE
795− or here: <http://example.com/>
795+ or here: <http://example.com/>
796796#+END_EXAMPLE
797797
798798--------------
@@ -837,7 +837,7 @@ This paragraph should not be part of the note, as it is not indented.
837837 (as with list items).
838838
839839 #+BEGIN_EXAMPLE
840− { <code> }
840+ { <code> }
841841 #+END_EXAMPLE
842842
843843 If you want, you can indent every line, but you can also be lazy and