stats: add edition information to page 1

Edition information is conditional based on there being more than
one edition present. It is printed on the same line as Chapters to
save vertical space.
This commit is contained in:
LaserEyess 2020-04-15 13:22:35 -04:00 committed by Julian
parent ace169ad0f
commit c364879e9f
1 changed files with 13 additions and 1 deletions

View File

@ -475,9 +475,21 @@ local function add_file(s)
local fs = append_property(s, "file-size", {prefix="Size:"}) local fs = append_property(s, "file-size", {prefix="Size:"})
append_property(s, "file-format", {prefix="Format/Protocol:", nl=fs and "" or o.nl}) append_property(s, "file-format", {prefix="Format/Protocol:", nl=fs and "" or o.nl})
local editions = mp.get_property_number("editions")
local edition = mp.get_property_number("current-edition")
local ed_cond = (edition and editions > 1)
if ed_cond then
append_property(s, "edition-list/" .. tostring(edition) .. "/title",
{prefix="Edition:"})
append_property(s, "edition-list/count",
{prefix="(" .. tostring(edition + 1) .. "/", suffix=")", nl="",
indent=" ", prefix_sep=" ", no_prefix_markup=true})
end
local ch_index = mp.get_property_number("chapter") local ch_index = mp.get_property_number("chapter")
if ch_index and ch_index >= 0 then if ch_index and ch_index >= 0 then
append_property(s, "chapter-list/" .. tostring(ch_index) .. "/title", {prefix="Chapter:"}) append_property(s, "chapter-list/" .. tostring(ch_index) .. "/title", {prefix="Chapter:",
nl=ed_cond and "" or o.nl})
append_property(s, "chapter-list/count", append_property(s, "chapter-list/count",
{prefix="(" .. tostring(ch_index + 1) .. "/", suffix=")", nl="", {prefix="(" .. tostring(ch_index + 1) .. "/", suffix=")", nl="",
indent=" ", prefix_sep=" ", no_prefix_markup=true}) indent=" ", prefix_sep=" ", no_prefix_markup=true})