git.iko.soy/typeable/pandoc
on master help sign in
Textile writer: Support header attributes.
commit0c9bb4040363d990cb1f59bcc5b39ff78508cad9 authorJohn MacFarlane <fiddlosopher@gmail.com> dateThu 28 Feb 2013, 18:47 (14 years ago) parentd5c2ace
1 file changed+9−3
src/Text/Pandoc/Writers/Textile.hs+9−3
src/Text/Pandoc/Writers/Textile.hs+9−3
@@ -122,10 +122,16 @@ blockToTextile _ (RawBlock f str) =
122122
123123blockToTextile _ HorizontalRule = return "<hr />\n"
124124
125−blockToTextile opts (Header level (ident,_,_) inlines) = do
125+blockToTextile opts (Header level (ident,classes,keyvals) inlines) = do
126126 contents <- inlineListToTextile opts inlines
127− let attribs = if null ident then "" else "(#" ++ ident ++ ")"
128− let prefix = 'h' : show level ++ attribs ++ ". "
127+ let identAttr = if null ident then "" else ('#':ident)
128+ let classAttr = unwords classes
129+ let attribs = if null identAttr && null classes
130+ then ""
131+ else "(" ++ unwords classes ++ identAttr ++ ")"
132+ let lang = maybe "" (\x -> "[" ++ x ++ "]") $ lookup "lang" keyvals
133+ let styles = maybe "" (\x -> "{" ++ x ++ "}") $ lookup "style" keyvals
134+ let prefix = 'h' : show level ++ attribs ++ styles ++ lang ++ ". "
129135 return $ prefix ++ contents ++ "\n"
130136
131137blockToTextile _ (CodeBlock (_,classes,_) str) | any (all isSpace) (lines str) =