@@ -294,6 +294,17 @@ data BlockAttributes = BlockAttributes
294294 , blockAttrKeyValues :: [(String, String)]
295295 }
296296
297+-- | Convert BlockAttributes into pandoc Attr
298+attrFromBlockAttributes :: BlockAttributes -> Attr
299+attrFromBlockAttributes (BlockAttributes{..}) =
300+ let
301+ ident = fromMaybe mempty $ lookup "id" blockAttrKeyValues
302+ classes = case lookup "class" blockAttrKeyValues of
303+ Nothing -> []
304+ Just clsStr -> words clsStr
305+ kv = filter ((`notElem` ["id", "class"]) . fst) blockAttrKeyValues
306+ in (ident, classes, kv)
307+
297308stringyMetaAttribute :: (String -> Bool) -> OrgParser (String, String)
298309stringyMetaAttribute attrCheck = try $ do
299310 metaLineStart
@@ -364,23 +375,25 @@ orgBlock = try $ do
364375 blockAttrs <- blockAttributes
365376 blkType <- blockHeaderStart
366377 ($ blkType) $
367− case blkType of
378+ case (map toLower blkType) of
368379 "export" -> exportBlock
369380 "comment" -> rawBlockLines (const mempty)
370− "html" -> rawBlockLines (return . (B.rawBlock blkType))
371− "latex" -> rawBlockLines (return . (B.rawBlock blkType))
372− "ascii" -> rawBlockLines (return . (B.rawBlock blkType))
381+ "html" -> rawBlockLines (return . B.rawBlock (lowercase blkType))
382+ "latex" -> rawBlockLines (return . B.rawBlock (lowercase blkType))
383+ "ascii" -> rawBlockLines (return . B.rawBlock (lowercase blkType))
373384 "example" -> rawBlockLines (return . exampleCode)
374385 "quote" -> parseBlockLines (fmap B.blockQuote)
375386 "verse" -> verseBlock
376387 "src" -> codeBlock blockAttrs
377− _ -> parseBlockLines (fmap $ B.divWith (mempty, [blkType], mempty))
388+ _ -> parseBlockLines $
389+ let (ident, classes, kv) = attrFromBlockAttributes blockAttrs
390+ in fmap $ B.divWith (ident, classes ++ [blkType], kv)
378391 where
379392 blockHeaderStart :: OrgParser String
380− blockHeaderStart = try $ do
381− skipSpaces
382− blockType <- stringAnyCase "#+begin_" *> orgArgWord
383− return (map toLower blockType)
393+ blockHeaderStart = try $ skipSpaces *> stringAnyCase "#+begin_" *> orgArgWord
394+
395+ lowercase :: String -> String
396+ lowercase = map toLower
384397
385398rawBlockLines :: (String -> F Blocks) -> String -> OrgParser (F Blocks)
386399rawBlockLines f blockType = (ignHeaders *> (f <$> rawBlockContent blockType))