Skip to content

Join sentence fields and separate joined fields by newline#136

Merged
tatsumoto-ren merged 4 commits into
Ajatt-Tools:masterfrom
emiham:better_field_join
Mar 31, 2025
Merged

Join sentence fields and separate joined fields by newline#136
tatsumoto-ren merged 4 commits into
Ajatt-Tools:masterfrom
emiham:better_field_join

Conversation

@emiham

@emiham emiham commented Mar 31, 2025

Copy link
Copy Markdown
Contributor

As discussed in #134.

A few thoughts:

  • Right now the separator is hardcoded to be a newline. I could see this being a config option, but I also don't really see the need for it.
  • There's a case to be made for skipping the separator for the image field, depending on what you want your cards to look like.

Comment thread helpers.lua Outdated
Comment on lines +280 to +287
this.match_substring = function(text, substring)
local escaped_substring = substring:gsub("([%W])", "%%%1")

return string.match(text, "^" .. escaped_substring .. "$")
or string.match(text, "^" .. escaped_substring .. "<br>")
or string.match(text, "<br>" .. escaped_substring .. "$")
or string.match(text, "<br>" .. escaped_substring .. "<br>")
end

@tatsumoto-ren tatsumoto-ren Mar 31, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need to check if substring is a substring of text, it's probably easier to just call string.find()

return string.find(text, substring, 1, true) ~= nil -- use plain searches

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but then you can get false positives. I think if you're joining foo bar and bar you should get foo bar<br>bar, not just foo bar.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the user can reformat the field any way they like, including inserting additional characters between subtitle lines. So I would only care about whether the substring is found or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll remove the helper function then since it would only be one line.

@tatsumoto-ren
tatsumoto-ren merged commit 1dc4b23 into Ajatt-Tools:master Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants