git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #3438 from ilabdsf/org-anchor-links

Org anchor links

commit64ad6ff8d9aed32198763411f8bf6019aac21805 authorAlbert Krewinkel <albert+github@zeitkraut.de> dateSun 12 Feb 2017, 16:50 (10 years ago) parent48c78719e3f5a5
4 files changed+29−1
pandoc.cabal+1 src/Text/Pandoc/Writers/Org.hs+1−1 test/Tests/Writers/Org.hs+25 test/test-pandoc.hs+2
pandoc.cabal+1
@@ -530,6 +530,7 @@ Test-Suite test-pandoc
530530 Tests.Writers.Docbook
531531 Tests.Writers.HTML
532532 Tests.Writers.Markdown
533+ Tests.Writers.Org
533534 Tests.Writers.Plain
534535 Tests.Writers.AsciiDoc
535536 Tests.Writers.LaTeX
src/Text/Pandoc/Writers/Org.hs+1−1
@@ -374,7 +374,7 @@ orgPath :: String -> String
374374orgPath src =
375375 case src of
376376 [] -> mempty -- wiki link
377− ('#':xs) -> xs -- internal link
377+ ('#':_) -> src -- internal link
378378 _ | isUrl src -> src
379379 _ | isFilePath src -> src
380380 _ -> "file:" <> src
test/Tests/Writers/Org.hsnew file+25
@@ -0,0 +1,25 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+module Tests.Writers.Org (tests) where
3+
4+import Test.Framework
5+import Text.Pandoc.Builder
6+import Text.Pandoc
7+import Tests.Helpers
8+import Text.Pandoc.Arbitrary()
9+
10+infix 4 =:
11+(=:) :: (ToString a, ToPandoc a)
12+ => String -> (a, String) -> Test
13+(=:) = test (purely (writeOrg def . toPandoc))
14+
15+tests :: [Test]
16+tests = [ testGroup "links"
17+ -- See http://orgmode.org/manual/Internal-links.html#Internal-links
18+ [ "simple link"
19+ =: link "/url" "" "foo"
20+ =?> "[[/url][foo]]"
21+ , "internal link to anchor"
22+ =: link "#my-custom-id" "" "#my-custom-id"
23+ =?> "[[#my-custom-id]]"
24+ ]
25+ ]
test/test-pandoc.hs+2
@@ -21,6 +21,7 @@ import qualified Tests.Writers.HTML
2121import qualified Tests.Writers.Docbook
2222import qualified Tests.Writers.Native
2323import qualified Tests.Writers.Markdown
24+import qualified Tests.Writers.Org
2425import qualified Tests.Writers.Plain
2526import qualified Tests.Writers.AsciiDoc
2627import qualified Tests.Writers.Docx
@@ -41,6 +42,7 @@ tests = [ Tests.Command.tests
4142 , testGroup "HTML" Tests.Writers.HTML.tests
4243 , testGroup "Docbook" Tests.Writers.Docbook.tests
4344 , testGroup "Markdown" Tests.Writers.Markdown.tests
45+ , testGroup "Org" Tests.Writers.Org.tests
4446 , testGroup "Plain" Tests.Writers.Plain.tests
4547 , testGroup "AsciiDoc" Tests.Writers.AsciiDoc.tests
4648 , testGroup "Docx" Tests.Writers.Docx.tests