git.iko.soy/typeable/pandoc
on master help sign in
Org reader: allow short hand for single-line raw blocks

Single-line raw blocks can be given via `#+FORMAT: raw line`, where `FORMAT` must be one of `latex`, `beamer`, `html`, or `texinfo`. Closes: #3366

commit5729f1f2eaf1665be3fcbf92917503bdd15d1995 authorAlbert Krewinkel <albert@zeitkraut.de> dateThu 19 Jan 2017, 20:27 (10 years ago) parentaad7c3b
3 files changed+29−8
src/Text/Pandoc/Readers/Org/Blocks.hs+12−4 src/Text/Pandoc/Readers/Org/Meta.hs+5−4 tests/Tests/Readers/Org.hs+12
src/Text/Pandoc/Readers/Org/Blocks.hs+12−4
@@ -2,7 +2,7 @@
22{-# LANGUAGE RecordWildCards #-}
33{-# LANGUAGE ViewPatterns #-}
44{-
5−Copyright (C) 2014-2016 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
5+Copyright (C) 2014-2017 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
66
77This program is free software; you can redistribute it and/or modify
88it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2121
2222{- |
2323 Module : Text.Pandoc.Readers.Org.Options
24− Copyright : Copyright (C) 2014-2016 Albert Krewinkel
24+ Copyright : Copyright (C) 2014-2017 Albert Krewinkel
2525 License : GNU GPL, version 2 or above
2626
2727 Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
@@ -35,7 +35,7 @@ module Text.Pandoc.Readers.Org.Blocks
3535
3636import Text.Pandoc.Readers.Org.BlockStarts
3737import Text.Pandoc.Readers.Org.Inlines
38−import Text.Pandoc.Readers.Org.Meta ( metaExport, metaLine )
38+import Text.Pandoc.Readers.Org.Meta ( metaExport, metaKey, metaLine )
3939import Text.Pandoc.Readers.Org.ParserState
4040import Text.Pandoc.Readers.Org.Parsing
4141import Text.Pandoc.Readers.Org.Shared
@@ -679,7 +679,15 @@ exampleCode = B.codeBlockWith ("", ["example"], [])
679679--
680680
681681specialLine :: OrgParser (F Blocks)
682−specialLine = fmap return . try $ metaLine <|> commentLine
682+specialLine = fmap return . try $ rawExportLine <|> metaLine <|> commentLine
683+
684+rawExportLine :: OrgParser Blocks
685+rawExportLine = try $ do
686+ metaLineStart
687+ key <- metaKey
688+ if key `elem` ["latex", "html", "texinfo", "beamer"]
689+ then B.rawBlock key <$> anyLine
690+ else mzero
683691
684692commentLine :: OrgParser Blocks
685693commentLine = commentLineStart *> anyLine *> pure mempty
src/Text/Pandoc/Readers/Org/Meta.hs+5−4
@@ -1,7 +1,7 @@
11{-# LANGUAGE FlexibleContexts #-}
22{-# LANGUAGE TupleSections #-}
33{-
4−Copyright (C) 2014-2016 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
4+Copyright (C) 2014-2017 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
55
66This program is free software; you can redistribute it and/or modify
77it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2020
2121{- |
2222 Module : Text.Pandoc.Readers.Org.Meta
23− Copyright : Copyright (C) 2014-2016 Albert Krewinkel
23+ Copyright : Copyright (C) 2014-2017 Albert Krewinkel
2424 License : GNU GPL, version 2 or above
2525
2626 Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
@@ -28,8 +28,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2828Parsers for Org-mode meta declarations.
2929-}
3030module Text.Pandoc.Readers.Org.Meta
31− ( metaLine
32− , metaExport
31+ ( metaExport
32+ , metaKey
33+ , metaLine
3334 ) where
3435
3536import Text.Pandoc.Readers.Org.BlockStarts
tests/Tests/Readers/Org.hs+12
@@ -1605,6 +1605,18 @@ tests =
16051605 ] =?>
16061606 rawBlock "latex" "The category $\\cat{Set}$ is adhesive.\n"
16071607
1608+ , "Raw LaTeX line" =:
1609+ "#+LATEX: \\let\\foo\\bar" =?>
1610+ rawBlock "latex" "\\let\\foo\\bar"
1611+
1612+ , "Raw Beamer line" =:
1613+ "#+beamer: \\pause" =?>
1614+ rawBlock "beamer" "\\pause"
1615+
1616+ , "Raw HTML line" =:
1617+ "#+HTML: <aside>not important</aside>" =?>
1618+ rawBlock "html" "<aside>not important</aside>"
1619+
16081620 , "Export block HTML" =:
16091621 unlines [ "#+BEGIN_export html"
16101622 , "<samp>Hello, World!</samp>"