@@ -186,7 +186,7 @@ orgBlock = try $ do
186186 "html" -> rawBlockLines (return . B.rawBlock (lowercase blkType))
187187 "latex" -> rawBlockLines (return . B.rawBlock (lowercase blkType))
188188 "ascii" -> rawBlockLines (return . B.rawBlock (lowercase blkType))
189− "example" -> rawBlockLines (return . exampleCode)
189+ "example" -> exampleBlock blockAttrs
190190 "quote" -> parseBlockLines (fmap B.blockQuote)
191191 "verse" -> verseBlock
192192 "src" -> codeBlock blockAttrs
@@ -200,6 +200,16 @@ orgBlock = try $ do
200200 lowercase :: String -> String
201201 lowercase = map toLower
202202
203+exampleBlock :: PandocMonad m => BlockAttributes -> String -> OrgParser m (F Blocks)
204+exampleBlock blockAttrs _label = do
205+ skipSpaces
206+ (classes, kv) <- switchesAsAttributes
207+ newline
208+ content <- rawBlockContent "example"
209+ let id' = fromMaybe mempty $ blockAttrName blockAttrs
210+ let codeBlck = B.codeBlockWith (id', "example":classes, kv) content
211+ return . return $ codeBlck
212+
203213rawBlockLines :: Monad m => (String -> F Blocks) -> String -> OrgParser m (F Blocks)
204214rawBlockLines f blockType = ignHeaders *> (f <$> rawBlockContent blockType)
205215
@@ -216,11 +226,13 @@ rawBlockContent :: Monad m => String -> OrgParser m String
216226rawBlockContent blockType = try $ do
217227 blkLines <- manyTill rawLine blockEnder
218228 tabLen <- getOption readerTabStop
219− return
220− . unlines
221− . stripIndent
222− . map (tabsToSpaces tabLen . commaEscaped)
223− $ blkLines
229+ trimP <- orgStateTrimLeadBlkIndent <$> getState
230+ let stripIndent strs = if trimP then map (drop (shortestIndent strs)) strs else strs
231+ (unlines
232+ . stripIndent
233+ . map (tabsToSpaces tabLen . commaEscaped)
234+ $ blkLines)
235+ <$ updateState (\s -> s { orgStateTrimLeadBlkIndent = True })
224236 where
225237 rawLine :: Monad m => OrgParser m String
226238 rawLine = try $ ("" <$ blankline) <|> anyLine
@@ -228,9 +240,6 @@ rawBlockContent blockType = try $ do
228240 blockEnder :: Monad m => OrgParser m ()
229241 blockEnder = try $ skipSpaces <* stringAnyCase ("#+end_" <> blockType)
230242
231− stripIndent :: [String] -> [String]
232− stripIndent strs = map (drop (shortestIndent strs)) strs
233−
234243 shortestIndent :: [String] -> Int
235244 shortestIndent = foldr (min . length . takeWhile isSpace) maxBound
236245 . filter (not . null)
@@ -357,12 +366,19 @@ switchPolarity = (SwitchMinus <$ char '-') <|> (SwitchPlus <$ char '+')
357366
358367-- | Parses a source block switch option.
359368switch :: Monad m => OrgParser m (Char, Maybe String, SwitchPolarity)
360−switch = try $ lineNumberSwitch <|> labelSwitch <|> simpleSwitch
369+switch = try $ lineNumberSwitch <|> labelSwitch
370+ <|> whitespaceSwitch <|> simpleSwitch
361371 where
362372 simpleSwitch = (\pol c -> (c, Nothing, pol)) <$> switchPolarity <*> letter
363373 labelSwitch = genericSwitch 'l' $
364374 char '"' *> many1Till nonspaceChar (char '"')
365375
376+whitespaceSwitch :: Monad m => OrgParser m (Char, Maybe String, SwitchPolarity)
377+whitespaceSwitch = do
378+ string "-i"
379+ updateState $ \s -> s { orgStateTrimLeadBlkIndent = False }
380+ return ('i', Nothing, SwitchMinus)
381+
366382-- | Generic source block switch-option parser.
367383genericSwitch :: Monad m
368384 => Char
@@ -821,11 +837,22 @@ listItem parseIndentedMarker = try . withContext ListItemState $ do
821837
822838-- continuation of a list item - indented and separated by blankline or endline.
823839-- Note: nested lists are parsed as continuations.
824−listContinuation :: Monad m => Int
825− -> OrgParser m String
840+listContinuation :: PandocMonad m => Int -> OrgParser m String
826841listContinuation markerLength = try $ do
827842 notFollowedBy' blankline
828− mappend <$> (concat <$> many1 listLine)
843+ mappend <$> (concat <$> many1 (listContinuation' markerLength))
829844 <*> many blankline
830845 where
831− listLine = try $ indentWith markerLength *> anyLineNewline
846+ listContinuation' indentation =
847+ blockLines indentation <|> listLine indentation
848+ listLine indentation = try $ indentWith indentation *> anyLineNewline
849+ -- The block attributes and start must be appropriately indented,
850+ -- but the contents, and end do not.
851+ blockLines indentation =
852+ try $ lookAhead (indentWith indentation
853+ >> blockAttributes
854+ >>= (\blockAttrs ->
855+ case attrFromBlockAttributes blockAttrs of
856+ ("", [], []) -> count 1 anyChar
857+ _ -> indentWith indentation))
858+ >> (snd <$> withRaw orgBlock)