Visual editor adding <p> tag automatically

Topics: Feature requests, General, Troubleshooting, Visual editor
Mar 15, 2011 at 9:27 PM
Whenever the user edits a page and tries to set the content with the visual editor it will wrap that content inside paragraph tags. I think I understand correctly that everything needs to be inside a tag but is there somewhere I can go to change this default from the <p> tag to the <span> tag since the <span> tag does not result in unwanted styling being applied? Text within a <span> tag will not introduce line breaks or any other unnecessary styling but <p> tags will. Thanks for any help on the subject, telling the user that's how it was built and if it is a problem then just go into the source and remove them is not cutting it anymore.
Coordinator
Mar 15, 2011 at 10:10 PM

I faced similar problem, but in my case I needed to replace <p> tags with <span>-s in order to the result into a <a></a> tag. I solved it by adding a small xslt function that was converting <p> tags to <span>-s, it's pretty late in Denmark, I'll find and post the code I used tomorrow.

Coordinator
Mar 15, 2011 at 11:20 PM

Info on how you can modify the HTML from the Visual Editor: http://docs.composite.net/C1/XSLT/XSLTFAQ.aspx?q=How+can+I+modify+the+HTML+from+the+Visual+Content+editor%3f and http://docs.composite.net/C1/Videos.aspx?video=VdlbSTr4ytc

Mar 15, 2011 at 11:22 PM

Thanks for the reply but I think I have fixed my problem by explicitly setting a style that I was not aware existed by default.

Anyone else looking to fix this can put the following in their style sheet.

p {
margin: 0px;
}
Coordinator
Mar 16, 2011 at 9:09 AM

Any way, there's a change that somebody will need the code:

 

In layout:

<f:function name="Container.RemovePTags">
	<f:param name="Content">
		<rendering:placeholder id="contentplaceholder" title="Content" default="false" />
	</f:param>
</f:function>

 

 

And there's an xslt function Container.RemovePTags, which should have a string parameter "Content", and has the following template:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl in mp csharp"
	xmlns:in="http://www.composite.net/ns/transformation/input/1.0"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:xhtml="http://www.w3.org/1999/xhtml"
	xmlns:msxsl="urn:schemas-microsoft-com:xslt"
	xmlns:mp="#MarkupParserExtensions">
 
	<xsl:param name="content" select="/in:inputs/in:param[@name='Content']" />
	
	<xsl:template match="/">
		<html>
			<head>
				<!-- markup placed here will be shown in the head section of the rendered page -->
			</head>
			<body>
				<xsl:apply-templates select="mp:ParseWellformedDocumentMarkup($content)" mode="CopyWithoutPTags" />
			</body>
		</html>
	</xsl:template>

	<xsl:template match="@* | node()" mode="CopyWithoutPTags">
		<xsl:copy>
			<xsl:apply-templates select="@* | node()" mode="CopyWithoutPTags" />
		</xsl:copy>
	</xsl:template>

	<xsl:template match="xhtml:p" mode="CopyWithoutPTags">
		<xsl:apply-templates select="node()" mode="CopyWithoutPTags" />
	</xsl:template>

	<xsl:template match="p" mode="CopyWithoutPTags">
		<xsl:apply-templates select="node()" mode="CopyWithoutPTags" />
	</xsl:template>

</xsl:stylesheet>

Dec 15, 2016 at 12:46 PM
Hello everyone. I have similar bug on the editor. I'm using orchestra CMS and i'm installing new updates. So my question is: do i can to add this solution to prevent empty divs appearance? Is this solution is suitable for problem when divs with &nbsp of 160 appears? And will it be normally updated if a change config file of visual editor? Thank you for your fast reply.