CSS styled Content und der RTE
Die Extension CSS styled content ist weit verbreitet und beliebt. Jedoch wünschen viele TYPO3 Benutzer die Standardeinstellungen ihren Bedürfnissen anzupassen.
- wie entferne ich die Klasse class="bodytext" von den <p> Tags?
- wie entferne ich die Klasse class="contenttable" von den <table> Tags?
Das sind die häufigen Fragen. Wir versuchen, etwas Übersicht ins Dickicht der TypoScript Konfiguration zu bringen.
Der TypoScript Objekt Pfad für CSS styled content ist: lib.parseFunc_RTE.
In der Extension css_styled_content ist in der Datei typo3/sysext/css_styled_content/static/setup.txt folgendes konfiguriert:
# Creates persistent ParseFunc setup for RTE content (which is mainly HTML) based on the "ts_css" transformation.
lib.parseFunc_RTE < lib.parseFunc
lib.parseFunc_RTE {
// makelinks >
# Processing <table> and <blockquote> blocks separately
externalBlocks = table, blockquote, ol,ul
externalBlocks {
# The blockquote content is passed into parseFunc again...
blockquote.stripNL=1
blockquote.callRecursive=1
blockquote.callRecursive.tagStdWrap.HTMLparser = 1
blockquote.callRecursive.tagStdWrap.HTMLparser.tags.blockquote.overrideAttribs = style="margin-bottom:0;margin-top:0;"
ol.stripNL=1
ol.stdWrap.parseFunc = < lib.parseFunc
ul.stripNL=1
ul.stdWrap.parseFunc = < lib.parseFunc
table.stripNL=1
table.stdWrap.HTMLparser = 1
table.stdWrap.HTMLparser.tags.table.fixAttrib.class {
default = contenttable
always = 1
list = contenttable
}
table.stdWrap.HTMLparser.keepNonMatchedTags = 1
table.HTMLtableCells=1
table.HTMLtableCells {
default.callRecursive=1
addChr10BetweenParagraphs=1
}
}
nonTypoTagStdWrap.encapsLines {
encapsTagList = div,p,pre,h1,h2,h3,h4,h5,h6
remapTag.DIV = P
nonWrappedTag = P
innerStdWrap_all.ifBlank =
addAttributes.P.class = bodytext
addAttributes.P.class.setOnly=blank
}
nonTypoTagStdWrap.HTMLparser = 1
nonTypoTagStdWrap.HTMLparser {
keepNonMatchedTags = 1
htmlSpecialChars = 2
}
}
Lösungen
Die Klasse class="bodytext" von den <p> Tags entfernen:
lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.addAttributes.P.class >
Tags, die nicht mit einem zusätzlichen <p> Tag umgeben werden, sollen zur Liste hinzufügen:
lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.encapsTagList := addToList(table,tr,td)
<div> Tags sollen nicht in <p> Tags umgewandelt werden:
lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.remapTag >
Alle Zeilen, die nicht mit Tags umgeben sind, werden mit den angegebenen Tags umgeben:
Beispiel:
aus:
etwas Text
<p>mehr Text</p>
wird:
<p>etwas Text</p>
<p>mehr Text</p>
lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.wrapNonWrappedLines = <p>|</p>
Wenn eine Tabelle <table> eine Klasse <table class="name"> hat, wird diese verwendet, sonst class="contenttable":
lib.parseFunc_RTE.externalBlocks.table.stdWrap.HTMLparser.tags.table.fixAttrib.class.list >
Alle (!) <p> Tags in einer Tabelle entfernen
lib.parseFunc_RTE.externalBlocks.table.stdWrap.HTMLparser.removeTags = p
Liste von HTML Tags die im Code erlaubt sind.
Der Eintrag in allowTags hat eine höhere Priorität als denyTags. Ein konkurierender Eintrag in denyTags wird also ignoriert.
lib.parseFunc.allowTags = a,abbr,acronym,address,b,bdo,blockquote,br,cite,code,del,div,em,h1,h2,h3,h4,h5,h6,hr,i,img,li,ol,p,span,strike,strong,sub,sup,u,ul
lib.parseFunc_RTE.allowTags < lib.parseFunc.allowTag
