Implement function to prune string keeping HTML closing tags#1870
Conversation
paskal
left a comment
There was a problem hiding this comment.
Looks good! Could you please move the prune function to a different file? It's not telegram-specific and now increases complexity of telegram file without necessity.
0585517 to
c16c2bf
Compare
|
Sure. Sorry for the long wait Moved function to separated file and rebased my branch onto current master |
|
I don't know why build fails on CI/CD. Locally I can do both |
fixed, passed |
|
I have generated some unit tests, as the one it had didn't seem too convincing to me. |
|
pls note - the test is generated to match the code behavoir, however some of them look strange to me. for example this one {
name: "text exceeding limit",
html: "<p>Hello world, this is a long text</p>",
maxLength: 15,
expected: "<p>...</p>",
},I have not checked the code closely but the common sense expectation would be @aliksend can you take a look pls and adjust tests/code if needed? |
|
Current implementation will generate string |
2e1dda5 to
e2cf233
Compare
e2cf233 to
4b6e3ce
Compare
remove unneeded comment
Introduce comprehensive test cases for stringArr methods (Push, Pop, Unshift, Shift, String) to ensure correct behavior and state management. Additionally, add tests for HTML pruning functions (pruneHTML, pruneStringToWord) to validate handling of length constraints and formatting scenarios.
4b6e3ce to
f5d591f
Compare
- Fix bug where HTML tags were counted toward the character limit instead of only visible text content - Add pruning for parent comment text in Telegram notifications - Simplify pruneStringToWord using strings.LastIndex - Remove unused stringArr type and its tests - Consolidate and simplify test cases
paskal
left a comment
There was a problem hiding this comment.
- Fixed pruneHTML to count only visible text (not HTML tags) toward the limit
- Added pruning for parent comment text
- Simplified code and tests (removed 306 lines net)
LGTM now.
Fixes #1587