From c44ff4c555925e083a5debf3fdf6e2feb459be05 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 12 Nov 2010 00:38:31 -0800 Subject: Added material for citation tests. Currently they fail with a multibyte error from citeproc-hs when it tries to read locale. --- tests/RunTests.hs | 2 + tests/biblio.bib | 26 +++ tests/chicago-author-date.csl | 369 ++++++++++++++++++++++++++++++++++++++ tests/ieee.csl | 129 ++++++++++++++ tests/markdown-citations.plain | 36 ++++ tests/markdown-citations.txt | 28 +++ tests/mhra.csl | 390 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 980 insertions(+) create mode 100644 tests/biblio.bib create mode 100644 tests/chicago-author-date.csl create mode 100644 tests/ieee.csl create mode 100644 tests/markdown-citations.plain create mode 100644 tests/markdown-citations.txt create mode 100644 tests/mhra.csl (limited to 'tests') diff --git a/tests/RunTests.hs b/tests/RunTests.hs index 1715400fd..f58221846 100644 --- a/tests/RunTests.hs +++ b/tests/RunTests.hs @@ -106,6 +106,7 @@ main = do "latex-reader.latex" "latex-reader.native" r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"] "testsuite.native" "testsuite.native" + r14 <- runTest "markdown reader (citations)" ["-r", "markdown", "-w", "plain", "--biblio", "biblio.bib", "--csl", "chicago-author-date.csl"] "markdown-citations.txt" "markdown-citations.plain" r12s <- if runLhsTests then mapM runLhsWriterTest lhsWriterFormats else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return [] @@ -119,6 +120,7 @@ main = do , r9 -- html , r10 -- latex , r11 -- native + , r14 -- citations ] ++ r12s ++ r13s if all id results then do diff --git a/tests/biblio.bib b/tests/biblio.bib new file mode 100644 index 000000000..d395eb5b8 --- /dev/null +++ b/tests/biblio.bib @@ -0,0 +1,26 @@ +@Book{item1, +author="John Doe", +title="First Book", +year="2005", +address="Cambridge", +publisher="Cambridge University Press" +} + +@Article{item2, +author="John Doe", +title="Article", +year="2006", +journal="Journal of Generic Studies", +volume="6", +pages="33-34" +} + +@InCollection{item3, +author="John Doe and Jenny Roe", +title="Why Water Is Wet", +booktitle="Third Book", +editor="Sam Smith", +publisher="Oxford University PresS", +address="Oxford", +year="2007" +} diff --git a/tests/chicago-author-date.csl b/tests/chicago-author-date.csl new file mode 100644 index 000000000..f16f82305 --- /dev/null +++ b/tests/chicago-author-date.csl @@ -0,0 +1,369 @@ + + diff --git a/tests/ieee.csl b/tests/ieee.csl new file mode 100644 index 000000000..2e0af1795 --- /dev/null +++ b/tests/ieee.csl @@ -0,0 +1,129 @@ + + \ No newline at end of file diff --git a/tests/markdown-citations.plain b/tests/markdown-citations.plain new file mode 100644 index 000000000..8521e8c0b --- /dev/null +++ b/tests/markdown-citations.plain @@ -0,0 +1,36 @@ +Pandoc with citeproc-hs +======================= + +[@nonexistent] + +@nonexistent + +Doe (2005) says blah. Doe (2005, 30) says blah. Doe (2005; 2006, +30; see also Doe and Roe 2007) says blah. + +In a note.[^1] A citation group +(see Doe 2005, 34-35; also Doe and Roe 2007, chap. 3). Another one +(see Doe 2005, 34-35). And another one in a note.[^2] + +Now some modifiers.[^3] + +References +========== + +Doe, John. 2005. First Book. Cambridge: Cambridge University Press. + +---. 2006. Article. Journal of Generic Studies 6: 33-34. + +Doe, John, and Jenny Roe. 2007. Why Water Is Wet. Sam Smith Ed. +Third Book. Oxford: Oxford University Press. + +[^1]: + A citation without locators [Doe and Roe (2007)]. + +[^2]: + Some citations (see Doe 2006, chap. 3; Doe and Roe 2007; Doe + 2005). + +[^3]: + Like a citation without author: (2005), and now Doe with a + locator (2006, 44). diff --git a/tests/markdown-citations.txt b/tests/markdown-citations.txt new file mode 100644 index 000000000..59206f0a4 --- /dev/null +++ b/tests/markdown-citations.txt @@ -0,0 +1,28 @@ +# Pandoc with citeproc-hs + +[@nonexistent] + +@nonexistent + +@item1 says blah. +@item1 [p. 30] says blah. +@item1 [-@item2, p. 30; see also @item3] says blah. + +In a note.[^1] A citation group [see +@item1, p. 34-35; also @item3, chap. 3]. Another one [see +@item1, p. 34-35]. And another one in a note.[^2] + +Now some modifiers.[^3] + +[^1]: + A citation without locators [@item3]. + +[^2]: + Some citations [see @item2, chap. 3; @item3; @item1]. + +[^3]: + Like a citation without author: [-@item1], and now Doe with a + locator [-@item2, p. 44]. + +# References + diff --git a/tests/mhra.csl b/tests/mhra.csl new file mode 100644 index 000000000..4749cdcd7 --- /dev/null +++ b/tests/mhra.csl @@ -0,0 +1,390 @@ + + \ No newline at end of file -- cgit v1.2.3 From f272b81f850a61a30d72b31494c13e69170d2715 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 12 Nov 2010 18:40:16 -0800 Subject: Set LANG in test runner. --- tests/RunTests.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/RunTests.hs b/tests/RunTests.hs index f58221846..468451562 100644 --- a/tests/RunTests.hs +++ b/tests/RunTests.hs @@ -114,6 +114,7 @@ main = do then mapM runLhsReaderTest lhsReaderFormats else putStrLn "Skipping lhs reader tests because they presuppose highlighting support" >> return [] let results = r1s ++ + [ r2, r3, r4, r5 -- S5 , r6, r7, r7a -- markdown reader , r8, r8a -- rst @@ -167,7 +168,8 @@ runTest testname opts inp norm = do let normPath = norm hFlush stdout -- Note: COLUMNS must be set for markdown table reader - ph <- runProcess pandocPath (opts ++ [inpPath] ++ ["--data-dir", ".."]) Nothing (Just [("COLUMNS", "80")]) Nothing (Just hOut) (Just stderr) + ph <- runProcess pandocPath (opts ++ [inpPath] ++ ["--data-dir", ".."]) Nothing + (Just [("LANG","en_US.UTF-8"),("COLUMNS", "80")]) Nothing (Just hOut) (Just stderr) ec <- waitForProcess ph result <- if ec == ExitSuccess then do -- cgit v1.2.3 From bf4d9199895091998fd130e0c20551815d07df99 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 12 Nov 2010 18:46:34 -0800 Subject: Improvements to test suite for citations. --- tests/biblio.bib | 2 +- tests/markdown-citations.plain | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/biblio.bib b/tests/biblio.bib index d395eb5b8..755d535a8 100644 --- a/tests/biblio.bib +++ b/tests/biblio.bib @@ -20,7 +20,7 @@ author="John Doe and Jenny Roe", title="Why Water Is Wet", booktitle="Third Book", editor="Sam Smith", -publisher="Oxford University PresS", +publisher="Oxford University Press", address="Oxford", year="2007" } diff --git a/tests/markdown-citations.plain b/tests/markdown-citations.plain index 8521e8c0b..35218d954 100644 --- a/tests/markdown-citations.plain +++ b/tests/markdown-citations.plain @@ -17,12 +17,13 @@ Now some modifiers.[^3] References ========== -Doe, John. 2005. First Book. Cambridge: Cambridge University Press. +Doe, John. 2005. First Book. Cambridge: Cambridge University +Press. ---. 2006. Article. Journal of Generic Studies 6: 33-34. -Doe, John, and Jenny Roe. 2007. Why Water Is Wet. Sam Smith Ed. -Third Book. Oxford: Oxford University Press. +Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In Third Book, +ed. Sam Smith. Oxford: Oxford University Press. [^1]: A citation without locators [Doe and Roe (2007)]. -- cgit v1.2.3 From 1fa2973da690ba81a80337d9d3f0f6e2c786b602 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 12 Nov 2010 19:30:59 -0800 Subject: Repairs to citation parser + citation test suite. --- src/Text/Pandoc/Readers/Markdown.hs | 16 ++++++++-------- tests/markdown-citations.plain | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index eb9646df2..0d0e850bc 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1332,9 +1332,9 @@ textualCite = try $ do spnl char '[' spnl - bareloc <- option "" locator + bareloc <- option "" $ notFollowedBy (oneOf "-@") >> locator rest <- many $ try $ do - char ';' + optional $ char ';' spnl citation spnl @@ -1366,10 +1366,10 @@ locator = try $ do (char '\n' >> notFollowedBy blankline >> return ' ') prefix :: GenParser Char st String -prefix = try $ liftM removeLeadingTrailingSpace $ - many $ (char '\\' >> anyChar) <|> noneOf "@]\n" <|> - (char '-' >> notFollowedBy (char '@') >> return '-') <|> - (char '\n' >> notFollowedBy blankline >> return ' ') +prefix = liftM removeLeadingTrailingSpace $ + many $ (char '\\' >> anyChar) <|> noneOf "-@]\n" <|> + (try $ char '-' >> notFollowedBy (char '@') >> return '-') <|> + (try $ char '\n' >> notFollowedBy blankline >> return ' ') citeList :: GenParser Char st [Citation] citeList = try $ do @@ -1387,10 +1387,10 @@ citeList = try $ do citation :: GenParser Char st Citation citation = try $ do - suppress_auth <- option False (char '-' >> return True) pref <- prefix + suppress_auth <- option False (char '-' >> return True) key <- citeKey - loc <- locator + loc <- option "" locator return $ Citation{ citationId = key , citationPrefix = pref , citationLocator = loc diff --git a/tests/markdown-citations.plain b/tests/markdown-citations.plain index 35218d954..b809842be 100644 --- a/tests/markdown-citations.plain +++ b/tests/markdown-citations.plain @@ -5,8 +5,8 @@ Pandoc with citeproc-hs @nonexistent -Doe (2005) says blah. Doe (2005, 30) says blah. Doe (2005; 2006, -30; see also Doe and Roe 2007) says blah. +Doe (2005) says blah. Doe (2005, 30) says blah. Doe +(2005; 2006, 30; see also Doe and Roe 2007) says blah. In a note.[^1] A citation group (see Doe 2005, 34-35; also Doe and Roe 2007, chap. 3). Another one @@ -26,12 +26,12 @@ Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In Third Book, ed. Sam Smith. Oxford: Oxford University Press. [^1]: - A citation without locators [Doe and Roe (2007)]. + A citation without locators (Doe and Roe 2007). [^2]: - Some citations (see Doe 2006, chap. 3; Doe and Roe 2007; Doe - 2005). + Some citations + (see Doe 2006, chap. 3; Doe and Roe 2007; Doe 2005). [^3]: - Like a citation without author: (2005), and now Doe with a - locator (2006, 44). + Like a citation without author: (2005), and now Doe with a locator + (2006, 44). -- cgit v1.2.3 From 7aecddd0f7c22ed2beb1ccf268d3b0e8b2d08831 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 13 Nov 2010 08:42:09 -0800 Subject: Replaced --biblio-file with --bibliography, removed --biblio-format. Bibliography format is guessed from the file extension of the bibliography. Also, the bibliography entries are now read during option parsing. --- src/pandoc.hs | 27 +++++++++------------------ tests/RunTests.hs | 2 +- 2 files changed, 10 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/src/pandoc.hs b/src/pandoc.hs index 349d86ca2..d6b40cc94 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -163,8 +163,7 @@ data Opt = Opt , optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks , optDataDir :: Maybe FilePath #ifdef _CITEPROC - , optBiblioFile :: String - , optBiblioFormat :: String + , optBibliography :: [Reference] , optCslFile :: String #endif } @@ -205,8 +204,7 @@ defaultOpts = Opt , optIndentedCodeClasses = [] , optDataDir = Nothing #ifdef _CITEPROC - , optBiblioFile = [] - , optBiblioFormat = [] + , optBibliography = [] , optCslFile = [] #endif } @@ -520,16 +518,14 @@ options = "FORMAT") "" -- "Print default template for FORMAT" #ifdef _CITEPROC - , Option "" ["biblio"] + , Option "" ["bibliography"] (ReqArg - (\arg opt -> return opt { optBiblioFile = arg} ) + (\arg opt -> do + refs <- readBiblioFile arg "" + return opt { optBibliography = + optBibliography opt ++ refs } ) "FILENAME") "" - , Option "" ["biblio-format"] - (ReqArg - (\arg opt -> return opt { optBiblioFormat = arg} ) - "STRING") - "" , Option "" ["csl"] (ReqArg (\arg opt -> return opt { optCslFile = arg} ) @@ -684,9 +680,8 @@ main = do , optIndentedCodeClasses = codeBlockClasses , optDataDir = mbDataDir #ifdef _CITEPROC - , optBiblioFile = biblioFile - , optBiblioFormat = biblioFormat - , optCslFile = cslFile + , optBibliography = refs + , optCslFile = cslFile #endif } = opts @@ -746,10 +741,6 @@ main = do let standalone' = standalone || isNonTextOutput writerName' -#ifdef _CITEPROC - refs <- if null biblioFile then return [] else readBiblioFile biblioFile biblioFormat -#endif - variables' <- case (writerName', standalone', offline) of ("s5", True, True) -> do inc <- s5HeaderIncludes datadir diff --git a/tests/RunTests.hs b/tests/RunTests.hs index 468451562..688731317 100644 --- a/tests/RunTests.hs +++ b/tests/RunTests.hs @@ -106,7 +106,7 @@ main = do "latex-reader.latex" "latex-reader.native" r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"] "testsuite.native" "testsuite.native" - r14 <- runTest "markdown reader (citations)" ["-r", "markdown", "-w", "plain", "--biblio", "biblio.bib", "--csl", "chicago-author-date.csl"] "markdown-citations.txt" "markdown-citations.plain" + r14 <- runTest "markdown reader (citations)" ["-r", "markdown", "-w", "plain", "--bibliography", "biblio.bib", "--csl", "chicago-author-date.csl"] "markdown-citations.txt" "markdown-citations.plain" r12s <- if runLhsTests then mapM runLhsWriterTest lhsWriterFormats else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return [] -- cgit v1.2.3 From aaf7de0ddaea292ba4e869a6f0fa5adaaf02b813 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 18 Nov 2010 12:38:45 -0800 Subject: Markdown reader: Revised parser for new citation syntax. Suffixes and prefixes are now [Inline]. The locator is separated from the citation key by a blank space. The locator consists of one introductory word and any number of words containing at least one digit. The suffix, if any, is separated from the locator by a comma, and continues til the end of the citation. --- src/Text/Pandoc/Readers/Markdown.hs | 129 ++++++++++++++++++++---------------- tests/markdown-citations.txt | 10 +-- 2 files changed, 78 insertions(+), 61 deletions(-) (limited to 'tests') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 4975ee02f..b0aab9c70 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -34,7 +34,7 @@ module Text.Pandoc.Readers.Markdown ( import Data.List ( transpose, isSuffixOf, sortBy, findIndex, intercalate ) import qualified Data.Map as M import Data.Ord ( comparing ) -import Data.Char ( isAlphaNum ) +import Data.Char ( isAlphaNum, isDigit ) import Data.Maybe import Text.Pandoc.Definition import Text.Pandoc.Shared @@ -1309,15 +1309,25 @@ rawHtmlInline' = do cite :: GenParser Char ParserState Inline cite = do failIfStrict - textualCite <|> normalCite + citations <- textualCite <|> normalCite + return $ Cite citations [] spnl :: GenParser Char st () -spnl = try $ skipSpaces >> optional newline >> skipSpaces >> - notFollowedBy (char '\n') +spnl = try $ do + skipSpaces + optional newline + skipSpaces + notFollowedBy (char '\n') -textualCite :: GenParser Char ParserState Inline +blankSpace :: GenParser Char st () +blankSpace = try $ do + res <- many1 $ oneOf " \t\n" + guard $ length res > 0 + guard $ length (filter (=='\n') res) <= 1 + +textualCite :: GenParser Char ParserState [Citation] textualCite = try $ do - key <- citeKey + (_, key) <- citeKey st <- getState unless (key `elem` stateCitations st) $ fail "not a citation" @@ -1329,73 +1339,80 @@ textualCite = try $ do , citationNoteNum = 0 , citationHash = 0 } - option (Cite [first] []) $ try $ do - spnl - char '[' - spnl - bareloc <- option "" $ notFollowedBy (oneOf "-@") >> locator - rest <- many $ try $ do - optional $ char ';' - spnl - citation - spnl - char ']' - let first' = if null bareloc - then first - else first{ citationLocator = bareloc - , citationMode = AuthorInText } - return $ Cite (first' : rest) [] - -normalCite :: GenParser Char ParserState Inline + rest <- option [] $ try $ spnl >> normalCite + if null rest + then option [first] $ bareloc first + else return $ first : rest + +bareloc :: Citation -> GenParser Char ParserState [Citation] +bareloc c = try $ do + spnl + char '[' + spnl + loc <- locator + spnl + rest <- option [] $ try $ char ';' >> citeList + spnl + char ']' + return $ c{ citationLocator = loc } : rest + +normalCite :: GenParser Char ParserState [Citation] normalCite = try $ do - cites <- citeList - return $ Cite cites [] + char '[' + spnl + citations <- citeList + spnl + char ']' + return citations -citeKey :: GenParser Char st String +citeKey :: GenParser Char st (Bool, String) citeKey = try $ do + suppress_author <- option False (char '-' >> return True) char '@' first <- letter - rest <- many $ noneOf ",;]@ \t\n" - return (first:rest) + rest <- many $ (noneOf ",;]@ \t\n") + return (suppress_author, first:rest) locator :: GenParser Char st String locator = try $ do - optional $ char ',' spnl - many1 $ (char '\\' >> oneOf "];\n") <|> noneOf "];\n" <|> - (char '\n' >> notFollowedBy blankline >> return ' ') - -prefix :: GenParser Char st String -prefix = liftM removeLeadingTrailingSpace $ - many $ (char '\\' >> anyChar) <|> noneOf "-@]\n" <|> - (try $ char '-' >> notFollowedBy (char '@') >> return '-') <|> - (try $ char '\n' >> notFollowedBy blankline >> return ' ') - -citeList :: GenParser Char st [Citation] -citeList = try $ do - char '[' + w <- many1 (noneOf " \t\n;]") spnl - first <- citation + ws <- many locatorWord + return $ unwords $ w:ws + +locatorWord :: GenParser Char st String +locatorWord = try $ do + wd <- many1 $ (try $ char '\\' >> oneOf "]; \t\n") <|> noneOf "]; \t\n" spnl - rest <- many $ try $ do - char ';' - spnl - citation + if any isDigit wd + then return wd + else pzero + +suffix :: GenParser Char ParserState [Inline] +suffix = try $ do + char ',' spnl - char ']' - return (first:rest) + liftM normalizeSpaces $ many $ notFollowedBy (oneOf ";]") >> inline + +prefix :: GenParser Char ParserState [Inline] +prefix = liftM normalizeSpaces $ + manyTill inline (lookAhead citeKey) + +citeList :: GenParser Char ParserState [Citation] +citeList = sepBy1 citation (try $ char ';' >> spnl) -citation :: GenParser Char st Citation +citation :: GenParser Char ParserState Citation citation = try $ do pref <- prefix - suppress_auth <- option False (char '-' >> return True) - key <- citeKey - loc <- option "" locator + (suppress_author, key) <- citeKey + loc <- option "" $ try $ blankSpace >> locator + suff <- option [] suffix return $ Citation{ citationId = key - , citationPrefix = if pref /= [] then [Str pref] else [] - , citationSuffix = [] + , citationPrefix = pref + , citationSuffix = suff , citationLocator = loc - , citationMode = if suppress_auth + , citationMode = if suppress_author then SuppressAuthor else NormalCitation , citationNoteNum = 0 diff --git a/tests/markdown-citations.txt b/tests/markdown-citations.txt index 59206f0a4..9840832ce 100644 --- a/tests/markdown-citations.txt +++ b/tests/markdown-citations.txt @@ -6,11 +6,11 @@ @item1 says blah. @item1 [p. 30] says blah. -@item1 [-@item2, p. 30; see also @item3] says blah. +@item1 [-@item2 p. 30; see also @item3] says blah. In a note.[^1] A citation group [see -@item1, p. 34-35; also @item3, chap. 3]. Another one [see -@item1, p. 34-35]. And another one in a note.[^2] +@item1 p. 34-35; also @item3 chap. 3]. Another one [see +@item1 p. 34-35]. And another one in a note.[^2] Now some modifiers.[^3] @@ -18,11 +18,11 @@ Now some modifiers.[^3] A citation without locators [@item3]. [^2]: - Some citations [see @item2, chap. 3; @item3; @item1]. + Some citations [see @item2 chap. 3; @item3; @item1]. [^3]: Like a citation without author: [-@item1], and now Doe with a - locator [-@item2, p. 44]. + locator [-@item2 p. 44]. # References -- cgit v1.2.3 From f3bb3c1ff1c85ea3bc9132b4c890905a9af20c3a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 18 Nov 2010 13:22:20 -0800 Subject: Markdown citation parser improvements and test updates. Now we handle a suffix after a bare locator, e.g. @item1 [p. 30, suffix] The suffix now includes any punctuation that introduces it. A few tests fail because of problems with citeproc (extra space before the suffix, missing space after comma separating multiple page ranges in the locator). --- src/Text/Pandoc/Readers/Markdown.hs | 28 +++++++++++++++------------- tests/markdown-citations.plain | 8 +++++--- tests/markdown-citations.txt | 4 ++++ 3 files changed, 24 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index b0aab9c70..851cf25e7 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1348,13 +1348,12 @@ bareloc :: Citation -> GenParser Char ParserState [Citation] bareloc c = try $ do spnl char '[' - spnl loc <- locator - spnl + suff <- suffix rest <- option [] $ try $ char ';' >> citeList spnl char ']' - return $ c{ citationLocator = loc } : rest + return $ c{ citationLocator = loc, citationSuffix = suff } : rest normalCite :: GenParser Char ParserState [Citation] normalCite = try $ do @@ -1376,28 +1375,31 @@ citeKey = try $ do locator :: GenParser Char st String locator = try $ do spnl - w <- many1 (noneOf " \t\n;]") - spnl - ws <- many locatorWord + w <- many1 (noneOf " \t\n;,]") + ws <- many (locatorWord <|> locatorComma) return $ unwords $ w:ws locatorWord :: GenParser Char st String locatorWord = try $ do - wd <- many1 $ (try $ char '\\' >> oneOf "]; \t\n") <|> noneOf "]; \t\n" spnl - if any isDigit wd - then return wd - else pzero + wd <- many1 $ (try $ char '\\' >> oneOf "];, \t\n") <|> noneOf "];, \t\n" + guard $ any isDigit wd + return wd + +locatorComma :: GenParser Char st String +locatorComma = try $ do + char ',' + lookAhead $ locatorWord + return "," suffix :: GenParser Char ParserState [Inline] suffix = try $ do - char ',' spnl liftM normalizeSpaces $ many $ notFollowedBy (oneOf ";]") >> inline prefix :: GenParser Char ParserState [Inline] prefix = liftM normalizeSpaces $ - manyTill inline (lookAhead citeKey) + manyTill inline (char ']' <|> liftM (const ']') (lookAhead citeKey)) citeList :: GenParser Char ParserState [Citation] citeList = sepBy1 citation (try $ char ';' >> spnl) @@ -1407,7 +1409,7 @@ citation = try $ do pref <- prefix (suppress_author, key) <- citeKey loc <- option "" $ try $ blankSpace >> locator - suff <- option [] suffix + suff <- suffix return $ Citation{ citationId = key , citationPrefix = pref , citationSuffix = suff diff --git a/tests/markdown-citations.plain b/tests/markdown-citations.plain index b809842be..dd5d23efc 100644 --- a/tests/markdown-citations.plain +++ b/tests/markdown-citations.plain @@ -5,12 +5,14 @@ Pandoc with citeproc-hs @nonexistent -Doe (2005) says blah. Doe (2005, 30) says blah. Doe -(2005; 2006, 30; see also Doe and Roe 2007) says blah. +Doe (2005) says blah. Doe (2005, 30) says blah. Doe (2005, 30, suffix) +says blah. Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah. In a note.[^1] A citation group (see Doe 2005, 34-35; also Doe and Roe 2007, chap. 3). Another one -(see Doe 2005, 34-35). And another one in a note.[^2] +(see Doe 2005, 34-35). And another one in a note.[^2] Citation with +a suffix and locator (Doe 2005, 33, 35-37, and nowhere else). +Citation with suffix only (Doe 2005, and nowhere else). Now some modifiers.[^3] diff --git a/tests/markdown-citations.txt b/tests/markdown-citations.txt index 9840832ce..c54a41304 100644 --- a/tests/markdown-citations.txt +++ b/tests/markdown-citations.txt @@ -6,11 +6,15 @@ @item1 says blah. @item1 [p. 30] says blah. +@item1 [p. 30, with suffix] says blah. @item1 [-@item2 p. 30; see also @item3] says blah. In a note.[^1] A citation group [see @item1 p. 34-35; also @item3 chap. 3]. Another one [see @item1 p. 34-35]. And another one in a note.[^2] +Citation with a suffix and locator [@item1 pp. 33, 35-37, +and nowhere else]. Citation with suffix only +[@item1, and nowhere else]. Now some modifiers.[^3] -- cgit v1.2.3 From 8e71b5b2792a4d6a4ec878de07a729c90709370d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 21 Nov 2010 09:30:32 -0800 Subject: Updated markdown-citations test for new citeproc changes. --- tests/markdown-citations.plain | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/markdown-citations.plain b/tests/markdown-citations.plain index dd5d23efc..a834e566b 100644 --- a/tests/markdown-citations.plain +++ b/tests/markdown-citations.plain @@ -5,8 +5,9 @@ Pandoc with citeproc-hs @nonexistent -Doe (2005) says blah. Doe (2005, 30) says blah. Doe (2005, 30, suffix) -says blah. Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah. +Doe (2005) says blah. Doe (2005, 30) says blah. Doe +(2005, 30, with suffix) says blah. Doe +(2005; 2006, 30; see also Doe and Roe 2007) says blah. In a note.[^1] A citation group (see Doe 2005, 34-35; also Doe and Roe 2007, chap. 3). Another one -- cgit v1.2.3 From 3c7c1d8574667d183514d87684edd5f1cd886509 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 22 Nov 2010 22:54:40 -0800 Subject: Changed markdown citation tests. Now the tests are produced in HTML format (so we can see all formatting). Also, we produce them in three different style, chicago-author-date, ieee, and mhra. --- tests/RunTests.hs | 5 +- tests/markdown-citations.chicago-author-date.html | 56 ++++++++++ tests/markdown-citations.ieee.html | 56 ++++++++++ tests/markdown-citations.mhra.html | 126 ++++++++++++++++++++++ tests/markdown-citations.plain | 40 ------- 5 files changed, 240 insertions(+), 43 deletions(-) create mode 100644 tests/markdown-citations.chicago-author-date.html create mode 100644 tests/markdown-citations.ieee.html create mode 100644 tests/markdown-citations.mhra.html delete mode 100644 tests/markdown-citations.plain (limited to 'tests') diff --git a/tests/RunTests.hs b/tests/RunTests.hs index 688731317..2fa89bfeb 100644 --- a/tests/RunTests.hs +++ b/tests/RunTests.hs @@ -106,7 +106,7 @@ main = do "latex-reader.latex" "latex-reader.native" r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"] "testsuite.native" "testsuite.native" - r14 <- runTest "markdown reader (citations)" ["-r", "markdown", "-w", "plain", "--bibliography", "biblio.bib", "--csl", "chicago-author-date.csl"] "markdown-citations.txt" "markdown-citations.plain" + r14s <- mapM (\style -> runTest ("markdown reader (citations) (" ++ style ++ ")") ["-r", "markdown", "-w", "html", "--bibliography", "biblio.bib", "--csl", style ++ ".csl"] "markdown-citations.txt" ("markdown-citations." ++ style ++ ".html")) ["chicago-author-date","ieee","mhra"] r12s <- if runLhsTests then mapM runLhsWriterTest lhsWriterFormats else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return [] @@ -121,8 +121,7 @@ main = do , r9 -- html , r10 -- latex , r11 -- native - , r14 -- citations - ] ++ r12s ++ r13s + ] ++ r12s ++ r13s ++ r14s if all id results then do putStrLn "\nAll tests passed." diff --git a/tests/markdown-citations.chicago-author-date.html b/tests/markdown-citations.chicago-author-date.html new file mode 100644 index 000000000..92ee8d770 --- /dev/null +++ b/tests/markdown-citations.chicago-author-date.html @@ -0,0 +1,56 @@ +

Pandoc with citeproc-hs

[@nonexistent]

@nonexistent

Doe (2005) says blah. Doe (2005, 30) says blah. Doe (2005, 30, with suffix) says blah. Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah.

In a note.1 A citation group (see Doe 2005, 34-35; also Doe and Roe 2007, chap. 3). Another one (see Doe 2005, 34-35). And another one in a note.2 Citation with a suffix and locator (Doe 2005, 33, 35-37, and nowhere else). Citation with suffix only (Doe 2005, and nowhere else).

Now some modifiers.3

References

Doe, John. 2005. First Book. Cambridge: Cambridge University Press.

---. 2006. Article. Journal of Generic Studies 6: 33-34.

Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In Third Book, ed. Sam Smith. Oxford: Oxford University Press.


  1. A citation without locators (Doe and Roe 2007).

  2. Some citations (see Doe 2006, chap. 3; Doe and Roe 2007; Doe 2005).

  3. Like a citation without author: (2005), and now Doe with a locator (2006, 44).

diff --git a/tests/markdown-citations.ieee.html b/tests/markdown-citations.ieee.html new file mode 100644 index 000000000..a4b3922c0 --- /dev/null +++ b/tests/markdown-citations.ieee.html @@ -0,0 +1,56 @@ +

Pandoc with citeproc-hs

[@nonexistent]

@nonexistent

Reference [1] says blah. Reference [1] says blah. Reference [1] says blah. Reference [1] says blah.

In a note.1 A citation group [1],[3]. Another one [1]. And another one in a note.2 Citation with a suffix and locator [1]. Citation with suffix only [1].

Now some modifiers.3

References

[1] J. Doe, First Book, Cambridge: Cambridge University Press, 2005.

[2] J. Doe, “Article”, Journal of Generic Studies, vol. 6, 2006, pp. 33-34.

[3] J. Doe and J. Roe, “Why Water Is Wet”, Third Book, Smith, S., Ed., Oxford: Oxford University Press, 2007.


  1. A citation without locators [3].

  2. Some citations [1]-[3].

  3. Like a citation without author: [1], and now Doe with a locator [2].

diff --git a/tests/markdown-citations.mhra.html b/tests/markdown-citations.mhra.html new file mode 100644 index 000000000..6572291d9 --- /dev/null +++ b/tests/markdown-citations.mhra.html @@ -0,0 +1,126 @@ +

Pandoc with citeproc-hs

[@nonexistent]

@nonexistent

John Doe1 says blah. Doe2 says blah. Doe3 says blah. Doe4 says blah.

In a note.5 A citation group.6 Another one.7 And another one in a note.8 Citation with a suffix and locator.9 Citation with suffix only.10

Now some modifiers.11

References

Doe, John, ‘Article’, Journal of Generic Studies, 6 (2006), 33-34.

---, First Book (Cambridge: Cambridge University Press, 2005).

Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in Third Book, ed by Sam Smith (Oxford: Oxford University Press, 2007).


  1. First Book (Cambridge: Cambridge University Press, 2005).

  2. First Book, p. 30.

  3. First Book, p. 30, with suffix.

  4. First Book; ‘Article’, Journal of Generic Studies, 6 (2006), 33-34 (p. 30); see also John Doe and Jenny Roe, ‘Why Water Is Wet’, in Third Book, ed by Sam Smith (Oxford: Oxford University Press, 2007).

  5. A citation without locators Doe and Roe.

  6. See Doe, First Book, pp. 34-35; also Doe and Roe, chap. 3.

  7. See Doe, First Book, pp. 34-35.

  8. Some citations see Doe, Article, 33-34 (chap. 3); Doe and Roe; Doe, First Book.

  9. Doe, First Book, pp. 33, 35-37, and nowhere else.

  10. Doe, First Book, and nowhere else.

  11. Like a citation without author: First Book, and now Doe with a locator Article, 33-34 (p. 44).

diff --git a/tests/markdown-citations.plain b/tests/markdown-citations.plain deleted file mode 100644 index a834e566b..000000000 --- a/tests/markdown-citations.plain +++ /dev/null @@ -1,40 +0,0 @@ -Pandoc with citeproc-hs -======================= - -[@nonexistent] - -@nonexistent - -Doe (2005) says blah. Doe (2005, 30) says blah. Doe -(2005, 30, with suffix) says blah. Doe -(2005; 2006, 30; see also Doe and Roe 2007) says blah. - -In a note.[^1] A citation group -(see Doe 2005, 34-35; also Doe and Roe 2007, chap. 3). Another one -(see Doe 2005, 34-35). And another one in a note.[^2] Citation with -a suffix and locator (Doe 2005, 33, 35-37, and nowhere else). -Citation with suffix only (Doe 2005, and nowhere else). - -Now some modifiers.[^3] - -References -========== - -Doe, John. 2005. First Book. Cambridge: Cambridge University -Press. - ----. 2006. Article. Journal of Generic Studies 6: 33-34. - -Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In Third Book, -ed. Sam Smith. Oxford: Oxford University Press. - -[^1]: - A citation without locators (Doe and Roe 2007). - -[^2]: - Some citations - (see Doe 2006, chap. 3; Doe and Roe 2007; Doe 2005). - -[^3]: - Like a citation without author: (2005), and now Doe with a locator - (2006, 44). -- cgit v1.2.3 From be909d2bfc31390af22530ce39cdc52c14eea388 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 22 Nov 2010 23:10:00 -0800 Subject: Fixed eol mistake in test. --- tests/markdown-citations.ieee.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/markdown-citations.ieee.html b/tests/markdown-citations.ieee.html index a4b3922c0..753ebe82e 100644 --- a/tests/markdown-citations.ieee.html +++ b/tests/markdown-citations.ieee.html @@ -53,4 +53,4 @@ > +> \ No newline at end of file -- cgit v1.2.3 From e8516ff33774531c14ff22f39c1618f594b11fe9 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 26 Nov 2010 11:48:22 -0800 Subject: Set HOME in RunTests. Patch from Nathan Gass. --- tests/RunTests.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/RunTests.hs b/tests/RunTests.hs index 2fa89bfeb..d6259ffaf 100644 --- a/tests/RunTests.hs +++ b/tests/RunTests.hs @@ -168,7 +168,7 @@ runTest testname opts inp norm = do hFlush stdout -- Note: COLUMNS must be set for markdown table reader ph <- runProcess pandocPath (opts ++ [inpPath] ++ ["--data-dir", ".."]) Nothing - (Just [("LANG","en_US.UTF-8"),("COLUMNS", "80")]) Nothing (Just hOut) (Just stderr) + (Just [("LANG","en_US.UTF-8"),("COLUMNS", "80"),("HOME", "./")]) Nothing (Just hOut) (Just stderr) ec <- waitForProcess ph result <- if ec == ExitSuccess then do -- cgit v1.2.3 From 8f1aed168b8cae43f3fb7a4303ceea4792b8a45b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 27 Nov 2010 11:27:52 -0800 Subject: Removed extra line break from citation test output. --- tests/markdown-citations.chicago-author-date.html | 2 +- tests/markdown-citations.mhra.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/markdown-citations.chicago-author-date.html b/tests/markdown-citations.chicago-author-date.html index 92ee8d770..1d3809c83 100644 --- a/tests/markdown-citations.chicago-author-date.html +++ b/tests/markdown-citations.chicago-author-date.html @@ -53,4 +53,4 @@ > +> \ No newline at end of file diff --git a/tests/markdown-citations.mhra.html b/tests/markdown-citations.mhra.html index 6572291d9..76ca1b2ef 100644 --- a/tests/markdown-citations.mhra.html +++ b/tests/markdown-citations.mhra.html @@ -123,4 +123,4 @@ > +> \ No newline at end of file -- cgit v1.2.3 From e2e107cbeda11b88f9477003a89802b9eb654a09 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 27 Nov 2010 19:20:06 -0800 Subject: Fixed spacing in ieee citation test. (Test now fails pending citeproc update.) --- tests/markdown-citations.ieee.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/markdown-citations.ieee.html b/tests/markdown-citations.ieee.html index 753ebe82e..bf8955940 100644 --- a/tests/markdown-citations.ieee.html +++ b/tests/markdown-citations.ieee.html @@ -5,7 +5,7 @@ >

@nonexistent

Reference [1] says blah. Reference [1] says blah. Reference [1] says blah. Reference [1] says blah.

Reference [1] says blah. Reference [1] says blah. Reference [1] says blah. Reference [1] says blah.

In a note. \ No newline at end of file +> -- cgit v1.2.3 From b10e82c9fa9a2284a3eb9ff3bc1334ed15d45a26 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 28 Nov 2010 07:55:33 -0800 Subject: Fixed spacing bug for reference-style citations. --- src/Text/Pandoc/Biblio.hs | 5 ++++- tests/markdown-citations.ieee.html | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs index efaafd77d..0241b2d6d 100644 --- a/src/Text/Pandoc/Biblio.hs +++ b/src/Text/Pandoc/Biblio.hs @@ -71,7 +71,10 @@ processCite s cs (i:is) addNt t x = if null x then [] else [Cite t $ renderPandoc s x] process t = case M.lookup t cs of Just x -> if isTextualCitation t && x /= [] - then renderPandoc s [head x] ++ [Space] ++ addNt t (tail x) + then renderPandoc s [head x] ++ + if tail x /= [] + then Space : addNt t (tail x) + else [] else [Cite t $ renderPandoc s x] Nothing -> [Str ("Error processing " ++ show t)] diff --git a/tests/markdown-citations.ieee.html b/tests/markdown-citations.ieee.html index bf8955940..d25a60ca0 100644 --- a/tests/markdown-citations.ieee.html +++ b/tests/markdown-citations.ieee.html @@ -53,4 +53,4 @@ > +> \ No newline at end of file -- cgit v1.2.3 From b2e9f64984562ae5a6c33f5186fe5e515c4d5890 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 28 Nov 2010 08:10:01 -0800 Subject: Updated citation tests to use en-dash between ranges. --- tests/markdown-citations.chicago-author-date.html | 6 +++--- tests/markdown-citations.ieee.html | 2 +- tests/markdown-citations.mhra.html | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/markdown-citations.chicago-author-date.html b/tests/markdown-citations.chicago-author-date.html index 1d3809c83..8f01bc980 100644 --- a/tests/markdown-citations.chicago-author-date.html +++ b/tests/markdown-citations.chicago-author-date.html @@ -11,11 +11,11 @@ >1 A citation group (see Doe 2005, 34-35; also Doe and Roe 2007, chap. 3). Another one (see Doe 2005, 34-35). And another one in a note. A citation group (see Doe 2005, 34–35; also Doe and Roe 2007, chap. 3). Another one (see Doe 2005, 34–35). And another one in a note.2 Citation with a suffix and locator (Doe 2005, 33, 35-37, and nowhere else). Citation with suffix only (Doe 2005, and nowhere else).

Citation with a suffix and locator (Doe 2005, 33, 35–37, and nowhere else). Citation with suffix only (Doe 2005, and nowhere else).

Now some modifiers.

---. 2006. Article. Journal of Generic Studies 6: 33-34.

6: 33–34.

Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In Third Book

[2] J. Doe, “Article”, Journal of Generic Studies, vol. 6, 2006, pp. 33-34.

, vol. 6, 2006, pp. 33–34.

[3] J. Doe and J. Roe, “Why Water Is Wet”, Third Book

Doe, John, ‘Article’, Journal of Generic Studies, 6 (2006), 33-34.

, 6 (2006), 33–34.

---, First Book

First Book; ‘Article’, Journal of Generic Studies, 6 (2006), 33-34 (p. 30); see also John Doe and Jenny Roe, ‘Why Water Is Wet’, in , 6 (2006), 33–34 (p. 30); see also John Doe and Jenny Roe, ‘Why Water Is Wet’, in Third Book, ed by Sam Smith (Oxford: Oxford University Press, 2007).

  • See Doe, First Book, pp. 34-35; also Doe and Roe, chap. 3.

    See Doe, First Book, pp. 34–35; also Doe and Roe, chap. 3.

  • See Doe, First Book, pp. 34-35.

    See Doe, First Book, pp. 34–35.

  • Some citations see Doe, Article, 33-34 (chap. 3); Doe and Roe; Doe, First Book.

    Some citations see Doe, Article, 33–34 (chap. 3); Doe and Roe; Doe, First Book.

  • Doe, First Book, pp. 33, 35-37, and nowhere else.

    Doe, First Book, pp. 33, 35–37, and nowhere else.

  • Like a citation without author: First Book, and now Doe with a locator Article, 33-34 (p. 44).

    Like a citation without author: First Book, and now Doe with a locator Article, 33–34 (p. 44).

  • \ No newline at end of file +> -- cgit v1.2.3 From 61b16116ce3c2ea672a753063f0fda89d32e3d1e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 28 Nov 2010 08:12:32 -0800 Subject: Citation tests: removed spurious double-spaces. --- tests/markdown-citations.chicago-author-date.html | 6 +++--- tests/markdown-citations.ieee.html | 8 ++++---- tests/markdown-citations.mhra.html | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/markdown-citations.chicago-author-date.html b/tests/markdown-citations.chicago-author-date.html index 8f01bc980..05434493f 100644 --- a/tests/markdown-citations.chicago-author-date.html +++ b/tests/markdown-citations.chicago-author-date.html @@ -25,7 +25,7 @@ >

    References

    Doe, John. 2005. Doe, John. 2005. First Book. Cambridge: Cambridge University Press.

    Journal of Generic Studies 6: 33–34.

    Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In Third Book, ed. Sam Smith. Oxford: Oxford University Press.

    \ No newline at end of file +> diff --git a/tests/markdown-citations.ieee.html b/tests/markdown-citations.ieee.html index 7c7d811ff..f076a4675 100644 --- a/tests/markdown-citations.ieee.html +++ b/tests/markdown-citations.ieee.html @@ -27,15 +27,15 @@ >

    [1] J. Doe, First Book, Cambridge: Cambridge University Press, 2005.

    , Cambridge: Cambridge University Press, 2005.

    [2] J. Doe, “Article”, Journal of Generic Studies, vol. 6, 2006, pp. 33–34.

    , vol. 6, 2006, pp. 33–34.

    [3] J. Doe and J. Roe, “Why Water Is Wet”, Third Book, Smith, S., Ed., Oxford: Oxford University Press, 2007.

    , Smith, S., Ed., Oxford: Oxford University Press, 2007.


      \ No newline at end of file +> diff --git a/tests/markdown-citations.mhra.html b/tests/markdown-citations.mhra.html index 29c69d1a9..2964ed8b7 100644 --- a/tests/markdown-citations.mhra.html +++ b/tests/markdown-citations.mhra.html @@ -57,7 +57,7 @@ >

      References

      Doe, John, ‘Article’, Doe, John, ‘Article’, Journal of Generic Studies, 6 (2006), 33–34.

      First Book (Cambridge: Cambridge University Press, 2005).

      Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in Third Book, ed by Sam Smith (Oxford: Oxford University Press, 2007).

      Date: Sun, 28 Nov 2010 10:02:40 -0800 Subject: Revamped tests, using markdown output instead of HTML. This is easier to inspect. --- tests/RunTests.hs | 2 +- tests/markdown-citations.chicago-author-date.html | 56 ---------- tests/markdown-citations.chicago-author-date.txt | 32 ++++++ tests/markdown-citations.ieee.html | 56 ---------- tests/markdown-citations.ieee.txt | 32 ++++++ tests/markdown-citations.mhra.html | 126 ---------------------- tests/markdown-citations.mhra.txt | 56 ++++++++++ tests/markdown-citations.txt | 33 +++--- 8 files changed, 136 insertions(+), 257 deletions(-) delete mode 100644 tests/markdown-citations.chicago-author-date.html create mode 100644 tests/markdown-citations.chicago-author-date.txt delete mode 100644 tests/markdown-citations.ieee.html create mode 100644 tests/markdown-citations.ieee.txt delete mode 100644 tests/markdown-citations.mhra.html create mode 100644 tests/markdown-citations.mhra.txt (limited to 'tests') diff --git a/tests/RunTests.hs b/tests/RunTests.hs index 5c6e136e3..50ebcfc8e 100644 --- a/tests/RunTests.hs +++ b/tests/RunTests.hs @@ -107,7 +107,7 @@ main = do "latex-reader.latex" "latex-reader.native" r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"] "testsuite.native" "testsuite.native" - r14s <- mapM (\style -> runTest ("markdown reader (citations) (" ++ style ++ ")") ["-r", "markdown", "-w", "html", "--bibliography", "biblio.bib", "--csl", style ++ ".csl"] "markdown-citations.txt" ("markdown-citations." ++ style ++ ".html")) ["chicago-author-date","ieee","mhra"] + r14s <- mapM (\style -> runTest ("markdown reader (citations) (" ++ style ++ ")") ["-r", "markdown", "-w", "markdown", "--bibliography", "biblio.bib", "--csl", style ++ ".csl", "--no-wrap"] "markdown-citations.txt" ("markdown-citations." ++ style ++ ".txt")) ["chicago-author-date","ieee","mhra"] r12s <- if runLhsTests then mapM runLhsWriterTest lhsWriterFormats else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return [] diff --git a/tests/markdown-citations.chicago-author-date.html b/tests/markdown-citations.chicago-author-date.html deleted file mode 100644 index 05434493f..000000000 --- a/tests/markdown-citations.chicago-author-date.html +++ /dev/null @@ -1,56 +0,0 @@ -

      Pandoc with citeproc-hs

      [@nonexistent]

      @nonexistent

      Doe (2005) says blah. Doe (2005, 30) says blah. Doe (2005, 30, with suffix) says blah. Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah.

      In a note.1 A citation group (see Doe 2005, 34–35; also Doe and Roe 2007, chap. 3). Another one (see Doe 2005, 34–35). And another one in a note.2 Citation with a suffix and locator (Doe 2005, 33, 35–37, and nowhere else). Citation with suffix only (Doe 2005, and nowhere else).

      Now some modifiers.3

      References

      Doe, John. 2005. First Book. Cambridge: Cambridge University Press.

      ---. 2006. Article. Journal of Generic Studies 6: 33–34.

      Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In Third Book, ed. Sam Smith. Oxford: Oxford University Press.


      1. A citation without locators (Doe and Roe 2007).

      2. Some citations (see Doe 2006, chap. 3; Doe and Roe 2007; Doe 2005).

      3. Like a citation without author: (2005), and now Doe with a locator (2006, 44).

      diff --git a/tests/markdown-citations.chicago-author-date.txt b/tests/markdown-citations.chicago-author-date.txt new file mode 100644 index 000000000..42a28c5d2 --- /dev/null +++ b/tests/markdown-citations.chicago-author-date.txt @@ -0,0 +1,32 @@ +# Pandoc with citeproc-hs + +- [@nonexistent] +- @nonexistent +- Doe (2005) says blah. +- Doe (2005, 30) says blah. +- Doe (2005, 30, with suffix) says blah. +- Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah. +- In a note.[^1] +- A citation group (see Doe 2005, 34–35; also Doe and Roe 2007, chap. 3). +- Another one (see Doe 2005, 34–35). +- And another one in a note.[^2] +- Citation with a suffix and locator (Doe 2005, 33, 35–37, and nowhere else). +- Citation with suffix only (Doe 2005, and nowhere else). +- Now some modifiers.[^3] + +# References + +Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press. + +---. 2006. Article. *Journal of Generic Studies* 6: 33–34. + +Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In *Third Book*, ed. Sam Smith. Oxford: Oxford University Press. + +[^1]: + A citation without locators (Doe and Roe 2007). + +[^2]: + Some citations (see Doe 2006, chap. 3; Doe and Roe 2007; Doe 2005). + +[^3]: + Like a citation without author: (2005), and now Doe with a locator (2006, 44). diff --git a/tests/markdown-citations.ieee.html b/tests/markdown-citations.ieee.html deleted file mode 100644 index f076a4675..000000000 --- a/tests/markdown-citations.ieee.html +++ /dev/null @@ -1,56 +0,0 @@ -

      Pandoc with citeproc-hs

      [@nonexistent]

      @nonexistent

      Reference [1] says blah. Reference [1] says blah. Reference [1] says blah. Reference [1] says blah.

      In a note.1 A citation group [1],[3]. Another one [1]. And another one in a note.2 Citation with a suffix and locator [1]. Citation with suffix only [1].

      Now some modifiers.3

      References

      [1] J. Doe, First Book, Cambridge: Cambridge University Press, 2005.

      [2] J. Doe, “Article”, Journal of Generic Studies, vol. 6, 2006, pp. 33–34.

      [3] J. Doe and J. Roe, “Why Water Is Wet”, Third Book, Smith, S., Ed., Oxford: Oxford University Press, 2007.


      1. A citation without locators [3].

      2. Some citations [1]-[3].

      3. Like a citation without author: [1], and now Doe with a locator [2].

      diff --git a/tests/markdown-citations.ieee.txt b/tests/markdown-citations.ieee.txt new file mode 100644 index 000000000..de5c30b33 --- /dev/null +++ b/tests/markdown-citations.ieee.txt @@ -0,0 +1,32 @@ +# Pandoc with citeproc-hs + +- [@nonexistent] +- @nonexistent +- Reference [1] says blah. +- Reference [1] says blah. +- Reference [1] says blah. +- Reference [1] says blah. +- In a note.[^1] +- A citation group [1],[3]. +- Another one [1]. +- And another one in a note.[^2] +- Citation with a suffix and locator [1]. +- Citation with suffix only [1]. +- Now some modifiers.[^3] + +# References + +[1] J. Doe, *First Book*, Cambridge: Cambridge University Press, 2005. + +[2] J. Doe, “Article”, *Journal of Generic Studies*, vol. 6, 2006, pp. 33-34. + +[3] J. Doe and J. Roe, “Why Water Is Wet”, *Third Book*, Smith, S., Ed., Oxford: Oxford University Press, 2007. + +[^1]: + A citation without locators [3]. + +[^2]: + Some citations [1]-[3]. + +[^3]: + Like a citation without author: [1], and now Doe with a locator [2]. diff --git a/tests/markdown-citations.mhra.html b/tests/markdown-citations.mhra.html deleted file mode 100644 index 2964ed8b7..000000000 --- a/tests/markdown-citations.mhra.html +++ /dev/null @@ -1,126 +0,0 @@ -

      Pandoc with citeproc-hs

      [@nonexistent]

      @nonexistent

      John Doe1 says blah. Doe2 says blah. Doe3 says blah. Doe4 says blah.

      In a note.5 A citation group.6 Another one.7 And another one in a note.8 Citation with a suffix and locator.9 Citation with suffix only.10

      Now some modifiers.11

      References

      Doe, John, ‘Article’, Journal of Generic Studies, 6 (2006), 33–34.

      ---, First Book (Cambridge: Cambridge University Press, 2005).

      Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in Third Book, ed by Sam Smith (Oxford: Oxford University Press, 2007).


      1. First Book (Cambridge: Cambridge University Press, 2005).

      2. First Book, p. 30.

      3. First Book, p. 30, with suffix.

      4. First Book; ‘Article’, Journal of Generic Studies, 6 (2006), 33–34 (p. 30); see also John Doe and Jenny Roe, ‘Why Water Is Wet’, in Third Book, ed by Sam Smith (Oxford: Oxford University Press, 2007).

      5. A citation without locators Doe and Roe.

      6. See Doe, First Book, pp. 34–35; also Doe and Roe, chap. 3.

      7. See Doe, First Book, pp. 34–35.

      8. Some citations see Doe, Article, 33–34 (chap. 3); Doe and Roe; Doe, First Book.

      9. Doe, First Book, pp. 33, 35–37, and nowhere else.

      10. Doe, First Book, and nowhere else.

      11. Like a citation without author: First Book, and now Doe with a locator Article, 33–34 (p. 44).

      diff --git a/tests/markdown-citations.mhra.txt b/tests/markdown-citations.mhra.txt new file mode 100644 index 000000000..acd700f0d --- /dev/null +++ b/tests/markdown-citations.mhra.txt @@ -0,0 +1,56 @@ +# Pandoc with citeproc-hs + +- [@nonexistent] +- @nonexistent +- John Doe[^1] says blah. +- Doe[^2] says blah. +- Doe[^3] says blah. +- Doe[^4] says blah. +- In a note.[^5] +- A citation group.[^6] +- Another one.[^7] +- And another one in a note.[^8] +- Citation with a suffix and locator.[^9] +- Citation with suffix only.[^10] +- Now some modifiers.[^11] + +# References + +Doe, John, ‘Article’, *Journal of Generic Studies*, 6 (2006), 33-34. + +---, *First Book* (Cambridge: Cambridge University Press, 2005). + +Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed by Sam Smith (Oxford: Oxford University Press, 2007). + +[^1]: + *First Book* (Cambridge: Cambridge University Press, 2005). + +[^2]: + First Book, p. 30. + +[^3]: + First Book, p. 30, with suffix. + +[^4]: + First Book; ‘Article’, *Journal of Generic Studies*, 6 (2006), 33-34 (p. 30); see also John Doe and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed by Sam Smith (Oxford: Oxford University Press, 2007). + +[^5]: + A citation without locators Doe and Roe. + +[^6]: + See Doe, First Book, pp. 34-35; also Doe and Roe, chap. 3. + +[^7]: + See Doe, First Book, pp. 34-35. + +[^8]: + Some citations see Doe, Article, 33-34 (chap. 3); Doe and Roe; Doe, First Book. + +[^9]: + Doe, First Book, pp. 33, 35-37, and nowhere else. + +[^10]: + Doe, First Book, and nowhere else. + +[^11]: + Like a citation without author: First Book, and now Doe with a locator Article, 33-34 (p. 44). diff --git a/tests/markdown-citations.txt b/tests/markdown-citations.txt index c54a41304..9b6992f90 100644 --- a/tests/markdown-citations.txt +++ b/tests/markdown-citations.txt @@ -1,22 +1,19 @@ # Pandoc with citeproc-hs -[@nonexistent] - -@nonexistent - -@item1 says blah. -@item1 [p. 30] says blah. -@item1 [p. 30, with suffix] says blah. -@item1 [-@item2 p. 30; see also @item3] says blah. - -In a note.[^1] A citation group [see -@item1 p. 34-35; also @item3 chap. 3]. Another one [see -@item1 p. 34-35]. And another one in a note.[^2] -Citation with a suffix and locator [@item1 pp. 33, 35-37, -and nowhere else]. Citation with suffix only -[@item1, and nowhere else]. - -Now some modifiers.[^3] +- [@nonexistent] +- @nonexistent +- @item1 says blah. +- @item1 [p. 30] says blah. +- @item1 [p. 30, with suffix] says blah. +- @item1 [-@item2 p. 30; see also @item3] says blah. +- In a note.[^1] +- A citation group [see @item1, p. 34-35; also @item3 chap. 3]. +- Another one [see + @item1 p. 34-35]. +- And another one in a note.[^2] +- Citation with a suffix and locator [@item1, pp. 33, 35-37, and nowhere else]. +- Citation with suffix only [@item1, and nowhere else]. +- Now some modifiers.[^3] [^1]: A citation without locators [@item3]. @@ -26,7 +23,7 @@ Now some modifiers.[^3] [^3]: Like a citation without author: [-@item1], and now Doe with a - locator [-@item2 p. 44]. + locator [-@item2, p. 44]. # References -- cgit v1.2.3