git.iko.soy/typeable/pandoc
on master help sign in
Org writer: always indent src blocks content by 2 spaces
da9638eAlbert Krewinkel
src/Text/Pandoc/Writers/Org.hs+1−3
@@ -169,8 +169,6 @@ blockToOrg (Header level attr inlines) = do
169 else cr <> nest (level + 1) (propertiesDrawer attr)
169 else cr <> nest (level + 1) (propertiesDrawer attr)
170 return $ headerStr <> " " <> contents <> drawerStr <> blankline
170 return $ headerStr <> " " <> contents <> drawerStr <> blankline
171blockToOrg (CodeBlock (_,classes,kvs) str) = do
171blockToOrg (CodeBlock (_,classes,kvs) str) = do
172− opts <- gets stOptions
173− let tabstop = writerTabStop opts
174 let startnum = maybe "" (\x -> ' ' : trimr x) $ lookup "startFrom" kvs
172 let startnum = maybe "" (\x -> ' ' : trimr x) $ lookup "startFrom" kvs
175 let numberlines = if "numberLines" `elem` classes
173 let numberlines = if "numberLines" `elem` classes
176 then if "continuedSourceBlock" `elem` classes
174 then if "continuedSourceBlock" `elem` classes
@@ -181,7 +179,7 @@ blockToOrg (CodeBlock (_,classes,kvs) str) = do
181 let (beg, end) = case at of
179 let (beg, end) = case at of
182 [] -> ("#+BEGIN_EXAMPLE" ++ numberlines, "#+END_EXAMPLE")
180 [] -> ("#+BEGIN_EXAMPLE" ++ numberlines, "#+END_EXAMPLE")
183 (x:_) -> ("#+BEGIN_SRC " ++ x ++ numberlines, "#+END_SRC")
181 (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
185blockToOrg (BlockQuote blocks) = do
183blockToOrg (BlockQuote blocks) = do
186 contents <- blockListToOrg blocks
184 contents <- blockListToOrg blocks
187 return $ blankline $$ "#+BEGIN_QUOTE" $$
185 return $ blankline $$ "#+BEGIN_QUOTE" $$
test/command/5178.md+6−6
@@ -7,19 +7,19 @@
7 unsafePerformIO main
7 unsafePerformIO main
8^D
8^D
9#+BEGIN_SRC haskell -n 42
9#+BEGIN_SRC haskell -n 42
10− main = putStrLn "Hello World!"
10+ main = putStrLn "Hello World!"
11− unsafePerformIO main
11+ unsafePerformIO main
12#+END_SRC
12#+END_SRC
13```
13```
14
14
15```
15```
16% pandoc -f org -t native
16% pandoc -f org -t native
17#+BEGIN_SRC lisp -n 20
17#+BEGIN_SRC lisp -n 20
18− (+ 1 1)
18+ (+ 1 1)
19#+END_SRC
19#+END_SRC
20
20
21#+BEGIN_SRC lisp +n 10
21#+BEGIN_SRC lisp +n 10
22− (+ 2 2)
22+ (+ 2 2)
23#+END_SRC
23#+END_SRC
24^D
24^D
25[CodeBlock ("",["commonlisp","numberLines"],[("org-language","lisp"),("startFrom","20")]) "(+ 1 1)\n"
25[CodeBlock ("",["commonlisp","numberLines"],[("org-language","lisp"),("startFrom","20")]) "(+ 1 1)\n"
@@ -32,10 +32,10 @@
32,CodeBlock ("",["commonlisp","numberLines","continuedSourceBlock"],[("org-language","lisp"),("startFrom","10")]) "(+ 2 2)\n"]
32,CodeBlock ("",["commonlisp","numberLines","continuedSourceBlock"],[("org-language","lisp"),("startFrom","10")]) "(+ 2 2)\n"]
33^D
33^D
34#+BEGIN_SRC lisp -n 20
34#+BEGIN_SRC lisp -n 20
35− (+ 1 1)
35+ (+ 1 1)
36#+END_SRC
36#+END_SRC
37
37
38#+BEGIN_SRC lisp +n 10
38#+BEGIN_SRC lisp +n 10
39− (+ 2 2)
39+ (+ 2 2)
40#+END_SRC
40#+END_SRC
41```
41```
test/writer.org+20−20
@@ -92,9 +92,9 @@ E-mail style:
92 Code in a block quote:
92 Code in a block quote:
93
93
94 #+BEGIN_EXAMPLE
94 #+BEGIN_EXAMPLE
95− sub status {
95+ sub status {
96− print "working";
96+ print "working";
97− }
97+ }
98 #+END_EXAMPLE
98 #+END_EXAMPLE
99
99
100 A list:
100 A list:
@@ -127,21 +127,21 @@ And a following paragraph.
127Code:
127Code:
128
128
129#+BEGIN_EXAMPLE
129#+BEGIN_EXAMPLE
130− ---- (should be four hyphens)
130+ ---- (should be four hyphens)
131
131
132− sub status {
132+ sub status {
133− print "working";
133+ print "working";
134− }
134+ }
135
135
136− this code block is indented by one tab
136+ this code block is indented by one tab
137#+END_EXAMPLE
137#+END_EXAMPLE
138
138
139And:
139And:
140
140
141#+BEGIN_EXAMPLE
141#+BEGIN_EXAMPLE
142− this code block is indented by two tabs
142+ this code block is indented by two tabs
143
143
144− These should not be escaped: \$ \\ \> \[ \{
144+ These should not be escaped: \$ \\ \> \[ \{
145#+END_EXAMPLE
145#+END_EXAMPLE
146
146
147--------------
147--------------
@@ -364,7 +364,7 @@ Multiple blocks with italics:
364- /orange/ :: orange fruit
364- /orange/ :: orange fruit
365
365
366 #+BEGIN_EXAMPLE
366 #+BEGIN_EXAMPLE
367− { orange code block }
367+ { orange code block }
368 #+END_EXAMPLE
368 #+END_EXAMPLE
369
369
370 #+BEGIN_QUOTE
370 #+BEGIN_QUOTE
@@ -463,15 +463,15 @@ foo
463This should be a code block, though:
463This should be a code block, though:
464
464
465#+BEGIN_EXAMPLE
465#+BEGIN_EXAMPLE
466− <div>
466+ <div>
467− foo
467+ foo
468− </div>
468+ </div>
469#+END_EXAMPLE
469#+END_EXAMPLE
470
470
471As should this:
471As should this:
472
472
473#+BEGIN_EXAMPLE
473#+BEGIN_EXAMPLE
474− <div>foo</div>
474+ <div>foo</div>
475#+END_EXAMPLE
475#+END_EXAMPLE
476
476
477Now, nested:
477Now, nested:
@@ -502,7 +502,7 @@ Multiline:
502Code block:
502Code block:
503
503
504#+BEGIN_EXAMPLE
504#+BEGIN_EXAMPLE
505− <!-- Comment -->
505+ <!-- Comment -->
506#+END_EXAMPLE
506#+END_EXAMPLE
507
507
508Just plain comment, with trailing spaces on the line:
508Just plain comment, with trailing spaces on the line:
@@ -514,7 +514,7 @@ Just plain comment, with trailing spaces on the line:
514Code:
514Code:
515
515
516#+BEGIN_EXAMPLE
516#+BEGIN_EXAMPLE
517− <hr />
517+ <hr />
518#+END_EXAMPLE
518#+END_EXAMPLE
519
519
520Hr's:
520Hr's:
@@ -751,7 +751,7 @@ Indented [[/url][thrice]].
751This should [not][] be a link.
751This should [not][] be a link.
752
752
753#+BEGIN_EXAMPLE
753#+BEGIN_EXAMPLE
754− [not]: /url
754+ [not]: /url
755#+END_EXAMPLE
755#+END_EXAMPLE
756
756
757Foo [[/url/][bar]].
757Foo [[/url/][bar]].
@@ -792,7 +792,7 @@ An e-mail address: [[mailto:nobody@nowhere.net][nobody@nowhere.net]]
792Auto-links should not occur here: =<http://example.com/>=
792Auto-links should not occur here: =<http://example.com/>=
793
793
794#+BEGIN_EXAMPLE
794#+BEGIN_EXAMPLE
795− or here: <http://example.com/>
795+ or here: <http://example.com/>
796#+END_EXAMPLE
796#+END_EXAMPLE
797
797
798--------------
798--------------
@@ -837,7 +837,7 @@ This paragraph should not be part of the note, as it is not indented.
837 (as with list items).
837 (as with list items).
838
838
839 #+BEGIN_EXAMPLE
839 #+BEGIN_EXAMPLE
840− { <code> }
840+ { <code> }
841 #+END_EXAMPLE
841 #+END_EXAMPLE
842
842
843 If you want, you can indent every line, but you can also be lazy and
843 If you want, you can indent every line, but you can also be lazy and