Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/lua/document.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,14 @@ function Document.renumber(self: Document)
local wc = 0
local pn = 1

--i think i fixed the page count bug?

for _, p in ipairs(self) do
wc = wc + #p
for _, word in ipairs(p) do
if GetWordText(word) ~= "" then
wc = wc +1
end
end

local style = documentStyles[p.style]
if style.numbered then
Expand Down
10 changes: 9 additions & 1 deletion src/lua/fileio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ local escape = wg.escape
local unescape = wg.unescape
local string_format = string.format
local unpack = rawget(_G, "unpack") or table.unpack
-- bound this for page count bug fix
local GetWordText = wg.getwordtext

local MAGIC = "WordGrinder dumpfile v1: this is not a text file!"
local ZMAGIC = "WordGrinder dumpfile v2: this is not a text file!"
Expand Down Expand Up @@ -721,8 +723,14 @@ function UpgradeDocument(oldversion)
for _, document in ipairs(documentSet.documents) do
local wc = 0

-- page count bug fix

for _, p in ipairs(document) do
wc = wc + #p
for _, word in ipairs(p) do
if GetWordText(word) ~= "" then
wc = wc + 1
end
end
end

document.wordcount = wc
Expand Down