-
Notifications
You must be signed in to change notification settings - Fork 107
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
TruncateHtml #30
TruncateHtml #30
Conversation
New-lines after PSR links
Fixed typo
Fixed typo :)
Addition of Afrikaans (af) language translation (with spec tests)
@smeeckaert nice! Give me some time to check that code. |
Addition of Portuguese (pt) language translation (with spec tests)
Add Norwegian translation
Updating comma Updating readme
…pend Truncate check length of append
Awesome! |
Oxford collection + phpcs fixer cleanup.
Oxford italian translations
Add Dutch Oxford translations.
Yup, that seems a good idea, i will probably make it today, what would be the correct naming of the Interface in the project ? Coduo\PHPHumanizer\String\Truncate\Interface ? or Coduo\PHPHumanizer\String\Interface\Truncate ? |
Change string functions into multibyte string functions
Well I would like to avoide word "Interface" at all. Maybe just
|
Okay great. |
Okay, so i've changed the truncate and added an interface. I've renamed classes to HtmlTruncate and TextTruncate and added a method setBreakpoint to define the breakpoint. I've created a Breakpoint interface and created a WordBreakpoint class which uses the current mechanism in order to find a breakpoint. I let only one protected method which is TextTruncate::getLength to reuse the breakpoint mechanism of TextTruncate in HtmlTruncate. I'm not sure that's 100% what you could want, so tell me if everything is right. |
* | ||
* @return int | ||
*/ | ||
public function len($text, $charactersCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please change name of this method into calculatePosition($text, $charactersCount)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There is also one problem with this PR and we need to think how to solve it. Changing What we can do with that:
@defrag @smeeckaert what do u guys think? |
Fixes a typo in French
…to smeeckaert-master Conflicts: src/Coduo/PHPHumanizer/String/Truncate.php
We should make Truncate extends WordTruncate, no ? That way the class Truncate keeps its old behaviour. |
Actually I have been working on that now, please take a look norberttech@93a09b7 |
Yeah it changes the concept quite extensively (no __toString magic), but yeah, keeping the old code is an idea. But maybe replace the Truncate::construct to instanciate a WordTruncate and using it in the __toString would be a better idea, it's less code to maintain and provides the correct "new way" to do things. |
The old way with __toString has one problem, Truncate object exists only for one specific text. Its something that I would like to change. |
Yeah, i'm with you, i'm not particularly fan of magic function in general because it hides features, mess with code completion, and force strange-ish syntax, like type-cast in php that is not so common. I wholehearly agree with this change, more so when we add dependancies like the Breakpoint in the equation. |
Do you think you could take code that I made and finish it in this branch? I'm quite busy now and dont think gonna have much time until next few weeks |
I'm on it. |
It should be bugfixed, now. |
wow that was fast! Thanks @smeeckaert, good job! |
Super interested in seeing this added! Currently looking for an alternative to PHPTidy! 👍 🌴 |
@smeeckaert could you please remove default allowed tags? It would be much more flexible to allow users precise their own allowed tags, also its gonna be easier to maintain for us later without any BC Breakes. |
It's done. |
@smeeckaert thanks for your awesome work! 🍻 I rebased code and merged it manualy. |
I've implemented a html truncate based FuelPHP truncate function, with breakpoint management. I'm not exactly sure of the code style and hope it's okay.
Changes
This PR add a TruncateHTML class which extends from Truncate, it has the capability to truncate HTML by keeping some tags or removing them all together. It supports the breakpoints and append.
This PR changes the Truncate class by changing the visibility of the properties are refactoring the breakpoint mechanism in order for it to be reusable.
Code example