From cf2502de8fb3d208a6b062d38a09cec0f9faba5a Mon Sep 17 00:00:00 2001
From: Albert Krewinkel <albert@zeitkraut.de>
Date: Mon, 13 Jun 2016 23:13:05 +0200
Subject: [PATCH] Org writer: support arbitrary raw inlines

Org mode allows arbitrary raw inlines ("export snippets" in Emacs
parlance) to be included as `@@format:raw foreign format text@@`.

Support for this features is added to the Org writer.
---
 src/Text/Pandoc/Writers/Org.hs | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs
index f87aeca81..79ca37395 100644
--- a/src/Text/Pandoc/Writers/Org.hs
+++ b/src/Text/Pandoc/Writers/Org.hs
@@ -305,9 +305,10 @@ inlineToOrg (Math t str) = do
   return $ if t == InlineMath
               then "$" <> text str <> "$"
               else "$$" <> text str <> "$$"
-inlineToOrg (RawInline f str) | isRawFormat f =
-  return $ text str
-inlineToOrg (RawInline _ _) = return empty
+inlineToOrg (RawInline f@(Format f') str) =
+  return $ if isRawFormat f
+           then text str
+           else "@@" <> text f' <> ":" <> text str <> "@@"
 inlineToOrg (LineBreak) = return (text "\\\\" <> cr)
 inlineToOrg Space = return space
 inlineToOrg SoftBreak = do