Giter Club home page Giter Club logo

citeproc-rs's Introduction

citeproc-rs

A work-in-progress implementation of CSL and CSL-M in Rust. It is geared at:

  • replacing citeproc-js by providing WebAssembly bindings such that it could be embedded in Zotero or fulfil any other JavaScript-based use;
  • replacing much of pandoc-citeproc, by running as a Pandoc Filter;
  • making it easy to use citeproc from any programming language, and integrate into any use case; and
  • correctness and high performance.

Supported Rust versions

With a stable Rust compiler, 1.43 or later, you can:

  • Build citeproc as a library
  • Build a WebAssembly package (see below for details)

For development, you need a recent nightly compiler. This is required to run the test suite within the cargo test harness using datatest. Keep your nightly up to date, as there are frequent breaking changes in that area at the moment, and this repo will track close to the edge.

You should install Rust and keep it up to date with rustup.

Try it out

There is a demo of citeproc-rs in action. It includes a graph visualisation of cite ambiguity testing. See if you can figure out how it works.

To see how well citeproc-rs is doing on the tests, visit https://cormacrelf.github.io/citeproc-rs-test-viewer/

WebAssembly usage

The WebAssembly shell lives in crates/wasm. It consists of a JavaScript API that wraps the citeproc crate, and a mechanism for asynchronous locale fetching. The API works mostly by serializing to JSON and back, but this is invisible. It includes TypeScript definitions, which are the main source of documentation. Open up the generated .d.ts file or view the doc-comments with your editor or IDE. A useful reference is the js-demo, which exercises most of its functionality and demonstrates correct usage of the batchedUpdates/UpdateSummary API.

Note especially that Driver cannot be garbage collected. You will need to .free() it manually, otherwise the whole engine and its cached data will be leaked. Like many things with WebAssembly MVP, this might improve. Same with the WASM multithreading proposal -- computing cites is synchronous and single-threaded now, but it may be desirable in future to make it async and multithreaded. We'll see.

Building

  1. Install wasm-pack
  2. cd crates/wasm; wasm-pack build -h

Refer to the docs for on how to get the output you need, particularly --target.

Non-WebAssembly usage

For Rust users, this package will available at some point on crates.io. The csl crate is already available, if all you wanted to do was parse/validate styles and locales. (Hint: use std::str::FromStr; Style::from_str(xml);.) For the rest, it needs a slightly more stable API, and maybe some of the crate-splitting rethought. (I don't want to claim crate names and then change my mind later. They are split for compile time reasons.)

It will likely be possible to support communicating via JSON messages over stdio: drop me a line over at #13 if this interests you. There is currently no way to use citeproc-rs via C FFI. This is mostly because of the complex structured data involved, which requires significant conversion effort and may not be worth it. If this is something you really want, file an issue.

Running the CSL test suite

citeproc-rs comes with a full-featured test harness for the CSL test suite, based on the Rust testing infrastructure. This includes colourful diffs, and support for a new YAML-based test case format. However, given that at the moment not all of the tests pass, a more nuanced way of detecting failure and comparing results to find regressions between revisions was necessary. So now it can store and diff test runs. Pull requests that cause regressions (Ok => Failure) compared to master will fail.

# setup once
cargo pull-locales
cargo pull-test-suite

cargo test-suite --help

# the whole suite in parallel
cargo test-suite run

# the whole suite with deterministic test execution order
# this helps show related tests alongside one another in the terminal output
cargo test-suite run -- --test-threads 1

# for a particular test, paste the file name
cargo test-suite run -- name_ParsedDroppingParticleWithApostrophe.txt

# for a subset of tests with some commonality in the name (this runs 8 of them)
cargo test-suite run -- name_Initials

# store a test run for comparison
# this will also save a copy in 'branch_name' and 'commit_hash' if your working 
# directory is clean
cargo test-suite store [name] [-- filter_pattern]
cargo test-suite store disamb -- disamb # all of the disamb tests

# diff two named, commit-named or commit-hash test results
# outputs any regressions and fixed test cases
# exits with code 1 if any regressions
cargo test-suite diff master # compares to ..current

# only checks the intersection of the tests, especially if you're using a filter
cargo test-suite diff master..disamb
# test result: 0 regressions, 0 new passing tests, 0 new ignores, out of 107 intersecting tests

# saves in 'current'
cargo test-suite store
# copies 'current' to 'blessed'
cargo test-suite bless
# (make some changes)
# compares blessed..current
cargo test-suite store && cargo test-suite diff

# in a clean repo, go back in time to a commit and store the captured
# result by its commit SHA and an optional name, then checkout HEAD again
cargo test-suite checkout-store [name]

citeproc-rs's People

Contributors

cormacrelf avatar kira-bruneau avatar tnajdek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

citeproc-rs's Issues

Convention to specify a link for bibliography

As per the suggestion there, this issue is cloned from a citeproc-js issue:

Currently AFAICT CSL is in limbo regardingspecification for hyperlinks in bibliographies and so CSL implementers must invent their own convention for specifying hyperlinks. Is this something we are interested in? Do we need some way of specifying that part or all of a bibliographical entry (such as the whole entry, or the title, or the author name/date or something) should be a hyperlink (either to the URL field or the DOI link)? Currently it seems there is the wrap_url_and_doi process which can be ugly, although of course one can make it look nicer with CSS for HTML output. if one has control of the CSS. There are also macro hacks for LaTeX output; but it seems like some kind of unified approach might be in order?

Cannot build citeproc-db with `cargo vendor`

@doronbehar and I maintain texlab for the Nix package manager and I've encountered the following error trying to build 1.8.0 (which now uses citeproc-rs):

error: couldn't read /tmp/nix/texlab/texlab-1.8.0-vendor/citeproc-db/src/../../wasm/src/locales-en-US.xml: No such file or directory (o
s error 2)                                                                                                                            
   --> /tmp/nix/texlab/texlab-1.8.0-vendor/citeproc-db/src/xml.rs:320:13
    |
320 |             include_str!("../../wasm/src/locales-en-US.xml").to_string(),
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

This seems to be an issue with citeproc-db depending on locales-en-US.xml in citeproc-wasm.

For a normal run of cargo build this isn't an issue, but if the dependencies are vendored prior to running cargo build, citeproc-db will be compiled independently from citeproc-wasm, and it won't find locales-en-US.xml.

This can be reproduced by:

  • Setting the working directory to the texlab repo
  • Running cargo vendor
  • Following the instructions displayed in the output, for example:
To use vendored sources, add this to your .cargo/config for this project:

[source.crates-io]
replace-with = "vendored-sources"

[source."https://github.com/cormacrelf/citeproc-rs"]
git = "https://github.com/cormacrelf/citeproc-rs"
rev = "796ea0382392ae1befdc39f21162ed83b640ac29"
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "/tmp/texlab/vendor"
  • Running cargo build

Add a way to specify the ClusterMode of a previewed cluster

To be clear the cite-level ones, e.g. { id: "jones2006", prefix: "see their other work", mode: "SuppressAuthor" } currently work from the previewCitationCluster API, simply add a mode flag to any cite that you're passing in. It is only the cluster level flags { id: "cluster-one", cites: [...], mode: "Composite" } that aren't yet exposed there. To get that, I'll have to add a parameter to let you supply the preview cluster's cluster mode.

Originally posted by @cormacrelf in #117 (comment)

In some scenarios prefix needs to be ignored when wrapping DOI

After #124, with the new link_anchors set to true, for the following CSL (copied from MLA):

<text variable="DOI" prefix="https://doi.org/"/>

The following HTML is produced:

https://doi.org/<a href="https://doi.org/VAR">https://doi.org/VAR</a>

https://doi.org/ part of the prefix shouldn't be used here as it already appears as part of the URL.

Related: #116

Various index out of bound errors

I've encountered index out of bound errors when running Driver.free(), Driver.includeUncitedItems({Specific: []}) and Driver.insertReference() at various points while testing with Zotero. Note that Zotero is freeing the driver too often and I will have to debug why it does that, but it still shouldn't run into memory access issues when interacting with the driver.

I've put up a Zotero log, you can filter for CiteprocRs: lines to see CiteprocRs calls. If you have Zotero builds set up then the citeproc-rs branch is available here: https://github.com/adomasven/zotero/tree/citeproc-rs

CSL v1.1 support

Just to note that at the CSL project, we're hoping to close work on v1.1 in the coming weeks.

The most significant changes/additions are features which are closely modeled on, or exactly the same as, those in CSL-M; notably the intext and conditions elements. So if you support those, should be trivial to support v1.1 also.

Dates on the input model are also changing, with priority going forward on EDTF.

Please weigh in if any feedback. We're currently discussing some big questions; cf citation-style-language/schema#268.

Also, v1.0.2 should be tagged in the next week; this adds new variables, types, terms mostly.

Demo disambiguation favors disambiguate-add-names

In the current disambiguation demo, citeproc-rs is adding names where disambiguation can be done by adding names or initials to existing partners. Steps to reproduce:

  1. Align the names, changing "Amadeus" to "Ariadne" to yield:

    K. Camembert et al. / K. Camembert et al.

  2. Add a char to the first given name in the first item to yield:

    Kurtz Camembert et al. / Kurt Camembert et al.

  3. Add a char to the last family name in the first item.

Expected
Further disambiguation is unnecessary, and with the style set to etal-use-first="1" and etal-min="1" or etal-min="2", a single name should be preferred. The result should remain:

Kurtz Camembert et al. / Kurt Camembert et al.

Åctual Result
The first given name is reverted to an initial, and two names are added:

K. Camembert, A. Rossi, I. Irrelevantz / K. Camembert, A. Rossi, I. Irrelevant

Wasm js-demo errors when running with yarn

→ yarn -v
1.19.2

→ wasm-pack -V
wasm-pack 0.8.1

→ yarn && yarn start
yarn install v1.19.2
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.42s.
yarn run v1.19.2
$ webpack-dev-server --open -d --compress
🧐  Checking for wasm-pack...

✅  wasm-pack is installed. 

ℹ️  Compiling your crate in development mode...

ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /home/adomas/zotero/citeproc-rs/crates/wasm/js-demo/dist
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
error: the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101

Since I mentioned this in #31, let's just do a separate issue. This is running on Ubuntu 18.04, running wasm-pack standalone works fine.

Publish prerelease builds of the wasm driver

It takes a while to build and is tricky to link in to browser JS projects. A better way would be to publish alpha releases on NPM. It does need a package name first.

  • citeproc-wasm?
  • @citeproc-rs/driver?

Then a travis script to publish for any PRs merged into master.

Wasm bindings initialization with an ArrayBuffer

It used to be able to initialize the citeproc web bindings by passing an ArrayBuffer to the initialization function, but that's no longer the case since the last few updates. If you pass an ArrayBuffer it tries to await it. The initialization function expects a string input that it then can fetch, but fetch is unavailable in the environment in which we run citeproc-rs in Zotero. Could the previous functionality be restored, or is this change part of the outside bindgen code?

Stdio mode

It might turn out to be useful to have a command-line program that runs a citeproc server over stdin/stout with JSON messages. This might be easier to integrate in some applications than a WebAssembly runtime. citeproc-java, for instance, could do this, but so could a Vim plugin. It could also be a neat solution to running inside a Pandoc Lua script.

Stdio has proved a fitting transport for the Language Server Protocol, partly because of this ease of integration. You also wouldn't need to worry about ensuring downstream WebAssembly runtimes actually have the features you need; just build for x86 with rayon parallelism, set up filesystem watchers when requested, etc.

CompileErrror when initializing the wasm driver

CompileError: wasm validation error: at offset 7591: can't import/export mutable globals in the MVP

I am getting the above error when initializing the wasm driver with the latest canary build.

Index out of bounds when inserting reference with the WASM driver

This is the input to insertReference():

{
  "id": "1303",
  "type": "chapter",
  "abstract": "Another dimension of the institutional neutrality debate revolves around admissions. Who shall be allowed to go to college? What kind of college? How are the applicant’s credentials to be judged? Shall such extraneous variables as race be given any consideration? Is it proper for universities to set quotas to accommodate minorities, or go even further to a policy of “open admissions”?\nAgain, the debate basically turns on the conception of the university, and the role it plays in society. To the “classicist,” the university has three primary obligations: first, a commitment to transmit high culture—to shape students’ mind and",
  "container-title": "The Test",
  "ISBN": "978-0-87013-648-1",
  "page": "183-202",
  "publisher": "Michigan State University Press",
  "source": "JSTOR",
  "title": "THE GUARDIANS OF EXCELLENCE",
  "URL": "http://www.jstor.org/stable/10.14321/j.ctt130hjnp.11",
  "editor": [
    {
      "family": "ADAMS",
      "given": "WALTER"
    }
  ],
  "accessed": {
    "date-parts": [
      [
        "2017",
        10,
        20
      ]
    ]
  },
  "issued": {
    "date-parts": [
      [
        "2003"
      ]
    ]
  }
}

Stack trace:

RuntimeError: index out of bounds
    driver_insertReference@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:2746873:1
    insertReference@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:191:9

I don't know what's up with the stack trace. citeproc-rs.js:2746873 does not exist, citeproc-rs.js has 499 lines.

Invalid HTML produced when item URL contains a quotation symbol `"`.

When producing the bibliography with APA, with an item that has an URL field with a " symbol in it, the output is

“Title.” n.d. Accessed July 26, 2021. <a href="http://example.com/?"">http:&#x2f;&#x2f;example.com&#x2f;?&quot;</a>.

The quotation symbol in the href field should be escaped in the output.

BibliographyMeta wrongly cased/documented

This is the typescript

type BibliographyMeta = {
    max_offset: number;
    entry_spacing: number;
    line_spacing: number;
    hanging_indent: boolean;
    /** the second-field-align value of the CSL style */
    secondFieldAlign: null  | "flush" | "margin";
    /** Format-specific metadata */
    formatMeta: any,
};

The actual properties are all camel cased instead of snake cased. The camel case is preferred, but the typescript should be correct.

Fatal failure with unexpected page field data

I've been testing over a bunch of old documents and ran into this error:

(5)(+0000001): CiteprocRs: batchedUpdates

(3)(+0000064): RuntimeError: unreachable executed __rust_start_panic@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3933323:1 rust_panic@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3917250:1 std::panicking::rust_panic_with_hook::h5395f3796c27894a@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3743951:1 rust_begin_unwind@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3904279:1 core::panicking::panic_fmt::h0dbc4ba05c77baa3@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3913562:1 core::option::expect_none_failed::h126917f90cba260e@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3850499:1 citeproc_io::numeric::num_alpha_num::{{closure}}::hb9a26a06ae1f77c7@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3273116:1 citeproc_io::numeric::num_ish::hcc38c1239e41e686@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:1548126:1 citeproc_io::numeric::NumericValue::parse_full::hddf12232ec0098c2@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:991784:1 <citeproc_proc::cite_context::CiteContext<O,I> as citeproc_proc::cite_context::RenderContext>::get_number::{{closure}}::h2ee896cefcacb999@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3109807:1 <citeproc_proc::cite_context::CiteContext<O,I> as citeproc_proc::cite_context::RenderContext>::get_number::h3666ad58bc2f04d8@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:2751870:1 citeproc_proc::IrState::maybe_suppress_num::he0418788d31c7174@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3308652:1 citeproc_proc::element::<impl citeproc_proc::Proc<O,I> for csl::style::Element>::intermediate::h654e1790b9109a05@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:752345:1 citeproc_proc::helpers::sequence::hf5cd23065843b10f@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:1555607:1 citeproc_proc::choose::eval_ifthen::h3e556c3c7307cb3a@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3174782:1 citeproc_proc::choose::<impl citeproc_proc::Proc<O,I> for alloc::sync::Arc<csl::style::Choose>>::intermediate::hc6c50d568ff74573@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:2393448:1 citeproc_proc::element::<impl citeproc_proc::Proc<O,I> for csl::style::Element>::intermediate::h654e1790b9109a05@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:749498:1 citeproc_proc::helpers::sequence::hf5cd23065843b10f@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:1555607:1 citeproc_proc::choose::eval_ifthen::h3e556c3c7307cb3a@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3174782:1 citeproc_proc::choose::<impl citeproc_proc::Proc<O,I> for alloc::sync::Arc<csl::style::Choose>>::intermediate::hc6c50d568ff74573@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:2393547:1 citeproc_proc::element::<impl citeproc_proc::Proc<O,I> for csl::style::Element>::intermediate::h654e1790b9109a05@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:749498:1 citeproc_proc::helpers::sequence::hf5cd23065843b10f@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:1555607:1 citeproc_proc::element::<impl citeproc_proc::Proc<O,I> for csl::style::Element>::intermediate::h654e1790b9109a05@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:750038:1 citeproc_proc::helpers::sequence::hf5cd23065843b10f@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:1555607:1 <citeproc_proc::db::BibItemGen0Query as salsa::plumbing::QueryFunction>::execute::h0a2abac69d418a40@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:1224620:1 salsa::derived::slot::Slot<Q,MP>::read_upgrade::h71df57abfbc896c9@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:821526:1 salsa::derived::slot::Slot<Q,MP>::read::h5b8b842cd71d460b@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:2197295:1 <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch::ha57240a80a52e291@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:2328520:1 <DB as citeproc_proc::db::IrDatabase>::bib_item_gen0::__shim::hc8ed9cf4992c0e3a@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3751760:1 <DB as citeproc_proc::db::IrDatabase>::bib_item_gen0::hb264632af3b048ef@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3927691:1 <citeproc_proc::db::GetBibliographyMapQuery as salsa::plumbing::QueryFunction>::execute::hcc682aa18a4c463d@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:1585313:1 salsa::derived::slot::Slot<Q,MP>::read_upgrade::h61ba2c3083cc2262@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:919158:1 salsa::derived::slot::Slot<Q,MP>::read::h06730e013776937a@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:2237650:1 <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch::hbf9b37acc0597448@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:1955556:1 <DB as citeproc_proc::db::IrDatabase>::get_bibliography_map::__shim::hac9c8f6bdae9dd38@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3834967:1 citeproc::processor::Processor::save_and_diff_bibliography::h3dd633c777c169a3@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:1665750:1 citeproc::processor::Processor::batched_updates_str::h4989718f8bd964af@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:2561629:1 wasm::Driver::batched_updates::hf6c10ea98b5fba46@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:2486921:1 driver_batchedUpdates@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3851268:1 batchedUpdates@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:415:19 getBatchedUpdates@chrome://zotero/content/xpcom/citeproc-rs-to-citeproc-js.js:156:14 Zotero.Integration.Session.prototype._updateCitationsCiteprocRs@chrome://zotero/content/xpcom/integration.js:1895:25 Zotero.Integration.Session.prototype._updateCitations@chrome://zotero/content/xpcom/integration.js:1817:12 Zotero.Integration.Fields.prototype.updateDocument<@chrome://zotero/content/xpcom/integration.js:992:9 tryCatcher@resource://zotero/loader.jsm -> resource://zotero/bluebird/util.js:16:16 module.exports/PromiseSpawn.prototype._promiseFulfilled@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:97:18 From previous event: captureStackTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:915:23 CapturedTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:807:5 longStackTracesCaptureStackTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:482:19 module.exports/Promise.prototype._then@resource://zotero/loader.jsm -> resource://zotero/bluebird/promise.js:261:9 module.exports/Promise.prototype._passThrough@resource://zotero/loader.jsm -> resource://zotero/bluebird/finally.js:94:12 module.exports/Promise.prototype.finally@resource://zotero/loader.jsm -> resource://zotero/bluebird/finally.js:103:12 PromiseSpawn@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:36:25 module.exports/Promise.coroutine/<@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:197:21 Zotero.Integration.Interface.prototype.refresh@chrome://zotero/content/xpcom/integration.js:699:9

I isolated the problematic citation and it appears to have crazy data for the item page:

{"citationID":"UkVQybLi","properties":{"formattedCitation":"(Hamre et al. 2007)","plainCitation":"(Hamre et al. 2007)","noteIndex":0},"citationItems":[{"id":"5IR1ctXb/qmHPArzD","uris":["http://zotero.org/users/807735/items/SVSN2WHW"],"itemData":{"id":445,"type":"article-journal","title":"Teachers' Perceptions of Conflict with Young Students: Looking beyond Problem Behaviors","container-title":"Social Development","page":"071124114012001-???","volume":"0","issue":"0","source":"CrossRef","DOI":"10.1111/j.1467-9507.2007.00418.x","ISSN":"0961-205X, 1467-9507","language":"en","author":[{"family":"Hamre","given":"Bridget K."},{"family":"Pianta","given":"Robert C."},{"family":"Downer","given":"Jason T."},{"family":"Mashburn","given":"Andrew J."}],"issued":{"date-parts":[["2007",11,22]]},"title-short":"Teachers' Perceptions of Conflict with Young Students"}}],"schema":"https://github.com/citation-style-language/schema/raw/master/csl-citation.json"}

citeproc-js deals with this by simply ignoring the field. I have no idea how that page value got like that, it's from a document that i have from way back, but it's not impossible that this was the result of a translator save from some journal where the served item metadata was like that. Either way, citeproc-rs shouldn't fail for something like this. Moreover, the driver instance got busted after that and further calls to insertReference() would fail with a similar error (I presume if I'd call setClusterOrder first and removed that reference maybe it would fix itself.

Set output format after driver initialization

Could we have a setOutputFormat() API if it doesn't require reinitializing something fundamental in the driver? We can adjust Zotero code to only ever set output format on driver initialization but we might have plugins that are used to calling setOutputFormat() available on citeproc-js and we don't want to break them unnecessarily.

Make reference libraries more efficient

Currently, if you want a reference to be citable, you must have already added it via set_references. This is not ideal e.g. for Zotero, where there may be thousands of references, and serializing all of them to JSON once at startup, and keeping the processor updated each time one of them changes (ser the single changed ref), is too much. It probably needs to emulate citeproc-js' sys API here, where you call into JS when a reference is not found.

The following PR over at salsa may help avoid calling this for every cite, every time -- Zotero would simply notify citeproc-rs that it should invalidate one of its references, and maybe get a callback later if that item is cited.

https://github.com/salsa-rs/salsa/pull/194/files#diff-08c6e038e5b8a9cfe78f8df09fd08dc1

Plaintext output format

Citeproc-js includes a plaintext output format, which is useful in certain scenarios (in Zotero's case, when creating a cite and copying it directly to clipboard).

Wasm driver throws string errors

Wasm driver throws string errors from rust level code (instead of Error object). E.g.

could not parse cluster from host: data did not match any variant of untagged enum Cluster2

String errors do not contain a stack trace, which makes them hard to debug.

Rename id fields in JS API to be more foolproof

While I'm at it breaking compatibility in favour of usability, I might also kill the reuse of the field name "id" to refer to every different kind of ID. clusterId on a Cluster, refId on a Cite because it points to a Reference. Then you won't have so many accidents like earlier in this issue.

Originally posted by @cormacrelf in #117 (comment)

RTF Support

citeproc_io::output::html::Html is a bit of a misnomer at this point. It is very nearly capable of rendering RTF directives instead of HTML tags, chosen at runtime. It needs a few small impls, and a curly brace escaper.

CSL-M extensions

I've updated the descriptions of CSL-M schema extensions in the processor docs. I think everything is now covered. If you hit anything in the tests that is missing or inadequately described, just give a shout.

Cluster API changes

I would like to advocate for a change in the Driver API for clusters. The majority of citeproc clients that integrate citing with a document processor have a very specific workflow. There are 2 states that the document is in.

  1. The document is being edited by the user via the document processor, where edits are done to text and possibly citations are being copied in from other documents, moved around the existing document and deleted.
  2. The user is using the citeproc client (e.g. Zotero) to insert or edit citation clusters, at which point the citeproc client uses citeproc to update the document in bulk, including processing any citations that have appeared or disappeared.

During (2) the citeproc client has a full snapshot of the document with all clusters in order as they appear in the document, including multiple clusters in a single footnote, or citations that appear sequentially in text, then in a footnote (which is in the main body of text) and then in text again. I.e. all citations are naturally representable as an array in the order of appearance in the document.

The citeproc-js API for cluster update works somewhat well with this representation. When updating a particular citation, you slice off all the previous citations before the existing one to a citationsPre array and all the following citations to a citationsPost array. This is kind of cumbersome in its own right in that for each cluster update that you do in a single document update you need to generate new pre and post arrays, but at least the operation of slicing the known snapshot citation array is rather natural.

The current citeproc-rs Driver API requires manual renumbering of clusters whenever their order changes, which means that the citeproc-rs client has to keep track of which indices it has supplied to the driver and renumber the clusters manually for each document citation update, which is rather cumbersome.

The most natural way to interact with this API would be to be able to insert all clusters into the citeproc-rs Driver without specifying their position first, and then specify the order of their appearance in the document with a separate function call as an array of IDs (with tuplets for note numbers). E.g.

updateClusterOrder(clusters: [ClusterID | [ClusterID, NoteNumber]])

This would also be the natural way to tell the Driver about Clusters that have been removed.

I may be overlooking something about how note citations are handled and this is probably not the ideal way for the processor to represent cluster data internally but this has always been my imagination of how an ideal API designed for citeproc clients that integrate with a document processor would look like.

previewCitationCluster() is broken

Used to have to provide an item with {id: 0} for the citation, and in citation order array, but now i'm just providing an empty object instead (not a note item) as per updated instructions, and getting back

()

as output with APA. Can we have some tests for this method?

General questions about citeproc-rs

Hello @cormacrelf
Is citeproc-rs ready to be used in a project? The first line of the README states that citeproc-rs is "a work in progress" however the js-demo looks great and the current functionality appears to be able serve my purpose.

This may be a naive question considering citeproc-rs compiles to webassembly but what is the performance of citeproc-rs compared to citeproc-js?

Is there still a plan to release this as a package on NPM as discussed #7 ?

Synchronous locale fetching?

CC @adomasven

One thing I couldn't get going in the Zotero client code at the moment is the ability to fetch all the locales needed. The old locale fetching based on individual references (!) was wrong and please ignore it, but the new way is that:

  1. Driver.new({ style: '<style default-locale="en-GB" ... >' }) wants to fetch ['en-US', 'en-GB']
  2. Driver.new({ style: ..., localeOverride: "de-AT" }) wants to fetch ['en-US', 'de-DE', 'de-AT']
  3. await driver.fetchAll() fetches everything on that list except en-US, which is bundled.

Using the API correctly means always calling and waiting for fetchAll after Driver.new(). If you don't call it, you get everything from en-US, no localisation at all. If you call it but don't await it, then you get an error if you use the driver during the fetch, it wants to have exclusive access. This is a bit of a rust thing that would be pretty painful to work around.

So, fetchAll being async, you can't use it in most of the adapter API because most of those methods are synchronous i.e. _resetDriver can't be async unless you want the "red functions" to take over a lot of the integration code.

The question is: Do you want a synchronous locale fetching option? Just provide fetchLocaleSync(lang: string): string and let it run, no fetchAll required. Last time I read the zotero locale fetching code, it was synchronous, so this would make things easier. Let me know what you think.

CSL-M in Pandoc

This project looks very promising. Are there plans for making CSL-M extensions available with pandoc? Would be amazing. (I am especially keen on using things like hereinafter or the classic item type.)

Rough status tracker

Parsing status

  • Error highlighting with fix hints like rustc's output
  • Semantic version requirement
  • Feature flags and gating using <features><feature name="conditions" /></features>
  • CSL
    • locale blocks, type-checked terms, localised dates
    • type-checked variables as enums
    • citation, layout blocks
    • every rendering element
    • bibliography blocks (currently just ignored)
    • info blocks (only really needed for dependent styles)
  • CSL-M
    • variable extensions/modifications
    • multi-conditionals
    • institutions
    • jurisdictions
    • style modules
    • macro namespacing? You should probably be able to define new and override existing macros in a juris module, it's a bit limiting without that.
  • Pandoc documents
    • locators
    • inline references
  • CSL-JSON and citeproc-js-style inputs
    • Numeric parsing (hyphens, ampersands, etc)
    • Date parsing:
      • raw, including ranges
      • date-parts, including ranges
      • other
    • Reference type
    • Reference serde::Deserialize implementation (currently parses a large Better Bibtex CSL-JSON dump)
      • ids, types
      • names
      • dates
      • strings
      • micro-HTML syntax
      • parse CSL-JSON with markdown into an intermediate format (see pandoc-preproc)
      • parse the Pandoc CSL-JSON into References
      • seasons
    • Cite type
    • Cite serde::Deserialize implementation
  • BibTeX (implement as a Haskell pre-processor using the Pandoc parser that compiles BibTeX to an extension of CSL-JSON that can have Pandoc Inlines instead of strings.)

IR Generation status (see design document for what this is)

  • Affixes, formatting in general
  • Delimiters, generally
  • text-case, in general
  • strip-periods, in general
  • Quotes
    • Kinda basic pandoc Quoted inlines with flip-flop on output phase
    • ...
  • Conditionals
  • Macros
    • Basics
    • Macro recursion avoidance
  • Groups
    • Basics
    • called-but-didn't-render-any-variables
  • Names
    • latin/cyrillic detection
    • ordering of name parts, and collapsing delimiters where parts were None
    • form="long" and "short"
    • name-as-sort-order
    • et-al-min, et-al-use-first
    • et al in subsequent references
    • et-al-use-first (the ... feature)
    • and (basic)
    • delimiter-precedes-last
    • delimiter-precedes-et-al
    • inheritable attributes merging
    • initialize, initialize-with, innitialize-with-hyphen
    • using terms for all the customizable bits, like and
    • actually inheriting attributes
    • name-part formatting
  • Institutions
    • like anything at all on that front
  • Dates
    • Independent dates
    • Defining locale dates
    • Calling localized dates
    • Delimiters, affixes
    • Use of terms like month and season, and range delimiters
    • Date ranges
  • Variables
    • Text variables
    • Number variables
    • Locator types
    • Numeric ordinals
    • Term fallbacks
  • Output modules for pandoc and text
    • citations (well, it's evolving, but it works mostly)
    • bibliography support
  • Many other things

IR disambiguation and post-processing

  • DisambToken and inverted index of available references
  • DisambToken for names (trickier; see discussion)
  • Falling back to comparing full IR against each matching reference to check differences
  • add names
  • add given names, & only as many as necessary
    • 'all-names' (and similar) inverted index applied to each rendered name in the entire document
  • YearSuffixHook::Date
  • YearSuffixHook::Explicit
  • Re-rendering with disambiguate="true"
  • Re-rendering in 4 stages by mutating cloned IR, depending on the style, and short-out if-unambiguous

Some discussion here.

Infrastructure

Incremental processing using Salsa is semi-blocked on Salsa supporting generics in its query groups and storage. I'm helping out where I can. It will be pretty awesome once that's off the ground. It's already in use for locale fetch+merge, and works like a charm.

  • Locale fetching
    • Locale fallback order
    • Locale parsing
    • Reading from a directory with locale-en-US.xml file naming scheme
    • Locale merging
      • terms (per form)
      • ordinals (all at once)
      • options
      • dates
    • Access to merged locales from processing code
  • Style module fetching / search paths
  • Juris abbreviations
  • Dependent styles
  • Pandoc filter mode
    • Read clusters into the db, and write them back out again
    • Basic JSON filtering CLI
    • Recognise STDIN and run in filter mode automatically
    • Support pandoc metadata for configuration

See README for example usage; also run cargo run -- --help.

Error: unknown field `shortTitle`, expected `any CSL variable`

Zotero debug log
zotero(5)(+0000000): CiteprocRs: insertReference {"id":"HtwJTceP/5JtRiY3k","type":"article-journal","title":"Visual spatial constancy and modularity: Does intention penetrate vision?","container-title":"Philosophical Studies: An International Journal for Philosophy in the Analytic Tradition","page":"647-669","volume":"165","issue":"2","source":"JSTOR","abstract":"Is vision informationally encapsulated from cognition or is it cognitively penetrated? I shall argue that intentions penetrate vision in the experience of visual spatial constancy: the world appears to be spatially stable despite our frequent eye movements. I explicate the nature of this experience and critically examine and extend current neurobiological accounts of spatial constancy, emphasizing the central role of motor signals in computing such constancy. I then provide a stringent condition for failure of informational encapsulation that emphasizes a computational condition for cognitive penetration: cognition must serve as an informational resource for visual computation. This requires proposals regarding semantic information transfer, a crucial issue in any model of informational encapsulation. I then argue that intention provides an informational resource for computation of visual spatial constancy. Hence, intention penetrates vision.","ISSN":"0031-8116","shortTitle":"Visual spatial constancy and modularity","author":[{"family":"Wu","given":"Wayne"}],"issued":{"date-parts":[["2013"]]}}

zotero(3)(+0000002): Error: unknown field `shortTitle`, expected `any CSL variable` at line 1 column 1306
    init/imports.wbg.__wbg_new_1d56e97b8de3067f@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:560:19
    js_sys::Error::new::h2b65a8ba67ca4d24@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3931381:1
    wasm::Driver::insert_reference::hbe371febbe99ccd6@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3353019:1
    driver_insertReference@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3850562:1
    insertReference@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:250:9
    _insertCitationReferences@chrome://zotero/content/xpcom/citeproc-rs-to-citeproc-js.js:94:9
    insertCluster@chrome://zotero/content/xpcom/citeproc-rs-to-citeproc-js.js:141:23
    Zotero.Integration.Session.prototype._updateCitationsCiteprocRs@chrome://zotero/content/xpcom/integration.js:1882:7
    Zotero.Integration.Session.prototype._updateCitations@chrome://zotero/content/xpcom/integration.js:1817:12
    Zotero.Integration.Fields.prototype.updateDocument<@chrome://zotero/content/xpcom/integration.js:992:9
    tryCatcher@resource://zotero/loader.jsm -> resource://zotero/bluebird/util.js:16:16
    module.exports/PromiseSpawn.prototype._promiseFulfilled@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:97:18
From previous event:
    captureStackTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:915:23
    CapturedTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:807:5
    longStackTracesCaptureStackTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:482:19
    module.exports/Promise.prototype._then@resource://zotero/loader.jsm -> resource://zotero/bluebird/promise.js:261:9
    module.exports/Promise.prototype._passThrough@resource://zotero/loader.jsm -> resource://zotero/bluebird/finally.js:94:12
    module.exports/Promise.prototype.finally@resource://zotero/loader.jsm -> resource://zotero/bluebird/finally.js:103:12
    PromiseSpawn@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:36:25
    module.exports/Promise.coroutine/<@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:197:21
    Zotero.Integration.Interface.prototype.refresh@chrome://zotero/content/xpcom/integration.js:699:9

I received an

Error: unknown field `shortTitle`, expected `any CSL variable`

when calling insertReference()

CiteprocRsDriverError: JSON Deserialization Error: unknown field `year`, expected one of `date-parts`, `season`, `circa`, `literal`, `raw`

Zotero debug log
(3)(+0000003): Integration: citeprocRs.insertCluster(({citationID:"LFGL1ErI", properties:{formattedCitation:"{\\rtf Carl R Trueman, \\uc0\\u8220{}A Small Step Towards Rationalism: The Impact of The Metaphysics of Tommaso Campanella on the Theology of Richard Baxter,\\uc0\\u8221{} in \\i Protestant Scholasticism\\uc0\\u8239{}: Essays in Reassessment\\i0{}, ed. Carl R Trueman and R. Scott Clark (Cumbia: Paternoster Press, 1999), 181\\uc0\\u8211{}95.}", plainCitation:"Carl R Trueman, \u201CA Small Step Towards Rationalism: The Impact of The Metaphysics of Tommaso Campanella on the Theology of Richard Baxter,\u201D in Protestant Scholasticism\u202F: Essays in Reassessment, ed. Carl R Trueman and R. Scott Clark (Cumbia: Paternoster Press, 1999), 181\u201395.", dontUpdate:true, noteIndex:126}, citationItems:[{id:"xZ0RfreE/MLbzfnYx", uris:["http://zotero.org/users/783802/items/8KRVTX2C"], itemData:{id:"rt2ymMKA/VtI0pOJ0", type:"chapter", title:"A Small Step Towards Rationalism: The Impact of The Metaphysics of Tommaso Campanella on the Theology of Richard Baxter", 'container-title':"Protestant Scholasticism : Essays in Reassessment", publisher:"Paternoster Press", 'publisher-place':"Cumbia", page:"181-195", 'event-place':"Cumbia", author:[{family:"Trueman", given:"Carl R"}], editor:[{family:"Trueman", given:"Carl R"}, {family:"Clark", given:"R. Scott"}], issued:{year:1999}, 'page-first':"181", 'title-short':"A Small Step"}}], schema:"https://github.com/citation-style-language/schema/raw/master/csl-citation.json"}))

(5)(+0000003): CiteprocRs: insertReference {"id":"xZ0RfreE/MLbzfnYx","type":"chapter","title":"A Small Step Towards Rationalism: The Impact of The Metaphysics of Tommaso Campanella on the Theology of Richard Baxter","container-title":"Protestant Scholasticism : Essays in Reassessment","publisher":"Paternoster Press","publisher-place":"Cumbia","page":"181-195","event-place":"Cumbia","author":[{"family":"Trueman","given":"Carl R"}],"editor":[{"family":"Trueman","given":"Carl R"},{"family":"Clark","given":"R. Scott"}],"issued":{"year":1999},"page-first":"181","title-short":"A Small Step"}

(3)(+0000005): CiteprocRsDriverError: JSON Deserialization Error: unknown field `year`, expected one of `date-parts`, `season`, `circa`, `literal`, `raw` at line 1 column 494 CiteprocRsError@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm_include.js:54:9 CiteprocRsDriverError@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm_include.js:60:9 init/imports.wbg.__wbg_new_16465ddabcb4a719@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:589:19 wasm::wasm_result::helper::<impl wasm::DriverError>::to_js_error::hd5825d773d476ccd@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:2408378:1 <wasm::wasm_result::helper::WasmResult as core::convert::From<core::result::Result<wasm_bindgen::JsValue,wasm::DriverError>>>::from::hb2595ad7d5360d09@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3473632:1 wasm::wasm_result::helper::typescript_serde_result::h9ee2b4d62f1cd415@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:2971268:1 driver_insertReference@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:3736618:1 insertReference@resource://zotero/loader.jsm -> resource://zotero/citeproc_rs_wasm.js:263:19 _insertCitationReferences@chrome://zotero/content/xpcom/citeproc-rs-to-citeproc-js.js:115:34 insertCluster@chrome://zotero/content/xpcom/citeproc-rs-to-citeproc-js.js:162:25 Zotero.Integration.Session.prototype._updateCitationsCiteprocRs@chrome://zotero/content/xpcom/integration.js:1891:7 Zotero.Integration.Session.prototype._updateCitations@chrome://zotero/content/xpcom/integration.js:1826:12 Zotero.Integration.Fields.prototype.updateDocument<@chrome://zotero/content/xpcom/integration.js:998:9 tryCatcher@resource://zotero/loader.jsm -> resource://zotero/bluebird/util.js:16:16 module.exports/PromiseSpawn.prototype._promiseFulfilled@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:97:18 From previous event: captureStackTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:915:23 CapturedTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:807:5 longStackTracesCaptureStackTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:482:19 module.exports/Promise.prototype._then@resource://zotero/loader.jsm -> resource://zotero/bluebird/promise.js:261:9 module.exports/Promise.prototype._passThrough@resource://zotero/loader.jsm -> resource://zotero/bluebird/finally.js:94:12 module.exports/Promise.prototype.finally@resource://zotero/loader.jsm -> resource://zotero/bluebird/finally.js:103:12 PromiseSpawn@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:36:25 module.exports/Promise.coroutine/<@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:197:21 Zotero.Integration.Interface.prototype.refresh@chrome://zotero/content/xpcom/integration.js:705:9

This is probably similar to #92, once again, I got it from an old document with embedded metadata.

Support string cluster ids

Currently cluster ids are limited to numbers. This is purely a compatibility with citeproc-js issue, but an important one since it is likely that many citeproc-js clients have alphanumeric cluster IDs and switching to citeproc-rs requires additional conversion code to support existing documents.

"RuntimeError: unreachable executed" when calling batchedUpdates

Zotero debug log
(5)(+0000004): CiteprocRs: new Driver

(5)(+0000001): CiteprocRs: new Driver

(5)(+0000008): CiteprocRs: setClusterOrder []

(3)(+0000000): CiteprocRs: updateUncitedItems not available in citeprocRs

(5)(+0000484): CiteprocRs: insertReference {"id":"1301","type":"chapter","abstract":"When John A. Hannah announced his retirement as president of Michigan State University to become Director of the U.S. Agency for International Development, it marked the end of an era. For twenty-eight years, he had done all the things which Clark Kerr says a university president must do; he was a “friend of the students, a colleague to the faculty, a good fellow with the alumni, a sound administrator with the trustees, a good speaker with the public, an astute bargainer with the foundations and the federal agencies, a politician with the state legislature, a friend of industry, labor, and","container-title":"The Test","ISBN":"978-0-87013-648-1","page":"17-32","publisher":"Michigan State University Press","source":"JSTOR","title":"THE STAGE IS SET","URL":"http://www.jstor.org/stable/10.14321/j.ctt130hjnp.5","editor":[{"family":"ADAMS","given":"WALTER"}],"accessed":{"date-parts":[["2017",10,20]]},"issued":{"date-parts":[["2003"]]}}

(5)(+0000001): CiteprocRs: insertCluster {"id":1,"cites":[{"id":"1301"}]}

(5)(+0000000): CiteprocRs: setClusterOrder [{"id":1}]

(5)(+0000000): CiteprocRs: builtCluster 1

(5)(+0000002): CiteprocRs: insertReference {"id":"1301","type":"chapter","abstract":"When John A. Hannah announced his retirement as president of Michigan State University to become Director of the U.S. Agency for International Development, it marked the end of an era. For twenty-eight years, he had done all the things which Clark Kerr says a university president must do; he was a “friend of the students, a colleague to the faculty, a good fellow with the alumni, a sound administrator with the trustees, a good speaker with the public, an astute bargainer with the foundations and the federal agencies, a politician with the state legislature, a friend of industry, labor, and","container-title":"The Test","ISBN":"978-0-87013-648-1","page":"17-32","publisher":"Michigan State University Press","source":"JSTOR","title":"THE STAGE IS SET","URL":"http://www.jstor.org/stable/10.14321/j.ctt130hjnp.5","editor":[{"family":"ADAMS","given":"WALTER"}],"accessed":{"date-parts":[["2017",10,20]]},"issued":{"date-parts":[["2003"]]}}

(5)(+0000001): CiteprocRs: insertCluster {"id":2,"cites":[{"id":"1301"}]}

(5)(+0000000): CiteprocRs: setClusterOrder [{"id":2}]

(3)(+0000000): CiteprocRs: batchedUpdates

zotero(3)(+0000003): RuntimeError: unreachable executed
    __rust_start_panic@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:2838407:1
    rust_panic@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:2829322:1
    std::panicking::rust_panic_with_hook::h5e7c2dc110ae79d4@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:2631309:1
    std::panicking::continue_panic_fmt::hb5b3e4b5160fe2ab@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:2784297:1
    std::panicking::begin_panic_fmt::h62d8474306d91923@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:2806028:1
    <citeproc_db::cite::CitePositionQuery as salsa::plumbing::QueryFunction<DB>>::execute::h4d094d2a5a421962@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:2222173:1
    salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade::hcacf00312d2ed625@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:788038:1
    <salsa::derived::slot::Slot<DB,Q,MP> as salsa::dependency::DatabaseSlot<DB>>::maybe_changed_since::h88f4ab6124f33143@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:1357987:1
    salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade::he2ab721d44835f2f@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:743872:1
    <salsa::derived::slot::Slot<DB,Q,MP> as salsa::dependency::DatabaseSlot<DB>>::maybe_changed_since::h065b302de8820459@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:1217350:1
    salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade::h600f853d8bc7c867@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:740531:1
    salsa::derived::slot::Slot<DB,Q,MP>::read::hc6cc882bbd08e744@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:1828830:1
    <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch::h57fccbdeddc4958e@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:1339826:1
    citeproc::db::update::UpdateSummary::summarize::h78c8d69619de9e2a@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:1553687:1
    citeproc::db::Processor::batched_updates::h876f2355ffba4f02@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:709681:1
    citeproc_wasm::Driver::batched_updates::h121e0b0bcb80bfdd@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:1991695:1
    driver_batchedUpdates@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:2811953:1
    batchedUpdates@resource://zotero/loader.jsm -> resource://zotero/citeproc-rs.js:317:21
    getBatchedUpdates@chrome://zotero/content/xpcom/citeproc-rs-to-citeproc-js.js:130:27
    Zotero.Integration.Session.prototype._updateCitationsCiteprocRs@chrome://zotero/content/xpcom/integration.js:1900:25
    Zotero.Integration.Session.prototype._updateCitations@chrome://zotero/content/xpcom/integration.js:1822:12
    Zotero.Integration.Fields.prototype.updateDocument<@chrome://zotero/content/xpcom/integration.js:1042:9
    tryCatcher@resource://zotero/loader.jsm -> resource://zotero/bluebird/util.js:16:16
    module.exports/PromiseSpawn.prototype._promiseFulfilled@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:97:18
From previous event:
    captureStackTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:829:23
    CapturedTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:721:5
    longStackTracesCaptureStackTrace@resource://zotero/loader.jsm -> resource://zotero/bluebird/debuggability.js:400:19
    module.exports/Promise.prototype._then@resource://zotero/loader.jsm -> resource://zotero/bluebird/promise.js:232:9
    module.exports/Promise.prototype._passThrough@resource://zotero/loader.jsm -> resource://zotero/bluebird/finally.js:94:12
    module.exports/Promise.prototype.finally@resource://zotero/loader.jsm -> resource://zotero/bluebird/finally.js:103:12
    PromiseSpawn@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:36:25
    module.exports/Promise.coroutine/<@resource://zotero/loader.jsm -> resource://zotero/bluebird/generators.js:197:21
    Zotero.Integration.Interface.prototype.addEditCitation@chrome://zotero/content/xpcom/integration.js:639:12
Attached above is the debug log for the full set of operations before the error is reached.

WebAssembly import / js-wasm bindings initialization

The current wasm JS bindings use the new nodejs wasm import syntax. At the moment this is not available in most environments, including browsers, older nodejs versions and the XPCOM environment Zotero is currently running in.

Could you provide an alternative API to supply the wasm bytecode for use with the WebAssembly API to the binding JS module, so that the citeproc-rs embedding application can use whatever API is available for them to load it?

Imperative tests

Currently the test harness can execute CITATIONS tests found in https://github.com/citation-style-language/test-suite, but the output is always a bit off. Specifically, the cluster numbering doesn't match the citeproc-test-runner's numbers, which I don't believe are either cluster indices or note numbers, more like the order they were inserted? Many tests include an undocumented index passed alongside noteIndex.

Wasm crate fails to build

Attached is the build log:

adomas@paprika-laptop:~/zotero/citeproc-rs/crates/wasm
$ wasm-pack build
[...]
   Compiling datatest-derive v0.5.3-alpha.0 (https://github.com/cormacrelf/datatest?branch=test_type#e267a78d)
   Compiling ctor v0.1.10
   Compiling html5ever v0.24.0
   Compiling v_escape_derive v0.5.5
   Compiling strum_macros v0.15.0
   Compiling js-sys v0.3.30
   Compiling salsa v0.13.0
   Compiling v_escape v0.7.4
error[E0432]: unresolved import `crate::rustc_test::TestType`
   --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/lib.rs:204:5
    |
204 | use crate::rustc_test::TestType;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `TestType` in the root

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/lib.rs:1:1
  |
1 | #![feature(test)]
  | ^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/lib.rs:2:1
  |
2 | #![feature(specialization)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/lib.rs:3:1
  |
3 | #![feature(termination_trait_lib)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0560]: struct `rustc_test::TestDesc` has no field named `test_type`
   --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/runner.rs:179:21
    |
179 |                     test_type: crate::test_type(desc.source_file),
    |                     ^^^^^^^^^ `rustc_test::TestDesc` does not have this field
    |
    = note: available fields are: `name`, `ignore`, `should_panic`, `allow_fail`

error[E0560]: struct `rustc_test::TestDesc` has no field named `test_type`
   --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/runner.rs:224:17
    |
224 |                 test_type: crate::test_type(desc.source_file),
    |                 ^^^^^^^^^ `rustc_test::TestDesc` does not have this field
    |
    = note: available fields are: `name`, `ignore`, `should_panic`, `allow_fail`

error[E0560]: struct `rustc_test::TestDesc` has no field named `test_type`
   --> /home/adomas/.cargo/git/checkouts/datatest-8f1d8ca908a37906/e267a78/src/runner.rs:392:21
    |
392 |                     test_type: crate::test_type(desc.source_file),
    |                     ^^^^^^^^^ `rustc_test::TestDesc` does not have this field
    |
    = note: available fields are: `name`, `ignore`, `should_panic`, `allow_fail`

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0432, E0554, E0560.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `datatest`.
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101

suppress-author and friends

Testing with the current build none of the custom item fields like suppress-author, prefix, suffix, locator and others appear to be working. The produced citations have the default output.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.