Remove *all* text after a newline in title
parent
1702e908ba
commit
136d422a33
2
API.md
2
API.md
|
@ -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
|
||||
|
|
10
init.lua
10
init.lua
|
@ -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. ]]
|
||||
|
|
Loading…
Reference in New Issue