26

Re: Dont want text wrapped in <p> tags

@bccarlso

Your request goes far beyond the scope of this forum's topics. First of all you need to find out about what server-side scripting languages your webspace provides and which is the one used by your CMS (my guess is PHP). Then you need to learn how to write scripts in this language in order to understand how your CMS works before you can modify it.

Good luck!

Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)

27

Re: Dont want text wrapped in <p> tags

Was just looking for a few links, not a discussion in this forum, but thanks! Looks like I'll have to go back to Markup or Textile.

28

Re: Dont want text wrapped in <p> tags

Same issue, different reasons. I'm working in Ruby on Rails, using inplacericheditor (http://github.com/ZenCocoon/inplacerich … ree/master) which uses tinyMCE. Presently, any text edited gets wrapped in <p></p> that tinyMCE touches. Now this may be fine for major blocks of content; it's definitely not when dealing with say a title that's <225 chars.

Don't get me wrong; I appreciate tinyMCE. But the assumption that everyone useing tinyMCE is a) a php programmer b) editing a large block of text is just not true.

29

Re: Dont want text wrapped in <p> tags

@BobWalsh Yeah… and you would think that using the 'HTML' tool to manually strip the <p></p> tags would remove them. But no, they come back. That makes zero sense to me, why allow editing of HTML then?

30

Re: Dont want text wrapped in <p> tags

BobWalsh wrote:

But the assumption that everyone useing tinyMCE is a) a php programmer b) editing a large block of text is just not true.

Implementing TinyMCE is far from a trivial issue and as such is an issue for professionals. Professionals can deal with a backend and tailor it to suit their needs. This forum can try to help those professionals. However it can not do the bidding of every hobby website creator. Hobby webworkers tend to have their own ideas about application design - and this often leads to different opinions about what is the right way to do things. In the end it remains up to you... always.

bccarlso wrote:

Yeah… and you would think that using the 'HTML' tool to manually strip the <p></p> tags would remove them. But no, they come back. That makes zero sense to me, why allow editing of HTML then?

My point exactly. Why should you allow users to input HTML-encoded contents if you don't want (real) HTML-encoded contents. Offering Rich Text Editing via a WYSIWYG interface often isn't the best choice but many people here stubbornly keep ignoring this fact. You could use a wiki-like syntax or BBCode (like this forum here) instead. So why using TinyMCE (or any other WYSIWYG editor control out there) in the first place?

Nobody needs to agree with my point of view. But I write this because I strongly believe that my opinion has some point. Do with it as you please.

As for the dreaded "I want no <p></p> around my content"-issue... either read the docs (FAQ first!!!) or finally decide why you don't want them and turn away from a WYSIWYG-based "solution"!

I'm growing weary...

Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)

31

Re: Dont want text wrapped in <p> tags

Sorry Felix, I don't mean to have you grow weary. I guess it just comes down to really liking this product (seriously, TinyMCE is a great tool!), but needing some functionality (for whatever reason, actual real-world needs often surpass the need to remain completely semantic, but that's a whole other discussion) that it doesn't provide. Obviously a fan of TinyMCE will look to TinyMCE for the solution first, which I have done. And thanks to this thread, I've found out that I will instead have to use another markup system, which is OK. But to imply we are either A) stupid and don't understand the web, or even B) hobby website creators, is slightly rude, which is fine, maybe even deserved I guess… anyway, case solved. Thanks for the help, it honestly is appreciated.

32

Re: Dont want text wrapped in <p> tags

For anyone who has the same type of issue, a simple regexp should solve the problem.

In PHP you can do, for instance (assuming you got the text in the $txt variable):

$txt = ereg_replace('^<p>(.*)</p>$', '\\1', $txt);

and no more <p> around your text!

33

Re: Dont want text wrapped in <p> tags

I'm a professional developer and have been working with database-driven web applications since 1997, so I think I know what I'm talking about. I am completely capable of stripping out these paragraph tags on the server, but that's not the point for me posting here.

I don't get the animosity. I know (KNOW - because I've written HTML editors from scratch - not to the extreme level of detail that this editor is written in, but detailed enough to have served as the front end for a from-scratch CMS I built in 2002), and I know that somewhere in this code is a line that takes my content variable (say that it looks like "var s='<div>hello world</div><div>some other stuff</div>'"), and does this to it: "var tinymceoutput="<p>" + s + "</p>".

If you are weary of explaining why you do this, then add an option in the setup so I can turn it off. How hard can that be? Hard for those of us that didn't write this and so get completely lost stepping it with 1-character variables to help keep track of where we are, or we'd have done it ourselves already. It's NOT a requirement of switching an object to richedit mode; this I know.

No argument that P tags are vital, but here's my scenario: one of the things I'm building in my current CMS is a FAQ page. The FAQ "Questions" are short enough that I intend to use them as the URL string in my replacement URL code, so that it will index better (I'm replacing spaces with underscores). But my users also want to be able to do simple formatting of the question (bold, italic, etc). But at the end of the day, for this application, I'm tickled pink to save this string in my FAQ record as a Question: "What is the <b>current</b> rate of pay?" I don't need to save, nor do I want to save, "<p>What is the <b>current</b> rate of pay?"

Why should your software force me to strip that pair of tags, thereby inducing me to both write unnecessary code and waste useless server processor cycles, every time I need to clean this string?

This is the kind of stuff that makes me crazy, and speaking from experience, it's the kind of attitude that drives customers away. I'm just saying.

34

Re: Dont want text wrapped in <p> tags

@devconcept
Actually I don't think there is such a line since this would create invalid HTML since div's (being block elements) aren't allowed within paragraph elements, p. wink

I have sort of a similar background as you and from my experience I have learned that the browsers themselves, especially IE, are creating a lot of the HTML like paragraphs or divs around texts when having editable areas in a web page, which basically is what TinyMCE is (even if it's an entire iframe being editable). And maybe it would be better to blame Microsoft (can't we always smile) since they were the first to implement editable content in a browser and they made some nifty features like allowing the user to produce different kind of line breaks when a user hits enter, producing a new block, or shift+enter, producing a br element. This is what they do in MS Word as well and I think they wanted editing on the web to act the same way. Because of this I think they also decided that "whenever a user enters text into an editable area we wrap this text in a block element" (by default paragraph), which is why you get the p element when typing text.

I try to think of TinyMCE as a tool trying to handle all browser differences the best way it can, allowing us, the users, to produce almost the same HTML in the supported browsers. And I also sort of like most of the parts of it, even that you can produce different kind of line breaks... but I guess Microsoft should have credit for that one... smile
I really don't think this behaviour will be changed, and I guess that is why people are suggesting parse of content before posting to server or on the server.
/Best regards
Henrik

35

Re: Dont want text wrapped in <p> tags

devconcept wrote:

I'm a professional developer and have been working with database-driven web applications since 1997, so I think I know what I'm talking about. [...] I'm tickled pink to save this string in my FAQ record as a Question: "What is the <b>current</b> rate of pay?" I don't need to save, nor do I want to save, "<p>What is the <b>current</b> rate of pay?"

Database? What do you store in your database? A simple line of text or some rich text content? Do you normalise your DB content before storing it there in order to make it technically context-free?

A question is a kind of sentence. In an HTML document this sentence will appear in some kind of block element - be it a <p> or (what I'd prefer in FAQ) a <li>. So why use a WYSIWYG editor if you want simple text (AKA your question)? And if you want to store it in rich text format (like with underlinement or italics) why use HTML code and not some other code like wiki syntax or BBCode?

So basically you use a tool which is called a WYSIWYG (X)HTML editor but don't want what it has been designed for (remember: to return the part of a real HTML document which is the content of the <body> element). So if the tool doesn't do what you want then either you choose another tool, or, well, work around the stuff you don't want.

I understand that you are capable of removing <p> tags from the code... but why do you complain? You have chosen this approach by using a WYSIWYG (X)HTML editor (be it TinyMCE or any other). If you simply want a line of text use an <input> element! And if you want to offer some formatting use BBCode or wiki syntax or any other code you wish (even HTML code). But if you let the user enter the stuff in a context (HTML document) where it is only a part of something bigger don't complain about the "something bigger" just because you had only asked for the small sub-part!

Yes, I might sound having an attitude here, and I might show some animosity, but if you really think about your means to an end you might find that you need to admit that certain questions are in fact rightful questions here.

Of course I'm aware that everyday life in your job might require quick and reliable solutions which aren't exactly according to high or even idealized coding standards... but then, why do you complain about having to create a workaround to avoid saving <p> elements in your DB?

Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)

36

Re: Dont want text wrapped in <p> tags

I don't understand the problem here really..
There already is a built in fix...

I was having the same issues with the <p></p>'s being added, and messing up the layout for the content being delivered. (It's coming from a database)

All I did was add the following directly under 'tinyMCE.init({':

forced_root_block : false,
force_p_newlines : false,

and presto, no more <p>'s being inserted automatically.

I dunno, maybe this doesn't work for everyone, but it's worked on 3 of my sites

37

Re: Dont want text wrapped in <p> tags

This automatic <p></p> tag situation is messing up my work too, I'd like to have a 'readmore' occur right after the entered text when published on a web page, but because of the <p> tags the 'readmore' has to sit underneath the paragraph, instead of following directly after the text, very annoying, it never used to do this. I work with Article Manager from Interactive tools, I generally don't have to know this level of coding to fix a problem, the problem shouldn't be there in the first place and none of the above work for me, great.

38

Re: Dont want text wrapped in <p> tags

graham wrote:

I work with Article Manager from Interactive tools, I generally don't have to know this level of coding to fix a problem, the problem shouldn't be there in the first place and none of the above work for me, great.

Then maybe you shold contact the makers of Article Manager...?

Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)

39

Re: Dont want text wrapped in <p> tags

No, because its your product with a problem, as the rest of this thread shows, denial and brushing off of your clients does not help, you should take responsibility for your product and not distract from the issue.

40

Re: Dont want text wrapped in <p> tags

Read the FAQ regarding P elements. Paragraphs where invented for a reason and all desktop office suites use them by default. Use shift+enter if you want to product BR elements like in Word or Open Office.

Best regards,
Spocke - Main developer of TinyMCE

41

Re: Dont want text wrapped in <p> tags

here is the issue so you can see the problem, http://stgeorges-ascot.org.uk/St-George … ndex.shtml
no BR will fix it etc and css margins are required on the <p> for normal paragraph spacing, the problem as you can see is the readmore is automatically put right below and away from the text (due to auto added <p> tags), as your TinyMCE icons are used in cms's frequently, along with read-more functions you should make this an easy fix if required, so the read-more can come straight after the text.

Guess I'll have to live with it....
G

42

Re: Dont want text wrapped in <p> tags

Just add a style where the user can select that a paragraph should have zero margins? Or press shift+enter in the paragraph and add the image. I don't see a issue here.

Best regards,
Spocke - Main developer of TinyMCE

43

Re: Dont want text wrapped in <p> tags

the end user wont know anything about P tags or whether they need them, cms's have to be simple, also this would then take the styling off the P tags where required, not just yours that aren't. 

Readmores are added automatically by any cms, and can only be added after the entered content which has the automatic P tags you've inserted and I cant get rid of.

44

Re: Dont want text wrapped in <p> tags

I've got this issue too.

I built a plugin that wraps selected text in a span ... but the editor wraps a p around the span ... this breaks my text into multiple lines.

force_p_newlines : false
force_root_block : false

Both are in my init

How do I turn off ALL injected tags?  I simply want what is in the HTML view to be posted.  I do not believe I should have to use server side cleanup for this.  Isn't this is something the editor should do natively? I would hate to see the project ported to get this functionality.

45

Re: Dont want text wrapped in <p> tags

I have a situation where a <p> tag cannot be used in my output. The text editor is being used to modify text for labels on inputs. It is a checkbox list with editable labels for each checkbox. Basic formatting is necessary (bold, italics, underline, color, etc), but nothing beyond that. Since we're all about sticking to XHTML standards... a block element, such as <p>, cannot be nested within an inline element <label> to be valid XHTML. Therefore, I need to have just a surrounding <span> (or nothing at all) with <br/>'s for any line breaks within the label. Does this sound correct? Is this a valid reason for not using <p> tags?

46

Re: Dont want text wrapped in <p> tags

We recommend using shift+br if you enter text in uncommon elements like <label>. The default should always be paragraphs since normal text consists of paragraphs.

Best regards,
Spocke - Main developer of TinyMCE

47

Re: Dont want text wrapped in <p> tags

spocke wrote:

We recommend using shift+br if you enter text in uncommon elements like <label>. The default should always be paragraphs since normal text consists of paragraphs.

Finally! .. I've tried all the suggested flags for tinymce's init section and they only seem to break the init, and only work on the jsFiddle copy of tinymce? (I'm using Version: 3.4.7 (2011-11-03))

This shift-enter is great but here's how I have to use it.

Hello Mike,<shift-enter>How are you doing today?<enter>I have more information on your issue:<shift-enter>XYZ is at 30%<shift-enter>ABC is at 12%<shift-enter> ...

See how efficient it would be to switch the function around so that I only have to shift-enter when I want a new paragraph, and otherwise I'll get a <BR>?

Any way I could do this easily?

48

Re: Dont want text wrapped in <p> tags

ChrisRichards wrote:

Hello Mike,<shift-enter>How are you doing today?<enter>I have more information on your issue:<shift-enter>XYZ is at 30%<shift-enter>ABC is at 12%<shift-enter> ...

Why do you think that this "document structure" is what you really need? Why not this one instead?

<p>Hello Mike,<br />I have more information on your issue:</p>
<ul>
    <li>XYZ is at 30%</li>
    <li>ABC is at 12%</li>
    <li>...</li>
</ul>

From a semantics point of view the above markup makes a lot more sense. As a result of this your wish for inverting the functionality of [enter] vs. [shift][enter] seems just wrong.
I dare say that your example shows a use case for which TinyMCE wasn't designed primarily, because your email (or at what else is your example hinting?) doesn't have to be in HTML - it works beautifully in plain text.

Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)

49

Re: Dont want text wrapped in <p> tags

Felix Riesterer wrote:

From a semantics point of view the above markup makes a lot more sense.

The output of TinyMCE works GREAT for viewing locally, when we post the same HTML data to our client portal their CSS leaves it looking


a bit hard to


read because of


all the wicked double


spaced paragraphs.


If we use shift+enter the result looks good locally in our 'tools' and it looks great on the client portal so this is why I say 'for our needs' flipping that around would solve 'our' issue. smile

Made sense at the time, still does.

Would it be nice to help the users make an unordered list? YES this is true in both the client portal and our 'tools' .. same with almost all of TinyMCE's plugins.

So TinyMCE is a great asset to us, but we can't control the client portal's layout/css so we have to hold down shift as we hit enter if we expect the message may get posted externally.

We could debate everyone else's needs, semantics, opinions, etc.. But what I am pointing out is accurate and we would benefit from knowing how to reverse the shift-enter logic or an option to reverse it.

50

Re: Dont want text wrapped in <p> tags

ChrisRichards wrote:

our client portal their CSS leaves it looking


a bit hard to


read because of


all the wicked double


spaced paragraphs.

[...] but we can't control the client portal's layout/css

You can't blame TinyMCE's functionality for that. Try to talk to your client instead!

Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)