Skip to content

Commit

Permalink
Check APA examples
Browse files Browse the repository at this point in the history
Fix nil page-first error

BibTeX parser: Fix hyphen in family name

Fix bugs in EDTF parsing

Add test for name initialization

Enhance bib2csl translator

TMP add APA tests (should be reverted later)

Resolve empty genre for thesis

Bib2csl: Resolve related entry

Fixup genre for thesis

Fixup reviewed title

Bib2csl: Add support for manuscript genre

Bib2csl: Update mapping

Bib2csl: Update mapping

Bib2csl: Update mapping of "titleaddon"

Fix escaping LaTeX in output

Bib2csl: Fix words after colons in sentence case conversion

Bib2csl: Fix tv series

Bib2csl: Fix mappings in song type

Bib2csl: Fix mappings in broadcast type

Bib2csl: Fix mappings in audio works

Bib2csl: Fix mappings in visual works

Bib2csl: Fix container-title of webpages

Fix typos

Add notes
  • Loading branch information
zepinglee committed Jul 27, 2024
1 parent b09b2b4 commit b8b3929
Show file tree
Hide file tree
Showing 17 changed files with 3,185 additions and 120 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add support for multiple bibliographies (`refsection` environment).
- Add global `ref-section` option.
- Add support for `biber`'s `%`-style inline comment in `.bib` files.

### Fixed

- Fix an infinite loop bug of unrecognized `babel` language name ([#65](https://github.com/zepinglee/citeproc-lua/issues/65)).
- BibTeX parser: Fix hyphen in family name.
- Fix a bug in EDTF parsing.
- Bib2csl: Fix a sentence case conversion bug that words after colons are not capitalized.

## [0.5.1] - 2024-07-10

Expand All @@ -29,13 +33,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `\fullcite` command ([#64](https://github.com/zepinglee/citeproc-lua/issues/64)).
- Add support for annotated bibliography ([#64](https://github.com/zepinglee/citeproc-lua/issues/64)).

## Changed
### Changed

- Check if the `\cite` command is in a footnote.

## [0.4.9] - 2024-04-21

## Added
### Added

- Add normal paragraph style for list of references ([#60](https://github.com/zepinglee/citeproc-lua/discussions/60)).

Expand Down
10 changes: 5 additions & 5 deletions citeproc/citeproc-bibtex-data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1691,8 +1691,8 @@ return {
type = "entrykey",
},
entrysubtype = {
csl = nil,
notes = "Not supported.",
csl = "genre",
notes = "May be used to determine the entry type (article-magazine).",
source = "biblatex",
type = "literal",
},
Expand Down Expand Up @@ -3182,8 +3182,8 @@ return {
type = "option",
},
relatedstring = {
csl = nil,
notes = "Not supported.",
csl = "genre",
notes = "The style apa.csl assumes that `genre` is entered as “Review of the book” or similar.",
source = "biblatex",
type = "literal",
},
Expand Down Expand Up @@ -3778,7 +3778,7 @@ return {
type = "literal",
},
titleaddon = {
csl = nil,
csl = "genre",
source = "biblatex",
type = "literal",
},
Expand Down
36 changes: 19 additions & 17 deletions citeproc/citeproc-bibtex-parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ end

-- Based on the grammar described at <https://github.com/aclements/biblib>.
local function get_bibtex_grammar()
local comment = (1 - P"@")^0
local space = S(" \t\r\n")^0
local inline_comment = P"%" * (1-P"\n")^0 * P"\n"
local comment = (inline_comment + 1 - P"@")^0
-- local ws = S(" \t\r\n")^0
local ws = (S" \t\r\n" + inline_comment)^0
local comment_cmd = case_insensitive_pattern("comment")
local balanced = P{ "{" * V(1)^0 * "}" + (1 - S"{}") }
local ident = (- R"09") * (R"\x20\x7F" - S" \t\"#%'(),={}")^1
Expand All @@ -74,31 +76,31 @@ local function get_bibtex_grammar()
name = string.lower(name),
}
end
local value = Ct(piece * (space * P"#" * space * piece)^0)
local value = Ct(piece * (ws * P"#" * ws * piece)^0)

local string_body = Cg(ident / string.lower, "name") * space * P"=" * space * Cg(value, "contents")
local string_cmd = Ct(Cg(Cc"string", "category") * case_insensitive_pattern("string") * space * (
P"{" * space * string_body * space * P"}"
+ P"(" * space * string_body * space * P")"
local string_body = Cg(ident / string.lower, "name") * ws * P"=" * ws * Cg(value, "contents")
local string_cmd = Ct(Cg(Cc"string", "category") * case_insensitive_pattern("string") * ws * (
P"{" * ws * string_body * ws * P"}"
+ P"(" * ws * string_body * ws * P")"
))

local preamble_body = Cg(value, "contents")
local preamble_cmd = Ct(Cg(Cc"preamble", "category") * case_insensitive_pattern("preamble") * space * (
P"{" * space * preamble_body * space * P"}"
+ P"(" * space * preamble_body * space * P")"
local preamble_cmd = Ct(Cg(Cc"preamble", "category") * case_insensitive_pattern("preamble") * ws * (
P"{" * ws * preamble_body * ws * P"}"
+ P"(" * ws * preamble_body * ws * P")"
))

local key = (1 - S", \t}\r\n")^0
local key_paren = (1 - S", \t\r\n")^0
local field_value_pair = (ident / string.lower) * space * P"=" * space * value -- * record_success_position()
local field_value_pair = (ident / string.lower) * ws * P"=" * ws * value -- * record_success_position()

local entry_body = Cf(Ct"" * (P"," * space * Cg(field_value_pair))^0 * (P",")^-1, rawset)
local entry = Ct(Cg(Cc"entry", "category") * Cg(ident / string.lower, "type") * space * (
P"{" * space * Cg(key, "key") * space * Cg(entry_body, "fields")^-1 * space * (P"}")
+ P"(" * space * Cg(key_paren, "key") * space * Cg(entry_body, "fields")^-1 * space * (P")")
local entry_body = Cf(Ct"" * (P"," * ws * Cg(field_value_pair))^0 * (P",")^-1, rawset)
local entry = Ct(Cg(Cc"entry", "category") * Cg(ident / string.lower, "type") * ws * (
P"{" * ws * Cg(key, "key") * ws * Cg(entry_body, "fields")^-1 * ws * (P"}")
+ P"(" * ws * Cg(key_paren, "key") * ws * Cg(entry_body, "fields")^-1 * ws * (P")")
))

local command_or_entry = P"@" * space * (comment_cmd + preamble_cmd + string_cmd + entry)
local command_or_entry = P"@" * ws * (comment_cmd + preamble_cmd + string_cmd + entry)

-- The P(-1) causes nil parsing result in case of error.
local bibtex_grammar = Ct(comment * (command_or_entry * comment)^0) * P(-1)
Expand Down Expand Up @@ -440,7 +442,7 @@ function bibtex_parser._split_extended_name_format(parts)
end

function bibtex_parser._split_first_von_last_parts(str)
local word_sep = P"-" + P"~" + P(util.unicode['no-break space'])
local word_sep = P" " + P"~" + P(util.unicode['no-break space'])
local word_tokens = Ct(C(utf8_balanced - space_char - word_sep)^0)
local words_and_seps = Ct(word_tokens * (C(space + word_sep) * word_tokens)^0)
local pieces = words_and_seps:match(str)
Expand Down
Loading

0 comments on commit b8b3929

Please sign in to comment.