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
1 changed files with 1 additions and 0 deletions

View File

@ -112,6 +112,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
data.description = "\""..short_title.."\" by "..data.owner
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_max = math.ceil((#data.text:gsub("[^\n]", "") + 1) / lpp)