Books: Convert \r to \n
authorCoder12a <32314020+Coder12a@users.noreply.github.com>
Mon, 16 Oct 2017 02:09:26 +0000 (19:09 -0700)
committersfan5 <sfan5@live.de>
Sun, 19 Nov 2017 22:03:38 +0000 (23:03 +0100)
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.

mods/default/craftitems.lua

index e4a93ae58d8833997fbb538b0122f3f9d9c4affc..e1d224d1004359c660598be40a24fe3fe95df9c9 100644 (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)