I have made a post with a ul list. node_teaser() chopped it off after the first

leaving an open ul list on my frontpage which ceased to validate properly.

Comments

jhriggs’s picture

I think it is a little much to expect node_teaser() to properly handle every type of HTML block tag (table, ul, ol, etc.). When blocks like this are used, I always use a <!--break--> to specify exactly where the break should occur (usually before or after the block element).

killes@www.drop.org’s picture

I _wanted_ the split to be after the first of the lis. I could not make it that way by using the break tag. I would have needed to close the ul and open a new one for the rest of the body. Don't know how this displays on the node/view view.

This workaround wouldn't work at all for ols.

So I guess we need some additional logic in node_teaser, run the htmlcorrector module, or offer another way to construct the teaser.

jonbob’s picture

In my opinion, node_teaser() should have code added to close any open tags after it does its truncation, or htmlcorrector should be folded into core.

Steven’s picture

Htmlcorrector is functional, but it's not written for speed. It really needs a good rewrite (note: I wrote htmlcorrector ;) ).

We cannot do such HTML validation in node_teaser though, because we have no guarantee that the unfiltered text is in fact intended to be HTML. Even without the input formats filter patch, an admin can choose to escape all HTML so that it appears literally. Alternatively he/she could be using something like textile for markup.

In those cases, we will be modifying the actual content when we close any HTML-like structures in the body.

boris mann’s picture

Status: Active » Closed (works as designed)

Use break tags.

killes@www.drop.org’s picture

Break tags won't fix this as outlined http://drupal.org/node/8456#comment-8620
This is pretty much non-fixable inside node_teaser() as the discussion has shown. The proper solution would probably be to use excerpt.module.

sjs’s picture

Hi.

I replaced node_teaser with a function found from this site:
http://www.phpinsider.com/smarty-forum/viewtopic.php?p=3349

So far it seems to work fine..