[TYPO3-dev] cropHtml as new Feature for stdWrap
Steffen Kamper
steffen at dislabs.de
Mon Jan 8 10:51:39 CET 2007
Hi Masi,
"Martin Kutschker" <martin.kutschker-n0spam at no5pam-blackbox.net> schrieb im
Newsbeitrag
news:mailman.1.1168180573.18161.typo3-dev at lists.netfielders.de...
> Steffen Kamper schrieb:
>> Hi,
>>
>> I developed a function that allows cropHtml taking care of open tags.
>> I postet it here:
>> http://bugs.typo3.org/view.php?id=4747
>
> Is the output any different from strip_tags()? Besides it relies on the
> DOM XML functions which may not be availabe if you haven't installed the
> PECL lib.
>
of cause - the output gives you html!
> Besides what IMHO would make more sense is a sensitive cropping. Basically
> there are two modes for cropping: crop to a given number of displayed
> characters (glyphs) or a number of bytes. In the latter case you must also
> take into account the character set (eg utf-8).
>
ok, this is no problem to extend it with a given charset.
> I will only address the former, suitable for content preview (eg news
> teaser or fulltext search results), which cares only about displayed
> characters and doesn't count the html tags.
the function counts only the displayed chars, not the tags or chars in the
tagss
>
> What should be done is this assuming well formed (X)HTML:
this has to be given anyway.
>
> Scan the content and count only the lengths of the text nodes. While doing
> this collect the opened tags on a stack. If the maximum character length
> is reached add the crop chars (eg "...") and close all open tags using the
> tag stack.
>
> Masi
that is exactly what this function does !
vg Steffen
More information about the TYPO3-dev
mailing list