By: codeless
Date: 2014-09-12
Time: 09:02
|
maxhtml operator failing in 3.8.1, 3.8.2 and 3.9.0
Hi!
The maxhtml-operator is not working as expected;
When having the input "Lorem ipsum<a href=#>link</a>", the result is correct: 'Lorem ips...'
But when the input is "Lorem <a href=#>ipsum</a> dolor sit amet.", the result should be: 'Lorem <a href=#>ips...</a>'
I use the following test:
/**
* Tests the TinyButStrong template engine
*/
class TBSTest extends PHPUnit_Framework_TestCase
{
/**
* With TBS it's possible to strip texts to a specific length, f.i. the command
*
* [onshow.description;ope=max:10;maxhtml]
*
* will strip the caption to 10 characters, but should not destroy HTML tags
* which are probably located at character 10.
*
* @dataProvider provideMaxHTML
*/
public function testMaxHTMLOperation(
$htmltext,
$expectedOutput,
$template='[onshow.htmltext;strconv=utf8;ope=max:10;maxhtml]')
{
$TBS = new clsTinyButStrong;
# Set variable
$GLOBALS['htmltext'] = $htmltext;
# Directly set source
$TBS->Source = $template;
# Run plugins, if any:
$TBS->LoadTemplate(null);
# Process
$TBS->Show(TBS_NOTHING);
# Get final HTML:
$actualOutput = $TBS->Source;
$this->assertEquals($expectedOutput, $actualOutput);
}
public function provideMaxHTML()
{
return array(
array('Lorem ipsum<a href=#>link</a>', 'Lorem ips...'),
array( 'Lorem <a href=#>ipsum</a> dolor sit amet.',
'Lorem <a href=#>ips</a>...'),
);
}
};
|
|
By: Skrol29
Date: 2014-09-14
Time: 20:26
|
Re: maxhtml operator failing in 3.8.1, 3.8.2 and 3.9.0
Hi Codeless,
But it would be a huge work to analyze formally the HTML content, and to be able to cut a correctly string.
An HTML content can have many embedded <div> , <span>, and even <table>.
That's why TBS applies a quite simple analysis for reading the string contained in the HTML.
If a stronger analysis is needed, it can be coded using a "onformat" function.
|
By: codeless
Date: 2014-09-14
Time: 20:52
|
Re: maxhtml operator failing in 3.8.1, 3.8.2 and 3.9.0
Hi Skrol!
Yes, it would be a huge work; so i misunderstood the maxhtml operator, it seems? Can you give me a usecase for maxhtml?
Thanks!
|
By: Skrol29
Date: 2014-09-17
Time: 14:06
|
Re: maxhtml operator failing in 3.8.1, 3.8.2 and 3.9.0
Hi,
Parameter "maxhtml" only indicates that HTML characters (that is special text items starting with "&" and endding with ";") are taken in account and are considered as a single characters.
Parameter "maxhtml" has no different consideration for special HTML characters such as "<" or ">".
Parameter "maxhtml" has no different consideration for HTML tags and HTML entities.
|
By: codeless
Date: 2014-09-17
Time: 14:39
|
Re: maxhtml operator failing in 3.8.1, 3.8.2 and 3.9.0
Aye! Maybe you could note this in the docs also. Thx!
|
By: Skrol29
Date: 2014-09-17
Time: 15:02
|
Re: maxhtml operator failing in 3.8.1, 3.8.2 and 3.9.0
Yes, of course I agree.
Ii will be updated soon.
|
|
Posting in progress.
Please wait...
|