From 4afbfaee71fd6529c627325843aaebe3ec7ff938 Mon Sep 17 00:00:00 2001 From: David Waern Date: Thu, 8 Apr 2010 00:32:52 +0000 Subject: Fix #118 Avoid being too greedy when lexing URL markup (<..>), in order to allow multiple URLs on the same line. Do the same thing with <<..>> and #..#. --- src/Haddock/Lex.x | 6 +-- tests/tests/NonGreedy.hs | 5 ++ tests/tests/NonGreedy.html.ref | 115 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 tests/tests/NonGreedy.hs create mode 100644 tests/tests/NonGreedy.html.ref diff --git a/src/Haddock/Lex.x b/src/Haddock/Lex.x index 115646ca..77d22723 100644 --- a/src/Haddock/Lex.x +++ b/src/Haddock/Lex.x @@ -82,9 +82,9 @@ $ident = [$alphanum \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~\:] { $special { strtoken $ \s -> TokSpecial (head s) } - \<\<.*\>\> { strtoken $ \s -> TokPic (init $ init $ tail $ tail s) } - \<.*\> { strtoken $ \s -> TokURL (init (tail s)) } - \#.*\# { strtoken $ \s -> TokAName (init (tail s)) } + \<\< [^\>]* \>\> { strtoken $ \s -> TokPic (init $ init $ tail $ tail s) } + \< [^\>]* \> { strtoken $ \s -> TokURL (init (tail s)) } + \# [^\#]* \# { strtoken $ \s -> TokAName (init (tail s)) } \/ [^\/]* \/ { strtoken $ \s -> TokEmphasis (init (tail s)) } [\'\`] $ident+ [\'\`] { ident } \\ . { strtoken (TokString . tail) } diff --git a/tests/tests/NonGreedy.hs b/tests/tests/NonGreedy.hs new file mode 100644 index 00000000..f51b55f5 --- /dev/null +++ b/tests/tests/NonGreedy.hs @@ -0,0 +1,5 @@ +module NonGreedy where + +-- | +f :: a +f = undefined diff --git a/tests/tests/NonGreedy.html.ref b/tests/tests/NonGreedy.html.ref new file mode 100644 index 00000000..670fc34a --- /dev/null +++ b/tests/tests/NonGreedy.html.ref @@ -0,0 +1,115 @@ + + +NonGreedy
 ContentsIndex
NonGreedy
Synopsis
f :: a
Documentation
f :: a
url1 url2 +
Produced by Haddock version 2.7.2
-- cgit v1.2.3