Org writer: stop indenting property drawers, quote blocks

This follows the current default org-mode behavior.

Closes: 
This commit is contained in:
Albert Krewinkel 2022-03-11 12:06:24 +01:00
parent a7d94dba43
commit 168529f0a4
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 122 additions and 115 deletions
src/Text/Pandoc/Writers
test

View file

@ -146,7 +146,7 @@ blockToOrg (Header level attr inlines) = do
let headerStr = text $ if level > 999 then " " else replicate level '*' let headerStr = text $ if level > 999 then " " else replicate level '*'
let drawerStr = if attr == nullAttr let drawerStr = if attr == nullAttr
then empty then empty
else cr <> nest (level + 1) (propertiesDrawer attr) else cr <> propertiesDrawer attr
return $ headerStr <> " " <> contents <> drawerStr <> cr return $ headerStr <> " " <> contents <> drawerStr <> cr
blockToOrg (CodeBlock (_,classes,kvs) str) = do blockToOrg (CodeBlock (_,classes,kvs) str) = do
let startnum = maybe "" (\x -> " " <> trimr x) $ lookup "startFrom" kvs let startnum = maybe "" (\x -> " " <> trimr x) $ lookup "startFrom" kvs
@ -163,7 +163,7 @@ blockToOrg (CodeBlock (_,classes,kvs) str) = do
blockToOrg (BlockQuote blocks) = do blockToOrg (BlockQuote blocks) = do
contents <- blockListToOrg blocks contents <- blockListToOrg blocks
return $ blankline $$ "#+begin_quote" $$ return $ blankline $$ "#+begin_quote" $$
nest 2 contents $$ "#+end_quote" $$ blankline contents $$ "#+end_quote" $$ blankline
blockToOrg (Table _ blkCapt specs thead tbody tfoot) = do blockToOrg (Table _ blkCapt specs thead tbody tfoot) = do
let (caption', _, _, headers, rows) = toLegacyTable blkCapt specs thead tbody tfoot let (caption', _, _, headers, rows) = toLegacyTable blkCapt specs thead tbody tfoot
caption'' <- inlineListToOrg caption' caption'' <- inlineListToOrg caption'

View file

@ -9,51 +9,51 @@ markdown test suite.
-------------- --------------
* Headers * Headers
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: headers :CUSTOM_ID: headers
:END: :END:
** Level 2 with an [[/url][embedded link]] ** Level 2 with an [[/url][embedded link]]
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: level-2-with-an-embedded-link :CUSTOM_ID: level-2-with-an-embedded-link
:END: :END:
*** Level 3 with /emphasis/ *** Level 3 with /emphasis/
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: level-3-with-emphasis :CUSTOM_ID: level-3-with-emphasis
:END: :END:
**** Level 4 **** Level 4
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: level-4 :CUSTOM_ID: level-4
:END: :END:
***** Level 5 ***** Level 5
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: level-5 :CUSTOM_ID: level-5
:END: :END:
* Level 1 * Level 1
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: level-1 :CUSTOM_ID: level-1
:END: :END:
** Level 2 with /emphasis/ ** Level 2 with /emphasis/
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: level-2-with-emphasis :CUSTOM_ID: level-2-with-emphasis
:END: :END:
*** Level 3 *** Level 3
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: level-3 :CUSTOM_ID: level-3
:END: :END:
with no blank line with no blank line
** Level 2 ** Level 2
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: level-2 :CUSTOM_ID: level-2
:END: :END:
with no blank line with no blank line
-------------- --------------
* Paragraphs * Paragraphs
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: paragraphs :CUSTOM_ID: paragraphs
:END: :END:
Here's a regular paragraph. Here's a regular paragraph.
In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
@ -68,38 +68,42 @@ here.
-------------- --------------
* Block Quotes * Block Quotes
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: block-quotes :CUSTOM_ID: block-quotes
:END: :END:
E-mail style: E-mail style:
#+begin_quote #+begin_quote
This is a block quote. It is pretty short. This is a block quote. It is pretty short.
#+end_quote #+end_quote
#+begin_quote #+begin_quote
Code in a block quote: Code in a block quote:
#+begin_example #+begin_example
sub status { sub status {
print "working"; print "working";
} }
#+end_example #+end_example
A list: A list:
1. item one 1. item one
2. item two 2. item two
Nested block quotes: Nested block quotes:
#+begin_quote #+begin_quote
nested nested
#+end_quote
#+end_quote
#+begin_quote
nested
#+end_quote
#+begin_quote
nested
#+end_quote
#+end_quote #+end_quote
This should not be a block quote: 2 > 1. This should not be a block quote: 2 > 1.
@ -109,9 +113,9 @@ And a following paragraph.
-------------- --------------
* Code Blocks * Code Blocks
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: code-blocks :CUSTOM_ID: code-blocks
:END: :END:
Code: Code:
#+begin_example #+begin_example
@ -135,13 +139,13 @@ These should not be escaped: \$ \\ \> \[ \{
-------------- --------------
* Lists * Lists
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: lists :CUSTOM_ID: lists
:END: :END:
** Unordered ** Unordered
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: unordered :CUSTOM_ID: unordered
:END: :END:
Asterisks tight: Asterisks tight:
- asterisk 1 - asterisk 1
@ -185,9 +189,9 @@ Minuses loose:
- Minus 3 - Minus 3
** Ordered ** Ordered
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: ordered :CUSTOM_ID: ordered
:END: :END:
Tight: Tight:
1. First 1. First
@ -227,9 +231,9 @@ Multiple paragraphs:
3. Item 3. 3. Item 3.
** Nested ** Nested
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: nested :CUSTOM_ID: nested
:END: :END:
- Tab - Tab
- Tab - Tab
- Tab - Tab
@ -256,9 +260,9 @@ Same thing but with paragraphs:
3. Third 3. Third
** Tabs and spaces ** Tabs and spaces
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: tabs-and-spaces :CUSTOM_ID: tabs-and-spaces
:END: :END:
- this is a list item indented with tabs - this is a list item indented with tabs
- this is a list item indented with spaces - this is a list item indented with spaces
@ -268,9 +272,9 @@ Same thing but with paragraphs:
- this is an example list item indented with spaces - this is an example list item indented with spaces
** Fancy list markers ** Fancy list markers
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: fancy-list-markers :CUSTOM_ID: fancy-list-markers
:END: :END:
2) [@2] begins with 2 2) [@2] begins with 2
3) and now 3 3) and now 3
@ -304,9 +308,9 @@ B. Williams
-------------- --------------
* Definition Lists * Definition Lists
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: definition-lists :CUSTOM_ID: definition-lists
:END: :END:
Tight using spaces: Tight using spaces:
- apple :: red fruit - apple :: red fruit
@ -340,7 +344,8 @@ Multiple blocks with italics:
#+end_example #+end_example
#+begin_quote #+begin_quote
orange block quote orange block quote
#+end_quote #+end_quote
Multiple definitions, tight: Multiple definitions, tight:
@ -372,9 +377,9 @@ Blank line after term, indented marker, alternate markers:
2. sublist 2. sublist
* HTML Blocks * HTML Blocks
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: html-blocks :CUSTOM_ID: html-blocks
:END: :END:
Simple block on one line: Simple block on one line:
foo foo
@ -529,9 +534,9 @@ Hr's:
-------------- --------------
* Inline Markup * Inline Markup
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: inline-markup :CUSTOM_ID: inline-markup
:END: :END:
This is /emphasized/, and so /is this/. This is /emphasized/, and so /is this/.
This is *strong*, and so *is this*. This is *strong*, and so *is this*.
@ -560,9 +565,9 @@ a^b c^d, a~b c~d.
-------------- --------------
* Smart quotes, ellipses, dashes * Smart quotes, ellipses, dashes
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: smart-quotes-ellipses-dashes :CUSTOM_ID: smart-quotes-ellipses-dashes
:END: :END:
"Hello," said the spider. "'Shelob' is my name." "Hello," said the spider. "'Shelob' is my name."
'A', 'B', and 'C' are letters. 'A', 'B', and 'C' are letters.
@ -583,9 +588,9 @@ Ellipses...and...and....
-------------- --------------
* LaTeX * LaTeX
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: latex :CUSTOM_ID: latex
:END: :END:
- \cite[22-23]{smith.1899} - \cite[22-23]{smith.1899}
- \(2+2=4\) - \(2+2=4\)
- \(x \in y\) - \(x \in y\)
@ -615,9 +620,9 @@ Cat & 1 \\ \hline
-------------- --------------
* Special Characters * Special Characters
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: special-characters :CUSTOM_ID: special-characters
:END: :END:
Here is some unicode: Here is some unicode:
- I hat: Î - I hat: Î
@ -671,13 +676,13 @@ Minus: -
-------------- --------------
* Links * Links
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: links :CUSTOM_ID: links
:END: :END:
** Explicit ** Explicit
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: explicit :CUSTOM_ID: explicit
:END: :END:
Just a [[/url/][URL]]. Just a [[/url/][URL]].
[[/url/][URL and title]]. [[/url/][URL and title]].
@ -697,9 +702,9 @@ Just a [[/url/][URL]].
[[][Empty]]. [[][Empty]].
** Reference ** Reference
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: reference :CUSTOM_ID: reference
:END: :END:
Foo [[/url/][bar]]. Foo [[/url/][bar]].
With [[/url/][embedded [brackets]]]. With [[/url/][embedded [brackets]]].
@ -723,9 +728,9 @@ Foo [[/url/][bar]].
Foo [[/url/][biz]]. Foo [[/url/][biz]].
** With ampersands ** With ampersands
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: with-ampersands :CUSTOM_ID: with-ampersands
:END: :END:
Here's a [[http://example.com/?foo=1&bar=2][link with an ampersand in the URL]]. Here's a [[http://example.com/?foo=1&bar=2][link with an ampersand in the URL]].
Here's a link with an amersand in the link text: [[http://att.com/][AT&T]]. Here's a link with an amersand in the link text: [[http://att.com/][AT&T]].
@ -735,9 +740,9 @@ Here's an [[/script?foo=1&bar=2][inline link]].
Here's an [[/script?foo=1&bar=2][inline link in pointy braces]]. Here's an [[/script?foo=1&bar=2][inline link in pointy braces]].
** Autolinks ** Autolinks
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: autolinks :CUSTOM_ID: autolinks
:END: :END:
With an ampersand: [[http://example.com/?foo=1&bar=2]] With an ampersand: [[http://example.com/?foo=1&bar=2]]
- In a list? - In a list?
@ -747,7 +752,8 @@ With an ampersand: [[http://example.com/?foo=1&bar=2]]
An e-mail address: [[mailto:nobody@nowhere.net][nobody@nowhere.net]] An e-mail address: [[mailto:nobody@nowhere.net][nobody@nowhere.net]]
#+begin_quote #+begin_quote
Blockquoted: [[http://example.com/]] Blockquoted: [[http://example.com/]]
#+end_quote #+end_quote
Auto-links should not occur here: =<http://example.com/>= Auto-links should not occur here: =<http://example.com/>=
@ -759,9 +765,9 @@ or here: <http://example.com/>
-------------- --------------
* Images * Images
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: images :CUSTOM_ID: images
:END: :END:
From "Voyage dans la Lune" by Georges Melies (1902): From "Voyage dans la Lune" by Georges Melies (1902):
#+caption: lalune #+caption: lalune
@ -772,15 +778,16 @@ Here is a movie [[file:movie.jpg]] icon.
-------------- --------------
* Footnotes * Footnotes
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: footnotes :CUSTOM_ID: footnotes
:END: :END:
Here is a footnote reference,[fn:1] and another.[fn:2] This should /not/ be a Here is a footnote reference,[fn:1] and another.[fn:2] This should /not/ be a
footnote reference, because it contains a space.[^my note] Here is an inline footnote reference, because it contains a space.[^my note] Here is an inline
note.[fn:3] note.[fn:3]
#+begin_quote #+begin_quote
Notes can go in quotes.[fn:4] Notes can go in quotes.[fn:4]
#+end_quote #+end_quote
1. And in list items.[fn:5] 1. And in list items.[fn:5]