diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-02-28 18:47:49 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-02-28 18:47:49 -0800 |
commit | 0c9bb4040363d990cb1f59bcc5b39ff78508cad9 (patch) | |
tree | 2ed8e6de394043bef8ec969fc27e356f2d18eb9a /src/Text | |
parent | d5c2ace9ae0792050df4b9855a71f5c182da14e9 (diff) | |
download | pandoc-0c9bb4040363d990cb1f59bcc5b39ff78508cad9.tar.gz |
Textile writer: Support header attributes.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/Textile.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs index 0a071c1f8..a3f899159 100644 --- a/src/Text/Pandoc/Writers/Textile.hs +++ b/src/Text/Pandoc/Writers/Textile.hs @@ -122,10 +122,16 @@ blockToTextile _ (RawBlock f str) = blockToTextile _ HorizontalRule = return "<hr />\n" -blockToTextile opts (Header level (ident,_,_) inlines) = do +blockToTextile opts (Header level (ident,classes,keyvals) inlines) = do contents <- inlineListToTextile opts inlines - let attribs = if null ident then "" else "(#" ++ ident ++ ")" - let prefix = 'h' : show level ++ attribs ++ ". " + let identAttr = if null ident then "" else ('#':ident) + let classAttr = unwords classes + let attribs = if null identAttr && null classes + then "" + else "(" ++ unwords classes ++ identAttr ++ ")" + let lang = maybe "" (\x -> "[" ++ x ++ "]") $ lookup "lang" keyvals + let styles = maybe "" (\x -> "{" ++ x ++ "}") $ lookup "style" keyvals + let prefix = 'h' : show level ++ attribs ++ styles ++ lang ++ ". " return $ prefix ++ contents ++ "\n" blockToTextile _ (CodeBlock (_,classes,_) str) | any (all isSpace) (lines str) = |