This repository was archived by the owner on Aug 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
src/Documentation/Haddock
test/Documentation/Haddock Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ takeWhile1_ = mfilter (not . T.null) . takeWhile_
227227-- DocAName "Hello world"
228228anchor :: Parser (DocH mod a )
229229anchor = DocAName . T. unpack <$>
230- disallowNewline (" #" *> takeWhile1_ (/= ' #' ) <* " #" )
230+ (" #" *> takeWhile1_ (\ x -> x /= ' #' && not (isSpace x) ) <* " #" )
231231
232232-- | Monospaced strings.
233233--
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ data DocH mod id
126126 | DocMathInline String
127127 | DocMathDisplay String
128128 | DocAName String
129- -- ^ A (HTML) anchor.
129+ -- ^ A (HTML) anchor. It must not contain any spaces.
130130 | DocProperty String
131131 | DocExamples [Example ]
132132 | DocHeader (Header (DocH mod id ))
Original file line number Diff line number Diff line change @@ -288,8 +288,10 @@ spec = do
288288 it " parses a single word anchor" $ do
289289 " #foo#" `shouldParseTo` DocAName " foo"
290290
291- it " parses a multi word anchor" $ do
292- " #foo bar#" `shouldParseTo` DocAName " foo bar"
291+ -- Spaces are not allowed:
292+ -- https://www.w3.org/TR/html51/dom.html#the-id-attribute
293+ it " doesn't parse a multi word anchor" $ do
294+ " #foo bar#" `shouldParseTo` " #foo bar#"
293295
294296 it " parses a unicode anchor" $ do
295297 " #灼眼のシャナ#" `shouldParseTo` DocAName " 灼眼のシャナ"
@@ -304,6 +306,9 @@ spec = do
304306 it " does not accept empty anchors" $ do
305307 " ##" `shouldParseTo` " ##"
306308
309+ it " does not accept anchors containing spaces" $ do
310+ " {-# LANGUAGE GADTs #-}" `shouldParseTo` " {-# LANGUAGE GADTs #-}"
311+
307312 context " when parsing emphasised text" $ do
308313 it " emphasises a word on its own" $ do
309314 " /foo/" `shouldParseTo` DocEmphasis " foo"
You can’t perform that action at this time.
0 commit comments