1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-12-23 15:20:19 +01:00

Books: Convert \r to \n

Some files or editors may use \r instand of \n like notepad++. If you copy
text written in notepad++ and pasted into the book. The book will only have
one page.
This commit is contained in:
Coder12a 2017-10-15 19:09:26 -07:00 committed by sfan5
parent 532013a032
commit 7d07c52d09

View File

@ -112,6 +112,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
data.description = "\""..short_title.."\" by "..data.owner data.description = "\""..short_title.."\" by "..data.owner
data.text = fields.text:sub(1, max_text_size) data.text = fields.text:sub(1, max_text_size)
data.text = data.text:gsub("\r\n", "\n"):gsub("\r", "\n")
data.page = 1 data.page = 1
data.page_max = math.ceil((#data.text:gsub("[^\n]", "") + 1) / lpp) data.page_max = math.ceil((#data.text:gsub("[^\n]", "") + 1) / lpp)