TinyMCE remove \n characters - tinymce

Does anyone know how to block the "\n" newline characters from appearing in the HTML when using TinyMCE?

Related

How to wrap text in Notepad++, but leave paragraph lines intact?

How can I wrap text in Notepad++, but leave paragraph lines intact?
Example:
The original text looks like this:
This
is
paragraph
one.
This
is
paragraph
two.
I would like the text to look like this:
This is paragraph one.
This is paragraph two.
But currently, when I go to Edit > Blank Operations > Remove Unnecessary Blank and EOL, the text ends up with no paragraph line in between, like this:
This is paragraph one. This is paragraph two.
How can I fix this?
Thank you.
You may try the following find and replace, in regex mode:
Find: ([^.\s])\r?\n
Replace: $1[ ]
Demo
The regex pattern ([^.\s])\r?\n will match and capture any letter which appears before a CR?LF character, so long as that character is not a full stop. It then replaces with that same character, followed by just a single space, thereby removing/replacing the original CR?LF.
This will replace every single linebreak with a space.
Ctrl+H
Find what: [^\r\n]+\K\R(?!\R)
Replace with: # a space
CHECK Wrap around
CHECK Regular expression
Replace all
Explanation:
[^\r\n]+ # 1 or more non linebreak
\K # forget them
\R # any kind of linebreak (i.e. \r, \n, \r\n)
(?!\R) # negative lookahead, make sure we haven't another linebreak after
Screenshot (before):
Screenshot (after):

Keep § when pasting from word

I'm trying to paste content from a word doc into a tinymce instance. The content contains the § (paragraph) character, but TinyMce changes it into an li tag.
Is there a way to config TinyMce to allow special characters like §?
What you are seeing is behavior around the Paste plugin when a sentence starts with that character.
When it starts with that character the Paste plugin treats that like a list element. If the character is anywhere other than the first character TinyMCE does not create a list element.
The best thing to do is to open a bug report on the issue tracker for TinyMCE so the developers are aware of this issue.
https://github.com/tinymce/tinymce/issues

How to display newline in TimelineItem control's text property?

We have a SAPUI5 timeline control, where we are showing the comments coming from server.
The issue is, if the comments contain a newline \n, then the Timeline control is not able to display the text in newline. Instead, it introduces space wherever \n is present.
We have tried formatting \n to unicode character also but that also didn't worked. Timeline control aggregates TimelineItem.
The control we are using is: https://ui5.sap.com/#/api/sap.suite.ui.commons.TimelineItem
Code snippet can be found at:
https://jsbin.com/kuluyehilu/edit?html,output
I inspected your example and came up with the following solution.
Since the text is embedded in a <span>, all unnecessary whitespace will be trimmed. What you can do is telling the span (via CSS) that it should display the whitespace anyway.
If you don't have a CSS file in your project yet, create one. Then add the following lines
div.sapSuiteUiCommonsTimelineItemShellBody>span {
white-space: pre;
}
This should do the trick.
JSBin: https://jsbin.com/feladeneso/1/edit?html,output
If you inspect the rendered element, you will see it actually put in the break:
<span id="__item0-realtext">x
y</span>
...but did not convert it to a <br/> tag. You cannot add the tag yourself since it will be escaped, either. Maybe you can try to override the renderer, and convert any line breaks to html breaks

vim displaying a 'page break' at line ending, with at's in margin (#)

I have an ANSI XML file using windows linebreaks.
At the end of a line, I have CRLF[space][space] (0 x 0D 0A 20 20)
In other text editors, this displays as newline, space space. in VIM, it appears to be doing a sort of 'page break' instead of a linebreak, with a screenfull of # characters down the left margin.
I have tried reloading the file using different encodings and explicit linebreak formats, but it made no useful difference.
Does anyone understand this phenomenon?
Thank you
This is just trying to show a long line all at once. You can turn it off with lastline
'display' 'dy' string (default "")
global
{not in Vi}
Change the way text is displayed. This is comma separated list of
flags:
lastline When included, as much as possible of the last line
in a window will be displayed. When not included, a
last line that doesn't fit is replaced with "#" lines.
uhex Show unprintable characters hexadecimal as <xx>
instead of using ^C and ~C.

TinyMCE- Get plain text

In tinyMCE, Is there any way to get the plain text instead of HTML text?
Try this:
var myText = tinyMCE.activeEditor.selection.getContent({ format: 'text' });
var rawtext = tinyMCE.activeEditor.getBody().textContent;
I just tried this approach:
editor.getContent()
.replace(/<[^>]*>/ig, ' ')
.replace(/<\/[^>]*>/ig, ' ')
.replace(/ | /gi, ' ')
.replace(/\s+/ig, ' ')
.trim();
Replaces both opening and closing html tags with space
Replaces various known special characters with space (add yours as well)
Replaces multiple spaces with a single space
Worked reasonably well, but it is obviously not perfect. I need only an approximation of plain text for purposes of word counting, so I am willing to ignore corner cases such as having part of the word bold or italic (replacement above for <b>a</b><i>x</i> will produce two separate words a b instead of ab).
It is an extension of Regular expression to remove HTML tags from a string
Hope that helps.