CKEditor - pasting from text file then applying bullets causes strange effect - ckeditor

Using CKEditor and I am copying a bunch of text on different lines into the editor. After I do that I select the text and click to apply bullets. The bullets appear but it throws the whole thing into a weird format.
Basically If I have 3 lines, the bullets appear for all 3 lines. But for the first 2 there is a line break after the bullet and the text is on the line underneath the bullet. Except on the 3rd one which looks fine
So
test1
test2
test3
when I try to apply bullets/numbering becomes
1.
test1
2.
test2
3. test3
Havent been able to find anything on google yet. Anyone know how to stop this?
EDIT:
Added the html before an after.
Before:
<html data-version="ckeditor"><body><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:11pt"><span style="font-size:11pt">test1<br />
test2<br />
test3</span></span></span></body></html>"
After:
test1
test2
test3
<html data-version="ckeditor"><body><ul>
<li><br />
<span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:11pt"><span style="font-size:11pt">test1</span></span></span></li>
<li><br />
<span style="font-size:11pt"><span style="font-family:Arial,Helvetica,sans-serif">test2</span></span></li>
<li><span style="font-size:11pt"><span style="font-family:Arial,Helvetica,sans-serif">test3</span></span></li>
</ul>
</body></html>

Related

CKEditor5 - Source formatting / layout

I've recently switched from CKE4 to CKE5 and note a slightly annoying side-effect with source formatting.
If typing a few short lines, the editor applies paragraph tags, which is fine, but upon saving to our db for example, all lines are joined into one, where as CKE4 kept them in nicely separated.
With CKE4 :
<p> Hello World </p>
<p> Testing 12345 </p>
With CKE5
<p> Hello World </p><p> Testing 12345 </p>
Is there a parameter to change this ?
thanks in advance
I've handled this database side using replace and adding in line break - seems to work well now.
SET #myField= replace(#myField,'</p>','</p>' + (CHAR(13) + CHAR(10)) + (CHAR(13) + CHAR(10)))

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.

Returning multiple strings using XPATH

Source website is here on Nethys
Since I don't know all of the terminologies I'm going to keep this as neutral as possible. I'm trying to gather information from this website into separate columns in a google doc.
I want the bold text in one column, the associated link in the next, and the spell description in another. The issue comes when a description references another spell they put it in italics which breaks the description into multiple parts seen in C153 and C154. I think it would be easier to just grab everything in between the bold text and a line break but I don't know the context.
From an example such as (Forgive me if the formatting is wrong, I'm mostly guessing here);
<p>
<b>
<a href='link1'>
Bold Link 1
</a>
</b>
:Followed by normal text
<br>
<b>
<a href='link2'>
Bold Link 2
</a>
</b>
:Normal Text
<i>with an italic</i>
in between
<br>
<b>
<a href='link3'>
Bold Link 3
</a>
</b>
:Back to this one
<br>
</p>
I can get it to return
:Followed by normal text
Normal text
in between
:Back to this one
But I want it to return :Followed by normal text :Normal text with an italic in between :Back to this one
I don't even know if it's possible to do with a single command but any help would be appreciated.
If you want to select every text node descendant of p root element that it's not also descendant of a you could use this XPath:
/p//text()[not(ancestor::a)]
Or more restricted ussing the Kayian method:
/p//text()[count(.|/p//a//text()) != count(/p//a//text())]
Note: XPath 1.0 has no intersection nor set differenciation operators, but it has union by | operator and cardinality by count() function. Dr. Michael Kay discovered that those were enough to test for set membership: a element is member of B set if and only if {a} union B has the same cardinality than B. From there you build all the others set operations.

how to remove everything after specific text with xpath

I am trying to setup a Telegram Instant View for a website.
i have something like this code and want to remove everything after "remove from here" text
<p> sample text <p> test</p> remove from here <p>test text</p> </p>
how can i access every text/nodes after this specific text ("remove from here") and remove them?
Update:
i want to have this result:
<p> sample text <p> test</p> remove from here</p>
how can i access every text/nodes after this specific text
You can use following-sibling::* from XPath to access the nodes on the same level after the one you selected.
Then use #remove function from the Instant View DSL:
$selected_node: //*[self::text() and normalize-space()="remove from here"]
#remove: $selected_node/following-sibling::*
You may want to be more specific with the $selected_node. Depending on your needs, you may want to add predicates to remove only certain types of the following siblings, for example: following-sibling::*[self::node() or self::text()].

CKEditor is modifying my HTML source - and not for the better. Any way to prevent this?

I realize there are many questions about CKEditor modifying HTML source. But none of the suggestions appear to work.
In particular, the most general suggested change:
config.allowedContent = true;
seems to help quite a bit, but a lot still gets changed.
For example, the following HTML entered in SOURCE mode gets modified.
Original:
<p><a name="top"></p>
<p>Over the course of its 2 phases the ACCRA programme has co-authored and published a large collection of reports, case studies, evaluations and working papers. These are all available to download for free here.<br>
Our resources are categorised as follows: General Programme Information | Research reports | Country case studies | Phase 1 Evaluation | Working papers| Publications in Portuguese</p>
Turns into this:
<div> </div>
<p><a name="top"></a></p>
<p><a name="top"> </a></p>
<p><a name="top">Over the course of its 2 phases the ACCRA programme has co-authored and published a large collection of reports, case studies, evaluations and working papers. These are all available to download for free here.<br>
Our resources are categorised as follows: </a>General Programme Information | Research reports | Country case studies | Phase 1 Evaluation | Working papers| Publications in Portuguese</p>
Duplicated lines and even spaces are added.
Another example:
Original:
<div style="clear: both"></div>
<p></p>
<p></p>
Becomes this:
<div style="clear: both"> </div>
<p> </p>
<p> </p>
I could go on, but you get the point.
The changed source gets rendered differently from the original. For example, rows of publications which were nicely aligned get slightly misaligned if opened and then saved in the CKEditor.
Is there a way of telling CKEditor to please leave my valid HTML source as is?
The option config.allowedContent = true; should do the trick for leaving your VALID html code intact.
But in the case that there is no valid html code it will try to correct it in order to show it correctly (that is because CKEditor is not a code writing tool but a WYSIWYG tool).
In your first example your html is not valid (<p><a name="top"></p>). The <a> tag should have a corresponding </a> end tag.
In your second example you can disable the automatic fillup of empty tags with the using the option:
config.fillEmptyBlocks = false;

Resources