From 513af8dd1bce76e37e813366347563284d9879b6 Mon Sep 17 00:00:00 2001
From: John MacFarlane <fiddlosopher@gmail.com>
Date: Fri, 27 Jan 2012 13:44:17 -0800
Subject: [PATCH] LaTeX writer: escape # in href URLs. Closes #359.

---
 src/Text/Pandoc/Writers/LaTeX.hs | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index ce77184e8..dec6d3118 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -171,12 +171,8 @@ elementToLaTeX opts (Sec level _ id' title' elements) = do
 -- escape things as needed for LaTeX
 stringToLaTeX :: Bool -> String -> String
 stringToLaTeX isUrl = escapeStringUsing latexEscapes
-  where latexEscapes = backslashEscapes "{}$%&_" ++
-                       if isUrl
-                          then []
-                          else [ ('~', "\\ensuremath{\\sim}")
-                               , ('#', "\\#")
-                               ] ++
+  where latexEscapes = backslashEscapes "{}$%&_#" ++
+                       [ ('~', "\\ensuremath{\\sim}") | not isUrl ] ++
                        [ ('^', "\\^{}")
                        , ('\\', "\\textbackslash{}")
                        , ('€', "\\euro{}")