git.iko.soy/typeable/pandoc
on master help sign in
Changed Float to Double in definition of Table element.

(Double is more efficient in GHC.) Truncate width in opendocument output to 2 decimal places. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1418 788f1e2b-df1e-0410-8736-df70ead52e1b

commit2127b7d5135af88dc3f2e7d78136ce24547bca3b authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 6 Sep 2008, 02:51 (18 years ago) parent4dca8f6
9 files changed+35−35
Text/Pandoc/Definition.hs+1−1 Text/Pandoc/Readers/Markdown.hs+3−3 Text/Pandoc/Writers/ConTeXt.hs+1−1 Text/Pandoc/Writers/Docbook.hs+2−2 Text/Pandoc/Writers/HTML.hs+2−2 Text/Pandoc/Writers/MediaWiki.hs+2−2 Text/Pandoc/Writers/OpenDocument.hs+3−3 Text/Pandoc/Writers/RTF.hs+1−1 tests/tables.opendocument+20−20
Text/Pandoc/Definition.hs+1−1
@@ -84,7 +84,7 @@ data Block
8484 -- the term, and a block list)
8585 | Header Int [Inline] -- ^ Header - level (integer) and text (inlines)
8686 | HorizontalRule -- ^ Horizontal rule
87− | Table [Inline] [Alignment] [Float] [[Block]] [[[Block]]] -- ^ Table,
87+ | Table [Inline] [Alignment] [Double] [[Block]] [[[Block]]] -- ^ Table,
8888 -- with caption, column alignments,
8989 -- relative column widths, column headers
9090 -- (each a list of blocks), and rows
Text/Pandoc/Readers/Markdown.hs+3−3
@@ -696,9 +696,9 @@ multilineRow indices = do
696696 mapM (parseFromString (many plain)) cols
697697
698698-- Calculate relative widths of table columns, based on indices
699−widthsFromIndices :: Int -- Number of columns on terminal
700− -> [Int] -- Indices
701− -> [Float] -- Fractional relative sizes of columns
699+widthsFromIndices :: Int -- Number of columns on terminal
700+ -> [Int] -- Indices
701+ -> [Double] -- Fractional relative sizes of columns
702702widthsFromIndices _ [] = []
703703widthsFromIndices numColumns indices =
704704 let lengths = zipWith (-) indices (0:indices)
Text/Pandoc/Writers/ConTeXt.hs+1−1
@@ -210,7 +210,7 @@ blockToConTeXt (Table caption aligns widths heads rows) = do
210210 text "\\HL" $$ headers $$ text "\\HL" $$
211211 vcat rows' $$ text "\\HL\n\\stoptable"
212212
213−printDecimal :: Float -> String
213+printDecimal :: Double -> String
214214printDecimal = printf "%.2f"
215215
216216tableRowToConTeXt :: [[Block]] -> State WriterState Doc
Text/Pandoc/Writers/Docbook.hs+2−2
@@ -165,7 +165,7 @@ blockToDocbook opts (Table caption aligns widths headers rows) =
165165
166166colHeadsToDocbook :: WriterOptions
167167 -> [[Char]]
168− -> [Float]
168+ -> [Double]
169169 -> [[Block]]
170170 -> Doc
171171colHeadsToDocbook opts alignStrings widths headers =
@@ -188,7 +188,7 @@ tableRowToDocbook opts aligns cols = inTagsIndented "tr" $
188188tableItemToDocbook :: WriterOptions
189189 -> [Char]
190190 -> [Char]
191− -> Float
191+ -> Double
192192 -> [Block]
193193 -> Doc
194194tableItemToDocbook opts tag align width item =
Text/Pandoc/Writers/HTML.hs+2−2
@@ -380,7 +380,7 @@ blockToHtml opts (Table capt aligns widths headers rows') = do
380380
381381colHeadsToHtml :: WriterOptions
382382 -> [[Char]]
383− -> [Float]
383+ -> [Double]
384384 -> [[Block]]
385385 -> State WriterState Html
386386colHeadsToHtml opts alignStrings widths headers = do
@@ -407,7 +407,7 @@ tableRowToHtml opts aligns columns =
407407tableItemToHtml :: WriterOptions
408408 -> (Html -> Html)
409409 -> [Char]
410− -> Float
410+ -> Double
411411 -> [Block]
412412 -> State WriterState Html
413413tableItemToHtml opts tag' align' width' item = do
Text/Pandoc/Writers/MediaWiki.hs+2−2
@@ -259,7 +259,7 @@ vcat (x:xs) = x ++ "\n" ++ vcat xs
259259
260260colHeadsToMediaWiki :: WriterOptions
261261 -> [[Char]]
262− -> [Float]
262+ -> [Double]
263263 -> [[Block]]
264264 -> State WriterState String
265265colHeadsToMediaWiki opts alignStrings widths headers = do
@@ -286,7 +286,7 @@ tableRowToMediaWiki opts aligns columns =
286286tableItemToMediaWiki :: WriterOptions
287287 -> [Char]
288288 -> [Char]
289− -> Float
289+ -> Double
290290 -> [Block]
291291 -> State WriterState String
292292tableItemToMediaWiki opts tag' align' width' item = do
Text/Pandoc/Writers/OpenDocument.hs+3−3
@@ -34,7 +34,7 @@ import Text.Pandoc.Shared
3434import Text.Pandoc.XML
3535import Text.Pandoc.Readers.TeXMath
3636import Text.PrettyPrint.HughesPJ hiding ( Str )
37−
37+import Text.Printf ( printf )
3838import Control.Applicative ( (<$>) )
3939import Control.Arrow ( (***), (>>>) )
4040import Control.Monad.State hiding ( when )
@@ -460,7 +460,7 @@ listLevelStyle i =
460460 [ ("text:space-before" , indent ++ "in")
461461 , ("text:min-label-width", "0.25in")]
462462
463−tableStyle :: Int -> [(Char,Float)] -> Doc
463+tableStyle :: Int -> [(Char,Double)] -> Doc
464464tableStyle num wcs =
465465 let tableId = "Table" ++ show (num + 1)
466466 table = inTags True "style:style"
@@ -472,7 +472,7 @@ tableStyle num wcs =
472472 [ ("style:name" , tableId ++ "." ++ [c])
473473 , ("style:family", "table-column" )] $
474474 selfClosingTag "style:table-column-properties"
475− [("style:column-width", show (7 * w) ++ "in")]
475+ [("style:column-width", printf "%.2f" (7 * w) ++ "in")]
476476 cellStyle = inTags True "style:style"
477477 [ ("style:name" , tableId ++ ".A1")
478478 , ("style:family", "table-cell" )] $
Text/Pandoc/Writers/RTF.hs+1−1
@@ -190,7 +190,7 @@ blockToRTF indent alignment (Table caption aligns sizes headers rows) =
190190 concatMap (tableRowToRTF False indent aligns sizes) rows ++
191191 rtfPar indent 0 alignment (inlineListToRTF caption)
192192
193−tableRowToRTF :: Bool -> Int -> [Alignment] -> [Float] -> [[Block]] -> String
193+tableRowToRTF :: Bool -> Int -> [Alignment] -> [Double] -> [[Block]] -> String
194194tableRowToRTF header indent aligns sizes cols =
195195 let columns = concat $ zipWith (tableItemToRTF indent) aligns cols
196196 totalTwips = 6 * 1440 -- 6 inches
tests/tables.opendocument+20−20
@@ -70,16 +70,16 @@
7070 <style:table-properties style:rel-width="100%" table:align="center" />
7171 </style:style>
7272 <style:style style:name="Table1.A" style:family="table-column">
73− <style:table-column-properties style:column-width="1.0500001in" />
73+ <style:table-column-properties style:column-width="1.05in" />
7474 </style:style>
7575 <style:style style:name="Table1.B" style:family="table-column">
76− <style:table-column-properties style:column-width="0.6125in" />
76+ <style:table-column-properties style:column-width="0.61in" />
7777 </style:style>
7878 <style:style style:name="Table1.C" style:family="table-column">
79− <style:table-column-properties style:column-width="1.1374999in" />
79+ <style:table-column-properties style:column-width="1.14in" />
8080 </style:style>
8181 <style:style style:name="Table1.D" style:family="table-column">
82− <style:table-column-properties style:column-width="0.875in" />
82+ <style:table-column-properties style:column-width="0.88in" />
8383 </style:style>
8484 <style:style style:name="Table1.A1" style:family="table-cell">
8585 <style:table-cell-properties fo:border="none" />
@@ -88,16 +88,16 @@
8888 <style:table-properties style:rel-width="100%" table:align="center" />
8989 </style:style>
9090 <style:style style:name="Table2.A" style:family="table-column">
91− <style:table-column-properties style:column-width="1.0500001in" />
91+ <style:table-column-properties style:column-width="1.05in" />
9292 </style:style>
9393 <style:style style:name="Table2.B" style:family="table-column">
94− <style:table-column-properties style:column-width="0.6125in" />
94+ <style:table-column-properties style:column-width="0.61in" />
9595 </style:style>
9696 <style:style style:name="Table2.C" style:family="table-column">
97− <style:table-column-properties style:column-width="1.1374999in" />
97+ <style:table-column-properties style:column-width="1.14in" />
9898 </style:style>
9999 <style:style style:name="Table2.D" style:family="table-column">
100− <style:table-column-properties style:column-width="0.875in" />
100+ <style:table-column-properties style:column-width="0.88in" />
101101 </style:style>
102102 <style:style style:name="Table2.A1" style:family="table-cell">
103103 <style:table-cell-properties fo:border="none" />
@@ -106,16 +106,16 @@
106106 <style:table-properties style:rel-width="100%" table:align="center" />
107107 </style:style>
108108 <style:style style:name="Table3.A" style:family="table-column">
109− <style:table-column-properties style:column-width="1.0500001in" />
109+ <style:table-column-properties style:column-width="1.05in" />
110110 </style:style>
111111 <style:style style:name="Table3.B" style:family="table-column">
112− <style:table-column-properties style:column-width="0.6125in" />
112+ <style:table-column-properties style:column-width="0.61in" />
113113 </style:style>
114114 <style:style style:name="Table3.C" style:family="table-column">
115− <style:table-column-properties style:column-width="1.1374999in" />
115+ <style:table-column-properties style:column-width="1.14in" />
116116 </style:style>
117117 <style:style style:name="Table3.D" style:family="table-column">
118− <style:table-column-properties style:column-width="0.875in" />
118+ <style:table-column-properties style:column-width="0.88in" />
119119 </style:style>
120120 <style:style style:name="Table3.A1" style:family="table-cell">
121121 <style:table-cell-properties fo:border="none" />
@@ -124,16 +124,16 @@
124124 <style:table-properties style:rel-width="100%" table:align="center" />
125125 </style:style>
126126 <style:style style:name="Table4.A" style:family="table-column">
127− <style:table-column-properties style:column-width="1.0500001in" />
127+ <style:table-column-properties style:column-width="1.05in" />
128128 </style:style>
129129 <style:style style:name="Table4.B" style:family="table-column">
130− <style:table-column-properties style:column-width="0.96250004in" />
130+ <style:table-column-properties style:column-width="0.96in" />
131131 </style:style>
132132 <style:style style:name="Table4.C" style:family="table-column">
133− <style:table-column-properties style:column-width="1.1374999in" />
133+ <style:table-column-properties style:column-width="1.14in" />
134134 </style:style>
135135 <style:style style:name="Table4.D" style:family="table-column">
136− <style:table-column-properties style:column-width="2.3625in" />
136+ <style:table-column-properties style:column-width="2.36in" />
137137 </style:style>
138138 <style:style style:name="Table4.A1" style:family="table-cell">
139139 <style:table-cell-properties fo:border="none" />
@@ -142,16 +142,16 @@
142142 <style:table-properties style:rel-width="100%" table:align="center" />
143143 </style:style>
144144 <style:style style:name="Table5.A" style:family="table-column">
145− <style:table-column-properties style:column-width="1.0500001in" />
145+ <style:table-column-properties style:column-width="1.05in" />
146146 </style:style>
147147 <style:style style:name="Table5.B" style:family="table-column">
148− <style:table-column-properties style:column-width="0.96250004in" />
148+ <style:table-column-properties style:column-width="0.96in" />
149149 </style:style>
150150 <style:style style:name="Table5.C" style:family="table-column">
151− <style:table-column-properties style:column-width="1.1374999in" />
151+ <style:table-column-properties style:column-width="1.14in" />
152152 </style:style>
153153 <style:style style:name="Table5.D" style:family="table-column">
154− <style:table-column-properties style:column-width="2.3625in" />
154+ <style:table-column-properties style:column-width="2.36in" />
155155 </style:style>
156156 <style:style style:name="Table5.A1" style:family="table-cell">
157157 <style:table-cell-properties fo:border="none" />