aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2010-04-08 00:32:52 +0000
committerDavid Waern <david.waern@gmail.com>2010-04-08 00:32:52 +0000
commit4afbfaee71fd6529c627325843aaebe3ec7ff938 (patch)
tree60a9333467dff9cdb300985fd375580e1f6885e9
parent2a45b7c00f64ac30b29a8c0baf2e663a41faab70 (diff)
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 #..#.
-rw-r--r--src/Haddock/Lex.x6
-rw-r--r--tests/tests/NonGreedy.hs5
-rw-r--r--tests/tests/NonGreedy.html.ref115
3 files changed, 123 insertions, 3 deletions
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 \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~\:]
<string,def> {
$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
+
+-- | <url1> <url2>
+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 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--Rendered using the Haskell Html Library v0.2-->
+<HTML
+><HEAD
+><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"
+><TITLE
+>NonGreedy</TITLE
+><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"
+><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"
+></SCRIPT
+><SCRIPT TYPE="text/javascript"
+>window.onload = function () {setSynopsis("mini_NonGreedy.html")};</SCRIPT
+></HEAD
+><BODY
+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
+><TR
+><TD CLASS="topbar"
+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
+><TR
+><TD
+><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "
+></TD
+><TD CLASS="title"
+></TD
+><TD CLASS="topbut"
+><A HREF="">Contents</A
+></TD
+><TD CLASS="topbut"
+><A HREF="">Index</A
+></TD
+></TR
+></TABLE
+></TD
+></TR
+><TR
+><TD CLASS="modulebar"
+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
+><TR
+><TD
+><FONT SIZE="6"
+>NonGreedy</FONT
+></TD
+></TR
+></TABLE
+></TD
+></TR
+><TR
+><TD CLASS="s15"
+></TD
+></TR
+><TR
+><TD CLASS="s15"
+></TD
+></TR
+><TR
+><TD CLASS="section1"
+>Synopsis</TD
+></TR
+><TR
+><TD CLASS="s15"
+></TD
+></TR
+><TR
+><TD CLASS="body"
+><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
+><TR
+><TD CLASS="decl"
+><A HREF="">f</A
+> :: a</TD
+></TR
+></TABLE
+></TD
+></TR
+><TR
+><TD CLASS="s15"
+></TD
+></TR
+><TR
+><TD CLASS="section1"
+>Documentation</TD
+></TR
+><TR
+><TD CLASS="s15"
+></TD
+></TR
+><TR
+><TD CLASS="decl"
+><A NAME="v:f"
+><A NAME="v%3Af"
+></A
+></A
+><B
+>f</B
+> :: a</TD
+></TR
+><TR
+><TD CLASS="doc"
+><A HREF="">url1</A
+> <A HREF="">url2</A
+>
+</TD
+></TR
+><TR
+><TD CLASS="s15"
+></TD
+></TR
+><TR
+><TD CLASS="botbar"
+>Produced by <A HREF="">Haddock</A
+> version 2.7.2</TD
+></TR
+></TABLE
+></BODY
+></HTML
+>