ckeditor removes <br/> when br is in allowed content - ckeditor

When I add br to ckeditor allowed content and adding <br> tag it is being changed into <br />
But when I add <br/> it is being removed.
Why is it being removed when br is in allowed content? Any suggestions?

There are some bits missing from your post, not sure why, or what you were trying to say.
If what you were saying is that you wanted to add, say, clear="all" to your <br /> tags, you can use this to update your allowed content:
config.AllowedContent = "br[clear]";
Separate individual elements with ;.
Here is the reference to the AllowedContent rules in the documentation:
http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules
I keep this bit in comments above my AllowedContent declaration as a reminder:
elements [attributes]{styles}(classes)
If that's not what you were asking, forgive me, again, there are some parts missing from your post. If you can update it and let me know I'll revisit this answer.
== EDIT ==
Ok, I just looked at the edit of the post, and it seems you had "naked" <br /> tags in your question, which turned into actual line breaks.
What you're seeing is that the editor is forcing valid HTML. BR tags should always be formatted as such: <br /> (notice the space)

Related

Typo3 close and start a new paragraph <p> in each <br /> in bodytext at news extension

I'm using Typo3 9.5.14 and CkEditor to add and edit news articles, i see in frontend that it is closing and starting a new paragraph at every in the bodytext area here an example :
<p>
Text somthing <br />
Text somthing 2 <br />
Text somthing 3 <br />
Text somthing 4 <br />
</p>
After save, i see in frontend is converted to this;
<p>Text somthing </p>
<p>Text somthing 2 </p>
<p>Text somthing 3 </p>
<p>Text somthing 4 </p>
But in source it is still in the original code even after save.
Is it really because CKEditor and how can i prevent this ?
This is causing the problem of adding new spaces between each line of text.
Possibly switch to direct source editing?
The other reason could be you need to allow tags in the editor configuration. Like this :
TYPO3 9.5.4 CKEditor RTE deletes style attributes
Hope it helps you
EDIT:
Does this setting still work in TYPO3 9? maybe that is it:
https://docs.typo3.org/m/typo3/reference-coreapi/7.6/en-us/Rte/Transformations/Tsconfig/Index.html#dontconvbrtoparagraph
I come back with the solution i find, i have uninstalled the obsolete extension rtehtmlarea, and this solved the problem.

How to use <br> instead of <br /> in CKeditor

It's 2017 and it's the age of HTML5! In HTML5, the line break is <br>, NOT <br />. But for the life of it, I can't get CKeditor to ditch <br /> in favor of <br>.
The incorrect <br />'s are giving me all sorts of problems. Among them:
Failed code validation
(In Firefox) Using JavaScript's innerHTML on a code block that was created with <br />'s, returns <br>'s instead - which messes up comparisons about changes.
I found this old forum entry about the issue (in a related program, not in CKeditor itself):
http://ckeditor.com/forums/Support/are-not-validated-W3C-validator-How-change
But the suggested fix (changing config.docType in the config file) does NOT WORK!
I tried a bunch of different docTypes's, in both the top-level config.js and in core/config.js .
In top-level config.js , I tried:
config.docType = '<!DOCTYPE html>';
In core/config.js, I tried:
docType: '<!DOCTYPE html>',
But nothing works! :(
I also tried to hunt down instances of <br /> in the multitudes of files, but didn't find any in the core part of CKeditor. I presume that the <br /> string gets created dynamically??
How can I get CKeditor to spit out <br> rather than <br /> ?
Thanks!
Yay, it took some hardcore Googling (hard to phrase the search), but I found the answer! I hope this will help others.
Simply add:
CKEDITOR.on( 'instanceReady', function( ev ) {
// Output self-closing tags the HTML5 way, like <br>
ev.editor.dataProcessor.writer.selfClosingEnd = '>';
});
What it does, from what I understand, is to wait for the core plugin "HTML Output Writer" to be loaded - and when it is, it modifies the "writer", which is a property of each editor instance. The above way applies the change to all editors, but it could also be done to individual editor instances (though I find it hard to imagine why anyone would want to do the latter.)
For more info, from the CKEditor4 documentation:
How Do I Output HTML Instead of XHTML Code Using CKEditor?
All right, CKEditor rocks! :D

How to mix href within jstl code

When I use the below jstl code
<a href="http://mysite.com?id="<c:out value="${myid}"/>/><c:out value="${myid}"/></a>
the output is :
"1234"
The value 1234 corresponds to the variable value of myid but the url being generated is
"http://mysite.com?id=" so no value for myid is being generated as part of the href.
How can I amend the href so that entire href is displayed :
"http://mysite.com?id=1234"
instead of :
"http://mysite.com?id="
Ultimately, JSP/JSTL generates HTML. You're familiar with basic HTML, right?
Look closer at the generated HTML output by rightclick, View Source in browser. You'll see:
<a href="http://mysite.com?id="1234/>1234</a>
Is that valid HTML? No, you're closing the attribute value too soon with " at wrong place and you're closing the tag too soon with />. Look, the Stack Overflow HTML syntax highlighter also got confused. Instead, it should have been:
1234
Fix the HTML generator (i.e. the JSP/JSTL code) accordingly so that it generates the desired HTML:
<c:out value="${myid}"/>
Unrelated to the concrete problem, the <c:out> is only helpful in preventing XSS attack holes when redisplaying user-controlled input and actually the wrong tool to inline URL parameters. If you can guarantee that ${myid} is always a number (because it's a Long or Integer), you can even just leave it entirely out, making the code prettier to read:
${myid}
If the ${myid} is however not a guaranteed to be a number (because it's a String), then you should use <c:url> and <c:param> to properly URL-encode it:
<c:url value="http://mysite.com" var="myURL">
<c:param name="id" value="${myid}" />
</c:url>
<c:out value="${myid}" />
<c:url> tag is used to create an url. It is helpful in the case when cookies is turned off by the client, and you would be required to rewrite URLs that will be returned from a jsp page.
<c:param> tag may used as a subtag of to add the parameters in the returned URL. Using these parameters encodes the URL.
<c:url value="http://mysite.com" var="myURL">
<c:param name="id" value="${myid}" />
</c:url>
<a href="${myURL}" />${myURL}</a>
Read more from here.

No automatic line-break in textarea in Joomla Backend

I'm writing a Module for Joomla! 2.5. In my Backend I've got a textarea, in which values should be written line by line. If the value is to big the line breaks and it looks really confusing and chaotic.
In normal html I would add a wrap="off" to the textarea-tag (I know it's not conform html, but it works), but the textarea is defined in the module's xml-file:
<field name="content" type="textarea" label="LWTAGCLOUD_CONTENT_LABEL" description="LWTAGCLOUD_CONTENT_DESCRIPTION" rows="20" cols="60" class="lw_tagcloud_textarea" default="VALUE; LINK"></field>
Has anyone an idea how to solve this problem?
If you cannot solve the problem using css only, and since you cannot add wrap="off" to the textarea type in Joomla, what you could do is to create a custom parameter type, the same like textarea, just with wrap=off already defined.
For more details on how to do it, have a look at http://docs.joomla.org/Creating_custom_template_parameter_types and http://www.sanjeevshrestha.com.np/2010/01/creating-color-element-in-joomla-for-custom-parameter-type/, it's not hard to make it
just use
for line break !
hope this help for anyone who ask

image button with html5

I'm trying to make an image button. I'm using/learning html5 and jquery mobile. this is my sample code:
<img src="img/beer.png" alt="beer" />
<input type="image" src="img/beer.png" />
the image is displayed, but the input type doesn't show the image. what do i do wrong ?
<input type="image" src="img/beer.png" /> is meant to collect coordinates. If you want to use it as a submit-button, you'll have to add an onsubmit-event, e.g.
<input type="image" src="img/beer.png" onsubmit="submit();" />
But you should rather use the <button>-element, which is way more flexible. It can contain text, images or both:
<button type="submit" name="beer" value="beer_btn_was_clicked">
Here's some optional text,
<p>which you can even put in a paragraph!</p>
And you don't even need JavaScript!
<img src="img/beer.png" />
</button>
Edit (2016-02-12)
As of today*, the above example is not considered 100% valid because <p>-elements are not allowed within a <button>-element anymore.
According to the MDN HTML element reference the only permitted content category within a <button>-element is the so called Phrasing content:
Phrasing content defines the text and the mark-up it contains. Runs of phrasing content make up paragraphs.
Elements belonging to this category are <abbr>, <audio>, <b>, <bdo>, <br>, <button>, <canvas>, <cite>, <code>, <command>, <datalist>, <dfn>, <em>, <embed>, <i>, <iframe>, <img>, <input>, <kbd>, <keygen>, <label>, <mark>, <math>, <meter>, <noscript>, <object>, <output>, <progress>, <q>, <ruby>, <samp>, <script>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <svg>, <textarea>, <time>, <var>, <video>, <wbr> and plain text (not only consisting of white spaces characters).
A few other elements belong to this category, but only if a specific condition is fulfilled:
<a>, if it contains only phrasing content
<area>, if it is a descendant of a element
<del>, if it contains only phrasing content
<ins>, if it contains only phrasing content
<link>, if the itemprop attribute is present
<map>, if it contains only phrasing content
<meta>, if the itemprop attribute is present
*today was that I read about it, not when the change was introduced
http://jsfiddle.net/cyB7B/
This works for me...have you got any other code that could be interfering? CSS maybe?

Resources