[commit: haddock] 2.15, 2.15.0.1, 2.15.0.2, T6018-injective-type-families, adamse-D1033, clean, fix-travis, ghc-head, master, metainfo, v2.15, wip/10268, wip/10313, wip/D538, wip/D538-1, wip/D538-2, wip/D538-3, wip/D538-4, wip/D538-5, wip/D538-6, wip/D548-master, wip/D548-master-2, wip/T10483, wip/T8584, wip/T9840, wip/api-ann-hstylit, wip/api-ann-hstylit-1, wip/api-ann-hstylit-2, wip/api-ann-hstylit-3, wip/api-ann-hstylit-4, wip/api-ann-hstylit-5, wip/api-annot-tweaks-7.10, wip/api-annots-ghc-7.10-3, wip/ast-annotations-separate, wip/ast-prepare-annotations, wip/ast-prepare-annotations-final, wip/ast-prepare-annotations-final2, wip/ast-prepare-annotations-final3, wip/ast-prepare-annotations-final4, wip/ast-prepare-annotations-final5, wip/ast-prepare-annotations-final6, wip/attoparsec-update, wip/landmine-param-family, wip/orf-new, wip/orf-reboot, wip/pattern-synonyms, wip/rae, wip/remove-cabal-dep, wip/trac-9744: Don't mangle append order for nested lists. (f5be842)

git at git.haskell.org git at git.haskell.org
Wed Jul 8 08:29:10 UTC 2015


Repository : ssh://git@git.haskell.org/haddock

On branches: 2.15,2.15.0.1,2.15.0.2,T6018-injective-type-families,adamse-D1033,clean,fix-travis,ghc-head,master,metainfo,v2.15,wip/10268,wip/10313,wip/D538,wip/D538-1,wip/D538-2,wip/D538-3,wip/D538-4,wip/D538-5,wip/D538-6,wip/D548-master,wip/D548-master-2,wip/T10483,wip/T8584,wip/T9840,wip/api-ann-hstylit,wip/api-ann-hstylit-1,wip/api-ann-hstylit-2,wip/api-ann-hstylit-3,wip/api-ann-hstylit-4,wip/api-ann-hstylit-5,wip/api-annot-tweaks-7.10,wip/api-annots-ghc-7.10-3,wip/ast-annotations-separate,wip/ast-prepare-annotations,wip/ast-prepare-annotations-final,wip/ast-prepare-annotations-final2,wip/ast-prepare-annotations-final3,wip/ast-prepare-annotations-final4,wip/ast-prepare-annotations-final5,wip/ast-prepare-annotations-final6,wip/attoparsec-update,wip/landmine-param-family,wip/orf-new,wip/orf-reboot,wip/pattern-synonyms,wip/rae,wip/remove-cabal-dep,wip/trac-9744
Link       : http://git.haskell.org/haddock.git/commitdiff/f5be8427d95217f4efd723575a79f8699b33d003

>---------------------------------------------------------------

commit f5be8427d95217f4efd723575a79f8699b33d003
Author: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
Date:   Wed Jun 25 15:17:20 2014 +0200

    Don't mangle append order for nested lists.
    
    The benefit of this is that the ‘top-level’ element of such lists is
    properly wrapped in <p> tags so any CSS working with these will be
    applied properly. It also just makes more sense.
    
    Pointed out at jgm/pandoc#1346.


>---------------------------------------------------------------

f5be8427d95217f4efd723575a79f8699b33d003
 CHANGES                                            |  2 +
 .../src/Documentation/Haddock/Parser.hs            | 16 +------
 .../test/Documentation/Haddock/ParserSpec.hs       | 16 +++----
 html-test/ref/Nesting.html                         | 54 ++++++++++++++++------
 4 files changed, 51 insertions(+), 37 deletions(-)

diff --git a/CHANGES b/CHANGES
index ee20ca1..3814d09 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,8 @@ Changes in version 2.15.0
 
  * parser: don't wrap headers in DocParagraph (#307)
 
+ * parser: don't mangle append order for nested lists (pandoc #1346)
+
 Changes in version 2.14.3
 
  * Fix parsing of identifiers with ^ or ⋆ in them (#298)
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index 1d98601..805b33f 100644
--- a/haddock-library/src/Documentation/Haddock/Parser.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -265,7 +265,7 @@ innerList item = do
   (cs, items) <- more item
   let contents = docParagraph . parseString . dropNLs . unlines $ c : cs
   return $ case items of
-    Left p -> [contents `joinPara` p]
+    Left p -> [contents <> p]
     Right i -> contents : i
 
 -- | Parses definition lists.
@@ -276,21 +276,9 @@ definitionList = do
   (cs, items) <- more definitionList
   let contents = parseString . dropNLs . unlines $ c : cs
   return $ case items of
-    Left p -> [(label, contents `joinPara` p)]
+    Left p -> [(label, contents <> p)]
     Right i -> (label, contents) : i
 
--- | If possible, appends two 'Doc's under a 'DocParagraph' rather than
--- outside of it. This allows to get structures like
---
--- @DocParagraph (DocAppend … …)@
---
--- rather than
---
--- @DocAppend (DocParagraph …) …@
-joinPara :: DocH mod id -> DocH mod id -> DocH mod id
-joinPara (DocParagraph p) c = docParagraph $ p <> c
-joinPara d p = d <> p
-
 -- | Drops all trailing newlines.
 dropNLs :: String -> String
 dropNLs = reverse . dropWhile (== '\n') . reverse
diff --git a/haddock-library/test/Documentation/Haddock/ParserSpec.hs b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
index 6d05791..a8c2199 100644
--- a/haddock-library/test/Documentation/Haddock/ParserSpec.hs
+++ b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
@@ -547,34 +547,34 @@ spec = do
     context "when parsing paragraphs nested in lists" $ do
       it "can nest the same type of list" $ do
         "* foo\n\n    * bar" `shouldParseTo`
-          DocUnorderedList [ DocParagraph $ "foo"
+          DocUnorderedList [ DocParagraph "foo"
                              <> DocUnorderedList [DocParagraph "bar"]]
 
       it "can nest another type of list inside" $ do
         "* foo\n\n    1. bar" `shouldParseTo`
-          DocUnorderedList [ DocParagraph $ "foo"
+          DocUnorderedList [ DocParagraph "foo"
                              <> DocOrderedList [DocParagraph "bar"]]
 
       it "can nest a code block inside" $ do
         "* foo\n\n    @foo bar baz@" `shouldParseTo`
-          DocUnorderedList [ DocParagraph $ "foo"
+          DocUnorderedList [ DocParagraph "foo"
                              <> DocCodeBlock "foo bar baz"]
 
         "* foo\n\n    @\n    foo bar baz\n    @" `shouldParseTo`
-          DocUnorderedList [ DocParagraph $ "foo"
+          DocUnorderedList [ DocParagraph "foo"
                              <> DocCodeBlock "foo bar baz\n"]
 
       it "can nest more than one level" $ do
         "* foo\n\n    * bar\n\n        * baz\n        qux" `shouldParseTo`
-          DocUnorderedList [ DocParagraph $ "foo"
-                             <> DocUnorderedList [ DocParagraph $ "bar"
+          DocUnorderedList [ DocParagraph "foo"
+                             <> DocUnorderedList [ DocParagraph "bar"
                                                    <> DocUnorderedList [DocParagraph "baz\nqux"]
                                                  ]
                            ]
 
       it "won't fail on not fully indented paragraph" $ do
         "* foo\n\n    * bar\n\n        * qux\nquux" `shouldParseTo`
-          DocUnorderedList [ DocParagraph $ "foo"
+          DocUnorderedList [ DocParagraph "foo"
                              <> DocUnorderedList [ DocParagraph "bar" ]
                            , DocParagraph "qux\nquux"]
 
@@ -589,7 +589,7 @@ spec = do
 
       it "can come back to top level with a different list" $ do
         "* foo\n\n    * bar\n\n1. baz" `shouldParseTo`
-          DocUnorderedList [ DocParagraph $ "foo"
+          DocUnorderedList [ DocParagraph "foo"
                              <> DocUnorderedList [ DocParagraph "bar" ]
                            ]
           <> DocOrderedList [ DocParagraph "baz" ]
diff --git a/html-test/ref/Nesting.html b/html-test/ref/Nesting.html
index 1a7f275..e3302d8 100644
--- a/html-test/ref/Nesting.html
+++ b/html-test/ref/Nesting.html
@@ -86,9 +86,13 @@ window.onload = function () {pageLoad();setSynopsis("mini_Nesting.html");};
 	  ><div class="doc"
 	  ><ul
 	    ><li
-	      >We can<ul
+	      ><p
+		>We can</p
+		><ul
 		><li
-		  >easily go back<ol
+		  ><p
+		    >easily go back</p
+		    ><ol
 		    ><li
 		      >some indentation</li
 		      ></ol
@@ -114,7 +118,9 @@ window.onload = function () {pageLoad();setSynopsis("mini_Nesting.html");};
 	  ><div class="doc"
 	  ><ul
 	    ><li
-	      >Beginning of list<ul
+	      ><p
+		>Beginning of list</p
+		><ul
 		><li
 		  >second list</li
 		  ></ul
@@ -133,7 +139,9 @@ the presence of this text pushes it out of nesting back to the top.</li
 	  ><div class="doc"
 	  ><ul
 	    ><li
-	      >Beginning of list<pre
+	      ><p
+		>Beginning of list</p
+		><pre
 		>nested code
     we preserve the space correctly
 </pre
@@ -149,7 +157,9 @@ the presence of this text pushes it out of nesting back to the top.</li
 	  ><div class="doc"
 	  ><ul
 	    ><li
-	      >Beginning of list<ul
+	      ><p
+		>Beginning of list</p
+		><ul
 		><li
 		  >Nested list</li
 		  ></ul
@@ -165,7 +175,9 @@ the presence of this text pushes it out of nesting back to the top.</li
 	  ><div class="doc"
 	  ><ul
 	    ><li
-	      >Beginning of list<pre
+	      ><p
+		>Beginning of list</p
+		><pre
 		>nested
 bird
 tracks</pre
@@ -181,8 +193,10 @@ tracks</pre
 	  ><div class="doc"
 	  ><ul
 	    ><li
-	      >Beginning of list
-This belongs to the list above!<pre
+	      ><p
+		>Beginning of list
+This belongs to the list above!</p
+		><pre
 		>nested
 bird
 tracks
@@ -194,12 +208,18 @@ another line
   without leading space</pre
 		><ul
 		><li
-		  >Next list
-More of the indented list.<ul
+		  ><p
+		    >Next list
+More of the indented list.</p
+		    ><ul
 		    ><li
-		      >Deeper<ul
+		      ><p
+			>Deeper</p
+			><ul
 			><li
-			  >Deeper<ul
+			  ><p
+			    >Deeper</p
+			    ><ul
 			    ><li
 			      >Even deeper!</li
 			      ><li
@@ -232,12 +252,16 @@ bird
 tracks</pre
 		><ul
 		><li
-		  >Next list
-with more of the indented list content.<p
+		  ><p
+		    >Next list
+with more of the indented list content.</p
+		    ><p
 		    >Even more content on a new line.</p
 		    ><ol
 		    ><li
-		      >Different type of list<ol
+		      ><p
+			>Different type of list</p
+			><ol
 			><li
 			  >Deeper</li
 			  ></ol



More information about the ghc-commits mailing list