Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
If your news articles tend to be really big, such that fetching the whole story text every time would be a hindrance for your application, you might want to consider how important it really is to try to preserve html markup in an initial 200 characters for your "sample" display.
In effect, I think your choices are:
Either way, you would be counting only the displayable characters (although in the first approach, with most html formatting preserved, the display space taken up by the 200 characters would vary with the formatting). Of course, if there are lots of character entity references in the text, you probably want a way to count each as "one character"... So think about the desired output: what really makes the most sense, in your app, for that "sample" display? Maybe you want to do stuff like replacing certain tags with particular punctuation (e.g. "ul" and "ol" with emdash, "li" with asterisk, "hN" with underscore, "p" with "/", or whatever). That way, the formatting counts for something in the final result, but in a controlled and consistent way. (updated to fix grammar) In reply to Re: Clipping text in the middle of an open HTML tag
by graff
|
|