1 // This Source Code Form is subject to the terms of the Mozilla Public 2 // License, v. 2.0. If a copy of the MPL was not distributed with this 3 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 // 5 // Copyright © 2018 Corporation for Digital Scholarship 6 7 //! This module describes non-CSL inputs to the processor. Specifically, it aims to implement 8 //! [CSL-JSON](https://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html) 9 //! ([schema](https://github.com/citation-style-language/schema/blob/master/csl-data.json)). 10 //! 11 //! These are constructed at deserialization time, i.e. when a [Reference][] 12 //! is read from CSL-JSON. Any data types that contain strings from the original JSON are typically 13 //! done with `&'r str` borrows under the [Reference][]'s lifetime `'r`, so the original JSON string 14 //! cannot be thrown away, but a large number of string allocations is saved. 15 //! 16 //! [Reference]: struct.Reference.html 17 18 #[macro_use] 19 extern crate serde_derive; 20 21 #[macro_use] 22 extern crate log; 23 24 mod cite; 25 mod csl_json; 26 mod date; 27 mod names; 28 pub use names::TrimInPlace; 29 mod numeric; 30 pub mod output; 31 mod reference; 32 pub mod unicode; 33 pub mod utils; 34 35 pub use csl_json::NumberLike; 36 pub use output::micro_html::micro_html_to_string; 37 38 pub use self::cite::*; 39 pub use self::date::*; 40 pub use self::names::*; 41 pub use self::numeric::*; 42 pub use self::reference::*; 43 44 use self::output::LocalizedQuotes; 45 use csl::TextCase; 46 47 // Export these, because proc is going to need them 48 // type Sixteen = smallstr::SmallString<[u8; 16]>; 49 // type TwentyFour = smallstr::SmallString<[u8; 24]>; 50 51 pub type SmartString = smartstring::alias::String; 52 pub(crate) type String = smartstring::alias::String; 53 pub type SmartCow<'a> = cervine::Cow<'a, String, str>; 54 55 #[derive(Debug, Clone, Default)] 56 pub struct IngestOptions { 57 pub replace_hyphens: bool, 58 pub text_case: TextCase, 59 pub quotes: LocalizedQuotes, 60 pub strip_periods: bool, 61 pub is_english: bool, 62 63 /// For `flipflop_LeadingMarkupWithApostrophe.txt` 64 /// 65 /// Set this for an affix on a whole cluster. You don't want to mess with people's quoting just 66 /// because they put it in a cluster prefix. They know their style better than we do. For 67 /// fields on a reference it's very different. 68 pub is_external: bool, 69 70 /// For affixes. 71 pub no_parse_quotes: bool, 72 } 73 74 impl IngestOptions { for_affixes() -> Self75 pub(crate) fn for_affixes() -> Self { 76 IngestOptions { 77 no_parse_quotes: true, 78 ..Default::default() 79 } 80 } 81 } 82 83 mod text_case; 84 pub mod lazy; 85