From 9f8717c88a4e766720798393159a6bfc5f57e007 Mon Sep 17 00:00:00 2001 From: Michael Goerz Date: Thu, 14 Nov 2024 12:32:36 -0500 Subject: [PATCH] Compatibility with BibInternal v0.3.7 --- Project.toml | 2 -- src/formatting.jl | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 27bb784..1392442 100644 --- a/Project.toml +++ b/Project.toml @@ -5,7 +5,6 @@ version = "1.3.4+dev" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" -BibInternal = "2027ae74-3657-4b95-ae00-e2f7d55c3e64" Bibliography = "f1be7e48-bf82-45af-a471-ae754a193061" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" @@ -17,7 +16,6 @@ Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [compat] AbstractTrees = "0.4" -BibInternal = "=0.3.6" Bibliography = "0.2.15" Dates = "1" Documenter = "1" diff --git a/src/formatting.jl b/src/formatting.jl index bce290d..f81026f 100644 --- a/src/formatting.jl +++ b/src/formatting.jl @@ -304,7 +304,7 @@ function format_published_in( else @assert entry.type == "unpublished" "Unexpected type $(repr(entry.type))" # @unpublished should be rendered entirely via the Note field. - if isempty(get(entry.fields, "note", "")) + if !has_note(entry) @warn "unpublished $(entry.id) does not have a 'note'" end end @@ -512,8 +512,23 @@ function format_vol_num_series( end +function has_note(entry) + if hasproperty(entry, :note) + return !isempty(entry.note) + else + return !isempty(get(entry.fields, "note", "")) + end +end + + function format_note(entry) - return strip(get(entry.fields, "note", "")) |> tex_to_markdown + if hasproperty(entry, :note) + # BibInternal v0.3.7 + return strip(entry.note) |> tex_to_markdown + else + # BibInternal <=v0.3.6 + return strip(get(entry.fields, "note", "")) |> tex_to_markdown + end end