git.iko.soy/typeable/pandoc
on master help sign in
Man writer: convert math to unicode when possible.
4aaa199John MacFarlane
src/Text/Pandoc/Writers/Man.hs+3−2
@@ -32,6 +32,7 @@ module Text.Pandoc.Writers.Man ( writeMan) where
32import Text.Pandoc.Definition
32import Text.Pandoc.Definition
33import Text.Pandoc.Templates
33import Text.Pandoc.Templates
34import Text.Pandoc.Shared
34import Text.Pandoc.Shared
35+import Text.Pandoc.Readers.TeXMath
35import Text.Printf ( printf )
36import Text.Printf ( printf )
36import Data.List ( isPrefixOf, intersperse, intercalate )
37import Data.List ( isPrefixOf, intersperse, intercalate )
37import Text.PrettyPrint.HughesPJ hiding ( Str )
38import Text.PrettyPrint.HughesPJ hiding ( Str )
@@ -301,9 +302,9 @@ inlineToMan _ Ellipses = return $ text "\\&..."
301inlineToMan _ (Code str) =
302inlineToMan _ (Code str) =
302 return $ text $ "\\f[B]" ++ escapeCode str ++ "\\f[]"
303 return $ text $ "\\f[B]" ++ escapeCode str ++ "\\f[]"
303inlineToMan _ (Str str) = return $ text $ escapeString str
304inlineToMan _ (Str str) = return $ text $ escapeString str
304−inlineToMan opts (Math InlineMath str) = inlineToMan opts (Code str)
305+inlineToMan opts (Math InlineMath str) = inlineListToMan opts $ readTeXMath str
305inlineToMan opts (Math DisplayMath str) = do
306inlineToMan opts (Math DisplayMath str) = do
306− contents <- inlineToMan opts (Code str)
307+ contents <- inlineListToMan opts $ readTeXMath str
307 return $ text ".RS" $$ contents $$ text ".RE"
308 return $ text ".RS" $$ contents $$ text ".RE"
308inlineToMan _ (TeX _) = return empty
309inlineToMan _ (TeX _) = return empty
309inlineToMan _ (HtmlInline _) = return empty
310inlineToMan _ (HtmlInline _) = return empty
tests/writer.man+7−8
@@ -544,23 +544,22 @@ Ellipses\&...and\&...and\&....
544.SH LaTeX
544.SH LaTeX
545.IP \[bu] 2
545.IP \[bu] 2
546.IP \[bu] 2
546.IP \[bu] 2
547−\f[B]2+2=4\f[]
547+2 + 2 = 4
548.IP \[bu] 2
548.IP \[bu] 2
549−\f[B]x\ \\in\ y\f[]
549+\f[I]x\f[] ∈ \f[I]y\f[]
550.IP \[bu] 2
550.IP \[bu] 2
551−\f[B]\\alpha\ \\wedge\ \\omega\f[]
551+α ∧ ω
552.IP \[bu] 2
552.IP \[bu] 2
553−\f[B]223\f[]
553+223
554.IP \[bu] 2
554.IP \[bu] 2
555−\f[B]p\f[]-Tree
555+\f[I]p\f[]-Tree
556.IP \[bu] 2
556.IP \[bu] 2
557Here's some display math:
557Here's some display math:
558.RS
558.RS
559−\f[B]\\frac{d}{dx}f(x)=\\lim_{h\\to\ 0}\\frac{f(x+h)-f(x)}{h}\f[]
559+$\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}$
560.RE
560.RE
561.IP \[bu] 2
561.IP \[bu] 2
562−Here's one that has a line break in it:
562+Here's one that has a line break in it: α + ω × \f[I]x\f[]^2^.
563−\f[B]\\alpha\ +\ \\omega\ \\times\ x^2\f[].
564.PP
563.PP
565These shouldn't be math:
564These shouldn't be math:
566.IP \[bu] 2
565.IP \[bu] 2