When I paste text from MS word document, it creates extra p tags.
Where in the code I can modify it so it only shows one opening and closing paragraph?
Hi @mp5163093 I’m not exactly sure what’s the problem but you seem to have a bunch of regular expressions replacing content in your JavaScript. Well my best guess is one of those is breaking your HTML and producing all of those p tags.
Generally that’s not recommended, although it’s not clear how you are copying the text and where you are pasting it. Word creates awful HTML, so the first recommendation is to use a code editor like Atom instead. Even if you do this as an intermediary step.
Are you pasting this into WordPress or something? Seems every line return is being treated as a new paragraph. That’s party why I think pasting the text into a plaiin text editor first might help, but we need a better idea of the conditions you’re working in.
Hey Ralphm,
Is for a small cms and the code as it is works great, the only thing is that is creating those extra paragraphs tags.
I can’t use Atom editor, or wordpress.
As you can see my example text it does show how extra p tags gets created. The cool thing is that the script cleans up all of the MS word html code.
I believe the problem is in the regular expressions. by the way Andres thank you for your input.
To test the code might want to copy and paste any text from MS word in to the codepen
Drop it into Notepad or similar, then cut & paste it back out, then put the tags back in that you need. It might take a little time, but it’ll definitely help clean things back up.
You’re welcome.
I don’t hope to despair you but your problem reminded me to this funny article :
And it actually must be the case that to build a WYSIWYG editor you do need regular expressions, but that must be the reason also why they are so hard to build.
I wish you good luck solving your problem
Often you’ll find the wysiwyg editors in CMSs have settings for how the editor should deal with paragraph returns etc. Do you know which editor the CMS is using?
Yes I could use PHP
In which file should i add your line of code ?
Should I create a new include php file ?
How can I can call the line of code in the form ?
Hey John, my friend Robert figure out the problem and it was the regular expression http://booden.net/ContentCleaner.aspx <[^/>][^>]>\s</[^>]+> Thanks for your help everyone