Cmenu Newline After Closing Tag

Why is CMenu putting newlines in my lists? It adds a newline after closing every ‘li’ or ‘ul’ tag and newlines surrounding nearly every “<ul options… >” (first one only has a newline after)? The white space is injecting unwanted space into my menu system. I’m tempted to edit CMenu.php and take out the 5 “\n” pieces, but I don’t want to maintain my own bug fixes to Yii or keep an extension up to date. If nothing else, it’s slightly less efficient code producing slightly less efficient html.

I can work around this by floating the list items to the left, but that notoriously causes other CSS problems, which seem to cascade into a mess that I cannot fix. Conceptually, I think of the menu items as inline-block objects, not some floating block that I want everything to flow around.

Is there any other good fix, or should I just edit CMenu.php? I’m hoping there’s something simple in Yii to prevent the spaces from being put there in the first place, but I’m not seeing anything from reading the code.

What kind of problem could this new line charaters add to your code?

HTML skip \n charater.

The newline is white space, which renders as a space between my <li> elements when they’re displayed as inline-block elements. Imagine placing a blue menu bar on a white background and having white gaps in the bar. My menus rely on previously set font sizes, so setting the size to 0 for the space won’t work.

I’m not sure I understand your second line. Are you saying there’s a way to stop Yii from outputting newline characters? I’ve looked at the code for CMenu, and I don’t see anything. For now, the newlines have just been remove from my CMenu.php file.

There’s a “text-space-collapse” property being discussed for CSS4, which will do the trick, but that doesn’t do me much good now. (I would share a link, but the forums say I’m too new)

you can trim the titles content while adding into menu

It’s not in the menu titles. It’s a newline in between the <li> items; put there by echo statements in CMenu.