diff options
author | Albert Krewinkel <albert+github@zeitkraut.de> | 2017-02-12 16:50:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-12 16:50:36 +0100 |
commit | 64ad6ff8d9aed32198763411f8bf6019aac21805 (patch) | |
tree | 595f81b2a3ca1fb18dc67c4c5dde201ae71c17e7 | |
parent | 48c78713c8faf445bed23ae3005abdba3273346b (diff) | |
parent | 9e3f5a5147c2cbc7d230c6fe7d8eaf8244b70c24 (diff) | |
download | pandoc-64ad6ff8d9aed32198763411f8bf6019aac21805.tar.gz |
Merge pull request #3438 from ilabdsf/org-anchor-links
Org anchor links
-rw-r--r-- | pandoc.cabal | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Org.hs | 2 | ||||
-rw-r--r-- | test/Tests/Writers/Org.hs | 25 | ||||
-rw-r--r-- | test/test-pandoc.hs | 2 |
4 files changed, 29 insertions, 1 deletions
diff --git a/pandoc.cabal b/pandoc.cabal index 255057cfa..3f736884b 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -530,6 +530,7 @@ Test-Suite test-pandoc Tests.Writers.Docbook Tests.Writers.HTML Tests.Writers.Markdown + Tests.Writers.Org Tests.Writers.Plain Tests.Writers.AsciiDoc Tests.Writers.LaTeX diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index fd4c16c64..55d3fe656 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -374,7 +374,7 @@ orgPath :: String -> String orgPath src = case src of [] -> mempty -- wiki link - ('#':xs) -> xs -- internal link + ('#':_) -> src -- internal link _ | isUrl src -> src _ | isFilePath src -> src _ -> "file:" <> src diff --git a/test/Tests/Writers/Org.hs b/test/Tests/Writers/Org.hs new file mode 100644 index 000000000..e2c58327b --- /dev/null +++ b/test/Tests/Writers/Org.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE OverloadedStrings #-} +module Tests.Writers.Org (tests) where + +import Test.Framework +import Text.Pandoc.Builder +import Text.Pandoc +import Tests.Helpers +import Text.Pandoc.Arbitrary() + +infix 4 =: +(=:) :: (ToString a, ToPandoc a) + => String -> (a, String) -> Test +(=:) = test (purely (writeOrg def . toPandoc)) + +tests :: [Test] +tests = [ testGroup "links" + -- See http://orgmode.org/manual/Internal-links.html#Internal-links + [ "simple link" + =: link "/url" "" "foo" + =?> "[[/url][foo]]" + , "internal link to anchor" + =: link "#my-custom-id" "" "#my-custom-id" + =?> "[[#my-custom-id]]" + ] + ] diff --git a/test/test-pandoc.hs b/test/test-pandoc.hs index 2624e9a53..8800dde24 100644 --- a/test/test-pandoc.hs +++ b/test/test-pandoc.hs @@ -21,6 +21,7 @@ import qualified Tests.Writers.HTML import qualified Tests.Writers.Docbook import qualified Tests.Writers.Native import qualified Tests.Writers.Markdown +import qualified Tests.Writers.Org import qualified Tests.Writers.Plain import qualified Tests.Writers.AsciiDoc import qualified Tests.Writers.Docx @@ -41,6 +42,7 @@ tests = [ Tests.Command.tests , testGroup "HTML" Tests.Writers.HTML.tests , testGroup "Docbook" Tests.Writers.Docbook.tests , testGroup "Markdown" Tests.Writers.Markdown.tests + , testGroup "Org" Tests.Writers.Org.tests , testGroup "Plain" Tests.Writers.Plain.tests , testGroup "AsciiDoc" Tests.Writers.AsciiDoc.tests , testGroup "Docx" Tests.Writers.Docx.tests |