-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add keep_newlines argument to wrap_text #7728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If keep_newlines is true, every new line given in the input text is also contained in the output text.
the result should be a table containing strings not a table containing a table with strings
|
Well this looks more clean than #7232 |
0e3b135 to
39c54e1
Compare
|
Can this be added please? |
|
Testing mod: local texts = {
-- | 50 is here
[[
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy]],
[[eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo
dolores et ea rebum. Stet clita]]
}
print("core.line_break(text, 50)")
for i, text in ipairs(texts) do
local lines = core.line_break(text, 50)
print("\t" .. table.concat(lines, "\n\t"))
print("")
end
print("core.wrap_text(text, 50, true, newlines)")
for i, text in ipairs(texts) do
local lines = core.wrap_text(text, 50, true, true)
print("\t" .. table.concat(lines, "\t")) -- new lines contained
print("")
end
print("core.wrap_text(text, 50, true, no newlines)")
for i, text in ipairs(texts) do
local lines = core.wrap_text(text, 50, true, false)
print("\t" .. table.concat(lines, "\n\t"))
print("")
endBut it does not contain new lines? This is the output: |
|
The previously contained newlines were converted into table splits, I've added a note for that to the documentation. I can change the behavior so it wraps into table lines and puts the newlines in as characters if you want that. |
|
It would be great to have some unit tests for this, see the Also, this is yet another wrapping function in Minetest that #10853 could replace :'( |
|
https://irc.minetest.net/minetest-dev/2022-07-03#i_5990806 Concept approved. |
|
Hello @theFox6 , sorry for the delay. Now that the PR has been conceptually approved, do you think you can take care of the rebase? |
If keep_newlines is true, every new line given in the input text is also contained in the output text.