aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJess Robinson <[email protected]>2012-03-16 20:55:47 +0000
committerJohn MacFarlane <[email protected]>2012-04-25 13:54:17 -0700
commitfae214e328bdf48d784aba1a24d74526784bb33c (patch)
tree214fd5f80bdd4f7ef931ae1fbefe0e6c086d51ce
parenta2c7db9c1d65031163e46d8fd17b98593d14c039 (diff)
Use U<> instead of L<> for external (http://) links.
Doesn't work for https, should it?
-rw-r--r--src/Text/Pandoc/Writers/PseudoPod.hs7
-rw-r--r--tests/writer.pod14
2 files changed, 12 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Writers/PseudoPod.hs b/src/Text/Pandoc/Writers/PseudoPod.hs
index 81fb98492..62b519d63 100644
--- a/src/Text/Pandoc/Writers/PseudoPod.hs
+++ b/src/Text/Pandoc/Writers/PseudoPod.hs
@@ -37,7 +37,7 @@ import Text.Pandoc.Templates (renderTemplate)
import Text.Pandoc.Shared
import Text.Pandoc.Parsing hiding (blankline)
import Text.ParserCombinators.Parsec ( runParser, GenParser )
-import Data.List ( intersperse )
+import Data.List ( isPrefixOf, intersperse )
import Text.Pandoc.Pretty
import Control.Monad.State
@@ -424,7 +424,10 @@ inlineToPseudoPod opts (Link txt (src, _)) = do
let linktext = if null txt
then empty
else label <> (text "|")
- return $ "L<" <> linktext <> (text src) <> ">"
+ let linktype = if isPrefixOf "http://" src
+ then "U<"
+ else "L<"
+ return $ linktype <> linktext <> (text src) <> ">"
inlineToPseudoPod opts (Image alternate (source, tit)) = do
let txt = if (null alternate) || (alternate == [Str ""]) ||
diff --git a/tests/writer.pod b/tests/writer.pod
index bcb35bd5a..d303988a8 100644
--- a/tests/writer.pod
+++ b/tests/writer.pod
@@ -879,7 +879,7 @@ spaces: a^b c^d, a~b c~d.
‘He said, “I want to go.”’ Were you alive in the 70’s?
-Here is some quoted ‘C<< code >>’ and a “L<quoted
+Here is some quoted ‘C<< code >>’ and a “U<quoted
link|http://example.com/?foo=1&bar=2>”.
Some dashes: one—two — three—four — five.
@@ -1085,9 +1085,9 @@ Foo L<biz|/url/>.
=head2 With ampersands
-Here’s a L<link with an ampersand in the URL|http://example.com/?foo=1&bar=2>.
+Here’s a U<link with an ampersand in the URL|http://example.com/?foo=1&bar=2>.
-Here’s a link with an amersand in the link text: L<AT&T|http://att.com/>.
+Here’s a link with an amersand in the link text: U<AT&T|http://att.com/>.
Here’s an L<inline link|/script?foo=1&bar=2>.
@@ -1096,7 +1096,7 @@ Here’s an L<inline link in pointy braces|/script?foo=1&bar=2>.
=head2 Autolinks
With an ampersand:
-L<C<< http:E<sol>E<sol>example.comE<sol>?foo=1&bar=2 >>|http://example.com/?foo=1&bar=2>
+U<C<< http:E<sol>E<sol>example.comE<sol>?foo=1&bar=2 >>|http://example.com/?foo=1&bar=2>
=over
@@ -1106,7 +1106,7 @@ In a list?
=item *
-L<C<< http:E<sol>E<sol>example.comE<sol> >>|http://example.com/>
+U<C<< http:E<sol>E<sol>example.comE<sol> >>|http://example.com/>
=item *
@@ -1118,7 +1118,7 @@ An e-mail address: L<C<< [email protected] >>|mailto:[email protected]>
=begin blockquote
-Blockquoted: L<C<< http:E<sol>E<sol>example.comE<sol> >>|http://example.com/>
+Blockquoted: U<C<< http:E<sol>E<sol>example.comE<sol> >>|http://example.com/>
=end blockquote
@@ -1146,7 +1146,7 @@ the footnote reference. It need not be placed at the end of the document.> and
another.N<Here’s the long note. This one contains multiple blocks.> This
should I<not> be a footnote reference, because it contains a space.[^my note]
Here is an inline note.N<This is I<easier> to type. Inline notes may contain
-L<links|http://google.com> and C<< ] >> verbatim characters, as well as
+U<links|http://google.com> and C<< ] >> verbatim characters, as well as
[bracketed text].>
=begin blockquote