diff options
| author | Albert Krewinkel <[email protected]> | 2025-08-03 14:59:35 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-08-06 12:54:12 -0700 |
| commit | 7639e800c5af85e5ded862a6e218d54489d17bfc (patch) | |
| tree | cd6274889de4baae6b47abb67926c0b1bf19d592 | |
| parent | 90afbea1db63dd0b84a17fdd5702dc43107725d8 (diff) | |
Org template: add `#+options` lines if necessary
The default template now adds `#+options` lines if non-default settings
are used for the `smart_quotes` and `special_strings` extensions.
| -rw-r--r-- | data/templates/default.org | 6 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/Org.hs | 11 | ||||
| -rw-r--r-- | test/command/10919.md | 21 |
3 files changed, 38 insertions, 0 deletions
diff --git a/data/templates/default.org b/data/templates/default.org index ee073c6e5..38b6e6fcc 100644 --- a/data/templates/default.org +++ b/data/templates/default.org @@ -9,6 +9,12 @@ $if(date)$ #+date: $date$ $endif$ +$if(options/pairs)$ +$for(options/pairs)$ +#+options: ${it.key}:${it.value} +$endfor$ + +$endif$ $for(header-includes)$ $header-includes$ diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index 6c05467cb..f1a516a66 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -71,6 +71,17 @@ pandocToOrg (Pandoc meta blocks) = do let main = body $+$ notes let context = defField "body" main . defField "math" hasMath + . defField "options" + (M.fromList + ((if isEnabled Ext_smart_quotes opts + then (("'", "t"):) + else id) . + (if not (isEnabled Ext_special_strings opts) + then (("-", "nil"):) + else id) + $ ([] :: [(Text, Text)]))) + . defField "option-special-strings" + (isEnabled Ext_special_strings opts) $ metadata return $ render colwidth $ case writerTemplate opts of diff --git a/test/command/10919.md b/test/command/10919.md new file mode 100644 index 000000000..6f03c8371 --- /dev/null +++ b/test/command/10919.md @@ -0,0 +1,21 @@ +# Org output with smart quotes turned on + +``` +% pandoc -t org+smart_quotes -s +"It's nice" she said. +^D +#+options: ':t + +"It's nice" she said. +``` + +Same test, but with special strings turned off. +``` +% pandoc -t org+smart_quotes-special_strings -s +"It's nice" she said. +^D +#+options: ':t +#+options: -:nil + +"It’s nice" she said. +``` |
