packages feed

asciidoc 0.1.0.3 → 0.1.0.4

raw patch · 13 files changed

+444/−222 lines, 13 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,17 @@ # Revision history for asciidoc-hs +## 0.1.0.4 -- 2026-08-11++  * Fix tracking of rowspans in table parsing (#13). Columns occupied+    by rowspans from previous rows were not skipped when recording the+    rowspans introduced by a new row, so tables with staggered rowspans+    could fail to parse or be parsed incorrectly.++  * Tables no longer have a footer by default (#13). Previously the+    last row of every table was treated as a footer unless the+    `nofooter` option was given. Now, as in Asciidoctor, a footer is+    only created when the `footer` option is given.+ ## 0.1.0.3 -- 2026-06-02    * Open block delimiter is exactly two `--` (#12).
asciidoc.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.4 name:               asciidoc-version:            0.1.0.3+version:            0.1.0.4 synopsis:           AsciiDoc parser. description:        A parser for AsciiDoc syntax. license:            BSD-3-Clause
src/AsciiDoc/Parse.hs view
@@ -969,8 +969,7 @@                             , tableSeparator = mbsep                             , tableHeader = "header" `elem` options ||                                 "noheader" `notElem` options-                            , tableFooter = "footer" `elem` options ||-                                "nofooter" `notElem` options+                            , tableFooter = "footer" `elem` options                             }   let getRows mbspecs rowspans = (([],[]) <$ pTableBorder) <|>          do -- for this row, we modify the specs based on rowspans@@ -981,12 +980,18 @@             row@(TableRow cells) <- pTableRow tableOpts mbspecs'             let numcols = sum (map cellColspan cells)             let specs = fromMaybe (replicate numcols defaultColumnSpec) mbspecs-            -- now, update rowspans in light of new row-            let updateRowspans [] rs = rs-                updateRowspans (c:cs) rs =-                  map (+ (cellRowspan c)) (take (cellColspan c) rs)-                  ++ updateRowspans cs (drop (cellColspan c) rs)-            let rowspans' = updateRowspans cells (map (\x -> x - 1) rowspans)+            -- now, update rowspans in light of new row; the new row's+            -- cells only occupy the columns that are not taken up by+            -- rowspans from rows above (after decrementing, those+            -- columns have a countdown >= 0), so we skip those:+            let fillRowspans [] rs = rs+                fillRowspans vs (r:rs)+                  | r >= 0 = r : fillRowspans vs rs+                fillRowspans (v:vs) (_:rs) = v : fillRowspans vs rs+                fillRowspans _ [] = []+            let newspans = concatMap+                  (\c -> replicate (cellColspan c) (cellRowspan c - 1)) cells+            let rowspans' = fillRowspans newspans (map (\x -> x - 1) rowspans)             (\(rows, colspecs') -> (row:rows, case rows of                                                  [] -> specs                                                  _ -> colspecs'))
test/asciidoctor/table/aligns-per-cell.test view
@@ -166,30 +166,29 @@                      , cellRowspan = 1                      }                  ]+             , TableRow+                 [ TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Paragraph+                                [ Inline mempty (Str "This content spans three columns (")+                                , Inline mempty (Str "3{plus}")+                                , Inline mempty (Str ") and is centered horizontally (")+                                , Inline mempty (Str "{caret}")+                                , Inline mempty (Str ") and vertically (")+                                , Inline mempty (Str ".{caret}")+                                , Inline mempty (Str ") within the cell.")+                                ])+                         ]+                     , cellHorizAlign = Just AlignCenter+                     , cellVertAlign = Just AlignMiddle+                     , cellColspan = 3+                     , cellRowspan = 1+                     }+                 ]              ]-             (Just-                [ TableRow-                    [ TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Paragraph-                                   [ Inline mempty (Str "This content spans three columns (")-                                   , Inline mempty (Str "3{plus}")-                                   , Inline mempty (Str ") and is centered horizontally (")-                                   , Inline mempty (Str "{caret}")-                                   , Inline mempty (Str ") and vertically (")-                                   , Inline mempty (Str ".{caret}")-                                   , Inline mempty (Str ") within the cell.")-                                   ])-                            ]-                        , cellHorizAlign = Just AlignCenter-                        , cellVertAlign = Just AlignMiddle-                        , cellColspan = 3-                        , cellRowspan = 1-                        }-                    ]-                ]))+             Nothing)       ]   }
test/asciidoctor/table/basic.test view
@@ -58,34 +58,33 @@                         }                     ]                 ])-             []-             (Just-                [ TableRow-                    [ TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Paragraph [ Inline mempty (Str "Cell in column 1, row 2") ])-                            ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    , TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Paragraph [ Inline mempty (Str "Cell in column 2, row 2") ])-                            ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    ]-                ]))+             [ TableRow+                 [ TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Paragraph [ Inline mempty (Str "Cell in column 1, row 2") ])+                         ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Paragraph [ Inline mempty (Str "Cell in column 2, row 2") ])+                         ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]+             ]+             Nothing)       ]   }
test/asciidoctor/table/cell-with-paragraphs.test view
@@ -44,26 +44,25 @@                         }                     ]                 ])-             []-             (Just-                [ TableRow-                    [ TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Paragraph [ Inline mempty (Str "First paragraph on row 2") ])-                            , Block-                                mempty-                                Nothing-                                (Paragraph [ Inline mempty (Str "Second paragraph on row 2") ])-                            ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    ]-                ]))+             [ TableRow+                 [ TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Paragraph [ Inline mempty (Str "First paragraph on row 2") ])+                         , Block+                             mempty+                             Nothing+                             (Paragraph [ Inline mempty (Str "Second paragraph on row 2") ])+                         ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]+             ]+             Nothing)       ]   }
test/asciidoctor/table/colspan.test view
@@ -79,38 +79,37 @@                         }                     ]                 ])-             []-             (Just-                [ TableRow-                    [ TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Paragraph-                                   [ Inline-                                       mempty-                                       (Str "Content in a single cell that spans columns 1 and 3")-                                   ])-                            ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 2-                        , cellRowspan = 1-                        }-                    , TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Paragraph [ Inline mempty (Str "Cell in column 3, row 1") ])-                            ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    ]-                ]))+             [ TableRow+                 [ TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Paragraph+                                [ Inline+                                    mempty+                                    (Str "Content in a single cell that spans columns 1 and 3")+                                ])+                         ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 2+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Paragraph [ Inline mempty (Str "Cell in column 3, row 1") ])+                         ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]+             ]+             Nothing)       ]   }
test/asciidoctor/table/insane-cells-formatting.test view
@@ -178,23 +178,22 @@                      , cellRowspan = 1                      }                  ]+             , TableRow+                 [ TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Listing+                                Nothing [ SourceLine "puts \"This is a source block!\"" [] ])+                         ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]              ]-             (Just-                [ TableRow-                    [ TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Listing-                                   Nothing [ SourceLine "puts \"This is a source block!\"" [] ])-                            ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    ]-                ]))+             Nothing)       ]   }
test/asciidoctor/table/rowspan.test view
@@ -123,34 +123,33 @@                      , cellRowspan = 1                      }                  ]+             , TableRow+                 [ TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Paragraph [ Inline mempty (Str "Cell in column 2, row 3") ])+                         ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Paragraph [ Inline mempty (Str "Cell in column 3, row 3") ])+                         ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]              ]-             (Just-                [ TableRow-                    [ TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Paragraph [ Inline mempty (Str "Cell in column 2, row 3") ])-                            ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    , TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Paragraph [ Inline mempty (Str "Cell in column 3, row 3") ])-                            ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    ]-                ]))+             Nothing)       ]   }
test/asciidoctor/table/with-header.test view
@@ -87,34 +87,33 @@                      , cellRowspan = 1                      }                  ]+             , TableRow+                 [ TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Paragraph [ Inline mempty (Str "Cell in column 1, row 2") ])+                         ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block+                             mempty+                             Nothing+                             (Paragraph [ Inline mempty (Str "Cell in column 2, row 2") ])+                         ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]              ]-             (Just-                [ TableRow-                    [ TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Paragraph [ Inline mempty (Str "Cell in column 1, row 2") ])-                            ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    , TableCell-                        { cellContent =-                            [ Block-                                mempty-                                Nothing-                                (Paragraph [ Inline mempty (Str "Cell in column 2, row 2") ])-                            ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    ]-                ]))+             Nothing)       ]   }
test/feature/table/longborder.test view
@@ -50,26 +50,25 @@                         }                     ]                 ])-             []-             (Just-                [ TableRow-                    [ TableCell-                        { cellContent =-                            [ Block mempty Nothing (Paragraph [ Inline mempty (Str "c") ]) ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    , TableCell-                        { cellContent =-                            [ Block mempty Nothing (Paragraph [ Inline mempty (Str "d") ]) ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    ]-                ]))+             [ TableRow+                 [ TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "c") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "d") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]+             ]+             Nothing)       ]   }
+ test/regression/issue_13.test view
@@ -0,0 +1,214 @@+[width="100%",cols="34%,33%,33%",options="noheader",]+|===+.2+|1,1 2+|1,2+          |2,2 .2+|2,3+ 2+|1,3+|===++[cols="1,1,1",options="noheader"]+|===+|1,1 .2+|1,2 |1,3+|2,1 .2+|2,3+|3,1 |3,2+|4,1 |4,2 |4,3+|===+>>>+Document+  { docMeta =+      Meta+        { docTitle = []+        , docTitleAttributes = Nothing+        , docAuthors = []+        , docRevision = Nothing+        , docAttributes = fromList [ ( "sectids" , "" ) ]+        }+  , docBlocks =+      [ Block+          Attr+          ( [] , fromList [ ( "width" , "100%" ) ] )+          Nothing+          (Table+             [ ColumnSpec+                 { colHorizAlign = Nothing+                 , colVertAlign = Nothing+                 , colWidth = Just 34+                 , colStyle = Nothing+                 }+             , ColumnSpec+                 { colHorizAlign = Nothing+                 , colVertAlign = Nothing+                 , colWidth = Just 33+                 , colStyle = Nothing+                 }+             , ColumnSpec+                 { colHorizAlign = Nothing+                 , colVertAlign = Nothing+                 , colWidth = Just 33+                 , colStyle = Nothing+                 }+             ]+             Nothing+             [ TableRow+                 [ TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "1,1") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 2+                     }+                 , TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "1,2") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 2+                     , cellRowspan = 1+                     }+                 ]+             , TableRow+                 [ TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "2,2") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "2,3") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 2+                     }+                 ]+             , TableRow+                 [ TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "1,3") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 2+                     , cellRowspan = 1+                     }+                 ]+             ]+             Nothing)+      , Block+          mempty+          Nothing+          (Table+             [ ColumnSpec+                 { colHorizAlign = Nothing+                 , colVertAlign = Nothing+                 , colWidth = Just 1+                 , colStyle = Nothing+                 }+             , ColumnSpec+                 { colHorizAlign = Nothing+                 , colVertAlign = Nothing+                 , colWidth = Just 1+                 , colStyle = Nothing+                 }+             , ColumnSpec+                 { colHorizAlign = Nothing+                 , colVertAlign = Nothing+                 , colWidth = Just 1+                 , colStyle = Nothing+                 }+             ]+             Nothing+             [ TableRow+                 [ TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "1,1") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "1,2") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 2+                     }+                 , TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "1,3") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]+             , TableRow+                 [ TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "2,1") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "2,3") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 2+                     }+                 ]+             , TableRow+                 [ TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "3,1") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "3,2") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]+             , TableRow+                 [ TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "4,1") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "4,2") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 , TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "4,3") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]+             ]+             Nothing)+      ]+  }
test/regression/issue_5.test view
@@ -99,18 +99,17 @@                      , cellRowspan = 2                      }                  ]+             , TableRow+                 [ TableCell+                     { cellContent =+                         [ Block mempty Nothing (Paragraph [ Inline mempty (Str "23") ]) ]+                     , cellHorizAlign = Nothing+                     , cellVertAlign = Nothing+                     , cellColspan = 1+                     , cellRowspan = 1+                     }+                 ]              ]-             (Just-                [ TableRow-                    [ TableCell-                        { cellContent =-                            [ Block mempty Nothing (Paragraph [ Inline mempty (Str "23") ]) ]-                        , cellHorizAlign = Nothing-                        , cellVertAlign = Nothing-                        , cellColspan = 1-                        , cellRowspan = 1-                        }-                    ]-                ]))+             Nothing)       ]   }