@@ -773,6 +773,12 @@ withRaw parser = do
773773inBrackets :: Inlines -> Inlines
774774inBrackets x = str "[" <> x <> str "]"
775775
776+unescapeURL :: String -> String
777+unescapeURL ('\\':x:xs) | isEscapable x = x:unescapeURL xs
778+ where isEscapable c = c `elem` ("#$%&~_^\\{}" :: String)
779+unescapeURL (x:xs) = x:unescapeURL xs
780+unescapeURL [] = ""
781+
776782inlineEnvironment :: PandocMonad m => LP m Inlines
777783inlineEnvironment = try $ do
778784 controlSeq "begin"
@@ -825,7 +831,7 @@ inlineCommands = M.fromList $
825831 , ("ref", rawInlineOr "ref" (inBrackets <$> tok))
826832 , ("textgreek", tok)
827833 , ("sep", lit ",")
828−-- , ("cref", rawInlineOr "cref" (inBrackets <$> tok)) -- from cleveref.sty
834+ , ("cref", rawInlineOr "cref" (inBrackets <$> tok)) -- from cleveref.sty
829835 , ("(", mathInline <$> manyTill anyTok (controlSeq ")"))
830836 , ("[", mathDisplay <$> manyTill anyTok (controlSeq "]"))
831837 , ("ensuremath", mathInline <$> braced)
@@ -878,7 +884,7 @@ inlineCommands = M.fromList $
878884 , ("v", option (str "v") $ try $ tok >>= accent hacek)
879885 , ("u", option (str "u") $ try $ tok >>= accent breve)
880886 , ("i", lit "i")
881−-- , ("\\", linebreak <$ (optional (bracketed inline) *> spaces'))
887+ , ("\\", linebreak <$ (optional (bracketed inline) *> spaces))
882888 , (",", lit "\8198")
883889 , ("@", pure mempty)
884890 , (" ", lit "\160")
@@ -893,8 +899,8 @@ inlineCommands = M.fromList $
893899 , ("verb", doverb)
894900 , ("lstinline", dolstinline)
895901 , ("Verb", doverb)
896−-- , ("url", (unescapeURL <$> braced) >>= \url ->
897−-- pure (link url "" (str url)))
902+ , ("url", ((unescapeURL . T.unpack . untokenize) <$> braced) >>= \url ->
903+ pure (link url "" (str url)))
898904-- , ("href", (unescapeURL <$> braced <* optional sp) >>= \url ->
899905-- tok >>= \lab ->
900906-- pure (link url "" lab))
@@ -1084,7 +1090,7 @@ block = (mempty <$ spaces1)
10841090blocks :: PandocMonad m => LP m Blocks
10851091blocks = mconcat <$> many block
10861092
1087−
1093+{-
10881094-- -- | Parse LaTeX from string and return 'Pandoc' document.
10891095-- readLaTeX :: PandocMonad m
10901096-- => ReaderOptions -- ^ Reader options
@@ -1525,12 +1531,7 @@ blocks = mconcat <$> many block
15251531-- inNote ils =
15261532-- note $ para $ ils <> str "."
15271533--
1528−-- unescapeURL :: String -> String
1529−-- unescapeURL ('\\':x:xs) | isEscapable x = x:unescapeURL xs
1530−-- where isEscapable c = c `elem` ("#$%&~_^\\{}" :: String)
1531−-- unescapeURL (x:xs) = x:unescapeURL xs
1532−-- unescapeURL [] = ""
1533−--
1534+-
15341535-- -- converts e.g. \SI{1}[\$]{} to "$ 1" or \SI{1}{\euro} to "1 €"
15351536-- dosiunitx :: PandocMonad m => LP m Inlines
15361537-- dosiunitx = do
@@ -2328,5 +2329,4 @@ blocks = mconcat <$> many block
23282329-- ++ maybeToList (lookup "language" options
23292330-- >>= fromListingsLanguage)
23302331-- in (fromMaybe "" (lookup "label" options), classes, kvs)
2331−--
2332−--
2332+-}