git.iko.soy/typeable/pandoc
on master help sign in
DocBook reader: Support language attribute on inline code.
commit15ef1a1a48c46301f19480a148954c4aca0052a9 authorJohn MacFarlane <fiddlosopher@gmail.com> dateThu 10 May 2012, 10:24 (14 years ago) parent79e8374
1 file changed+23−17
src/Text/Pandoc/Readers/DocBook.hs+23−17
src/Text/Pandoc/Readers/DocBook.hs+23−17
@@ -581,7 +581,7 @@ parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE
581581parseBlock (Text (CData _ s _)) = if all isSpace s
582582 then return mempty
583583 else return $ plain $ trimInlines $ text s
584−parseBlock (CRef _) = return mempty -- TODO need something better here
584+parseBlock (CRef x) = return $ plain $ str $ map toUpper x
585585parseBlock (Elem e) =
586586 case qName (elName e) of
587587 "para" -> para <$> getInlines e
@@ -637,7 +637,7 @@ parseBlock (Elem e) =
637637 Just x@(_:_) | all isDigit x -> read x
638638 _ -> 1
639639 orderedListWith (start,listStyle,DefaultDelim)
640− <$> listitems -- TODO list attributes
640+ <$> listitems
641641 "variablelist" -> definitionList <$> deflistitems
642642 "mediaobject" -> para <$> (getImage e)
643643 "caption" -> return mempty
@@ -786,24 +786,24 @@ parseInline (Elem e) =
786786 return $ if qt == SingleQuote
787787 then singleQuoted contents
788788 else doubleQuoted contents
789− "code" -> return $ code $ strContent e -- TODO attrs
790− "filename" -> return $ codeWith ("",["filename"],[]) $ strContent e -- TODO attrs
791− "literal" -> return $ code $ strContent e -- TODO attrs
792− "prompt" -> return $ codeWith ("",["prompt"],[]) $ strContent e -- TODO attrs
793− "parameter" -> return $ codeWith ("",["parameter"],[]) $ strContent e -- TODO attrs
794− "option" -> return $ codeWith ("",["option"],[]) $ strContent e -- TODO attrs
789+ "code" -> codeWithLang []
790+ "filename" -> codeWithLang ["filename"]
791+ "literal" -> codeWithLang []
792+ "prompt" -> codeWithLang ["prompt"]
793+ "parameter" -> codeWithLang ["parameter"]
794+ "option" -> codeWithLang ["option"]
795795 "optional" -> do x <- getInlines e
796796 return $ str "[" <> x <> str "]"
797− "markup" -> return $ code $ strContent e -- TODO attrs
797+ "markup" -> codeWithLang []
798798 "wordasword" -> emph <$> innerInlines
799− "command" -> return $ codeWith ("",["command"],[]) $ strContent e
800− "varname" -> return $ codeWith ("",["varname"],[]) $ strContent e
801− "function" -> return $ codeWith ("",["function"],[]) $ strContent e
802− "type" -> return $ codeWith ("",["type"],[]) $ strContent e
803− "symbol" -> return $ codeWith ("",["symbol"],[]) $ strContent e
804− "constant" -> return $ codeWith ("",["constant"],[]) $ strContent e
805− "userinput" -> return $ codeWith ("",["userinput"],[]) $ strContent e
806− "varargs" -> return $ str "(…)"
799+ "command" -> codeWithLang ["command"]
800+ "varname" -> codeWithLang ["varname"]
801+ "function" -> codeWithLang ["function"]
802+ "type" -> codeWithLang ["type"]
803+ "symbol" -> codeWithLang ["symbol"]
804+ "constant" -> codeWithLang ["constant"]
805+ "userinput" -> codeWithLang ["userinput"]
806+ "varargs" -> return $ code "(...)"
807807 "email" -> return $ link ("mailto:" ++ strContent e) ""
808808 $ code $ strContent e
809809 "ulink" -> link (attrValue "url" e) "" <$> innerInlines
@@ -820,3 +820,9 @@ parseInline (Elem e) =
820820 _ -> innerInlines
821821 where innerInlines = (trimInlines . mconcat) <$>
822822 (mapM parseInline $ elContent e)
823+ codeWithLang classes = do
824+ let classes' = case attrValue "language" e of
825+ "" -> classes
826+ l -> l:classes
827+ return $ codeWith (attrValue "id" e,classes',[]) $ strContent e
828+