Remove *all* text after a newline in title

master
Wuzzy 2020-03-10 17:19:00 +01:00
parent 1702e908ba
commit 136d422a33
2 changed files with 8 additions and 4 deletions

2
API.md
View File

@ -42,7 +42,7 @@ easy and quick manipulation of the item help entries. All fields are optional.
* `_doc_items_hidden`: Whether entry is hidden (default: `false` for air and hand, `true` for everything else)
* `_doc_items_create_entry`: Whether to create an entry for this item (default: `true`)
* `_doc_items_entry_name`: The title of the entry. By default, this is the same as the `description` field
of the item. This field is required if the `description` is empty
of the item (discarding text after the first newline). This field is required if the `description` is empty
* `_doc_items_durability`: This field is for describing how long a tool can be used before it breaks. Choose one data type:
* It it is a `number`: Fixed number of uses before it breaks
* If it is a `string`: Free-form text which explains how the durability works. Try to keep it short and only use it if the other types won't work

View File

@ -65,10 +65,14 @@ local groups_to_string = function(grouptable, filter)
end
end
-- Replaces all newlines with spaces
-- Removes all text after the first newline (including the newline)
local scrub_newlines = function(text)
local new, x = string.gsub(text, "\n", " ")
return new
local spl = string.split(text, "\n")
if spl and #spl > 0 then
return spl[1]
else
return text
end
end
--[[ Append a newline to text, unless it already ends with a newline. ]]