packages feed

citeproc 0.13 → 0.13.0.1

raw patch · 7 files changed

+264/−16 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,12 @@ # citeproc changelog +## 0.13.0.1++  * Detect terminal punctuation hidden by closing quotes (#179,+    Andrew Dunning).++  * Clarify building executable in the README (#177).+ ## 0.13    * Add `citationResetPosition` field to `Citation`. [API change]
README.md view
@@ -28,11 +28,6 @@  - it is more flexible, not being tied to pandoc's types. -Unlike pandoc-citeproc, this library does not provide an-executable.  It will be used in pandoc itself to provide-integrated citation support and bibliography format conversion-(so the pandoc-citeproc filter will no longer be necessary).- [CSL]: https://docs.citationstyles.org/en/stable/specification.html  ## How to use it@@ -93,13 +88,13 @@  ## The citeproc executable -If the package is compiled with the `executable` flag, an-executable `citeproc` will be built.  `citeproc` reads-a JSON-encoded `Inputs` object from `stdin` (or from-a file if a filename is provided) and writes-a JSON-encoded `Result` object to `stdout`.  (It does so using-`CslJson Text` as the underlying type.) This executable-can be used to add citation processing to non-Haskell projects.+If the package is compiled with the `executable` flag+(`cabal build -fexecutable`), a command-line program `citeproc`+will be built. `citeproc` reads a JSON-encoded `Inputs` object+from `stdin` (or from a file if a filename is provided) and+writes a JSON-encoded `Result` object to `stdout`. (It does so+using `CslJson Text` as the underlying type.) This executable can+be used to add citation processing to non-Haskell projects.  `citeproc --help` will summarize usage information.  See the [man page](man/citeproc.1.md) for more information.
citeproc.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                citeproc-version:             0.13+version:             0.13.0.1 synopsis:            Generates citations and bibliography from CSL styles. description:         citeproc parses CSL style files and uses them to                      generate a list of formatted citations and bibliography
src/Citeproc/Types.hs view
@@ -119,7 +119,9 @@ import qualified Data.CaseInsensitive as CI import Control.Monad (foldM, guard, mzero) import Control.Applicative ((<|>), optional)-import Data.Char (isLower, isDigit, isLetter, isSpace, isAlphaNum, isAscii)+import Data.Char (GeneralCategory(FinalQuote),+                  generalCategory, isLower, isDigit,+                  isLetter, isSpace, isAlphaNum, isAscii) import Data.Text (Text) import GHC.Generics (Generic) import qualified Data.Text as T@@ -1693,10 +1695,30 @@  where   xText = toText x   yText = toText y-  xEnd = if T.null xText then '\xFFFD' else T.last xText-  yStart = if T.null yText then '\xFFFD' else T.head yText+  yStart = fromMaybe '\xFFFD' (firstChar yText)+  -- see #179+  xEnd =+     if yStart == '.'+       then fromMaybe xLast (terminalCharBeforeQuote xText)+       else xLast+  xLast = fromMaybe '\xFFFD' (lastChar xText)   xTrimmed = dropTextWhileEnd (== xEnd) x   yTrimmed = dropTextWhile (== yStart) y+  firstChar = fmap fst . T.uncons+  lastChar = fmap snd . T.unsnoc+  terminalCharBeforeQuote t =+    let trimmed = T.dropWhileEnd isSpace t+    in case T.unsnoc trimmed of+         Just (_, q) | isQuoteLike q ->+           lastChar (T.dropWhileEnd isTrailingCloser trimmed)+         _ -> Nothing+  isQuoteLike c =+       c == '"'+    || c == '\''+    || generalCategory c == FinalQuote+  isTrailingCloser c =+       isSpace c+    || isQuoteLike c   keepFirst = if yTrimmed == y -- see #49                  then x : fixPunct (y : zs)                  else fixPunct $ x : yTrimmed : zs
+ test/extra/issue_179.txt view
@@ -0,0 +1,84 @@+>>===== MODE =====>>+citation+<<===== MODE =====<<+++>>===== RESULT =====>>+Doe, ‘Ends with period inside quotes.’+Doe, ‘Ends with question mark?’+Doe, ‘Ends with an exclamation mark!’+Doe, ‘Ends with period outside quotes’.+<<===== RESULT =====<<+++>>===== CITATION-ITEMS =====>>+[+  [+    {+      "id": "ITEM-1",+      "suffix": ", 'Ends with period inside quotes.'"+    }+  ],+  [+    {+      "id": "ITEM-1",+      "suffix": ", 'Ends with question mark?'"+    }+  ],+  [+    {+      "id": "ITEM-1",+      "suffix": ", 'Ends with an exclamation mark!'"+    }+  ],+  [+    {+      "id": "ITEM-1",+      "suffix": ", 'Ends with period outside quotes'."+    }+  ]+]+<<===== CITATION-ITEMS =====<<+++>>===== CSL =====>>+<style+      xmlns="http://purl.org/net/xbiblio/csl"+      class="note"+      version="1.0"+      default-locale="en-GB">+  <info>+    <id />+    <title />+    <updated>2026-05-03T22:24:00+00:00</updated>+  </info>+  <citation>+    <layout suffix=".">+      <names variable="author">+        <name form="short" />+      </names>+    </layout>+  </citation>+</style>+<<===== CSL =====<<+++>>===== INPUT =====>>+[+  {+    "author": [+      {+        "family": "Doe",+        "given": "John"+      }+    ],+    "id": "ITEM-1",+    "type": "book"+  }+]+<<===== INPUT =====<<+++>>===== VERSION =====>>+1.0+<<===== VERSION =====<<
+ test/extra/issue_179_enUS.txt view
@@ -0,0 +1,77 @@+>>===== MODE =====>>+citation+<<===== MODE =====<<+++>>===== RESULT =====>>+Doe, “Ends with period inside quotes.”+Doe, “Ends with question mark?”+Doe, “Ends with an exclamation mark!”+<<===== RESULT =====<<+++>>===== CITATION-ITEMS =====>>+[+  [+    {+      "id": "ITEM-1",+      "suffix": ", \"Ends with period inside quotes.\""+    }+  ],+  [+    {+      "id": "ITEM-1",+      "suffix": ", \"Ends with question mark?\""+    }+  ],+  [+    {+      "id": "ITEM-1",+      "suffix": ", \"Ends with an exclamation mark!\""+    }+  ]+]+<<===== CITATION-ITEMS =====<<+++>>===== CSL =====>>+<style+      xmlns="http://purl.org/net/xbiblio/csl"+      class="note"+      version="1.0"+      default-locale="en-US">+  <info>+    <id />+    <title />+    <updated>2026-05-03T22:24:00+00:00</updated>+  </info>+  <citation>+    <layout suffix=".">+      <names variable="author">+        <name form="short" />+      </names>+    </layout>+  </citation>+</style>+<<===== CSL =====<<+++>>===== INPUT =====>>+[+  {+    "author": [+      {+        "family": "Doe",+        "given": "John"+      }+    ],+    "id": "ITEM-1",+    "type": "book"+  }+]+<<===== INPUT =====<<+++>>===== VERSION =====>>+1.0+<<===== VERSION =====<<
+ test/extra/issue_179_paren.txt view
@@ -0,0 +1,63 @@+>>===== MODE =====>>+citation+<<===== MODE =====<<+++>>===== RESULT =====>>+Doe, (E.D. Wisc.).+<<===== RESULT =====<<+++>>===== CITATION-ITEMS =====>>+[+  [+    {+      "id": "ITEM-1",+      "suffix": ", (E.D. Wisc.)"+    }+  ]+]+<<===== CITATION-ITEMS =====<<+++>>===== CSL =====>>+<style+      xmlns="http://purl.org/net/xbiblio/csl"+      class="note"+      version="1.0"+      default-locale="en-US">+  <info>+    <id />+    <title />+    <updated>2026-05-03T22:24:00+00:00</updated>+  </info>+  <citation>+    <layout suffix=".">+      <names variable="author">+        <name form="short" />+      </names>+    </layout>+  </citation>+</style>+<<===== CSL =====<<+++>>===== INPUT =====>>+[+  {+    "author": [+      {+        "family": "Doe",+        "given": "John"+      }+    ],+    "id": "ITEM-1",+    "type": "book"+  }+]+<<===== INPUT =====<<+++>>===== VERSION =====>>+1.0+<<===== VERSION =====<<