Answers.Body: <p>I found that to get rid of <code>&lt;p&gt;</code> tags <em>and</em> stop it appending <code>&lt;br&gt;</code>s to the end of the string, I had to use:</p>
  
  <pre><code>{
      buttons: ['bold', 'italic', 'link'],
      toolbarFixed: true,
      minHeight: 50,
      linebreaks: true,
      deniedTags: ['br'],
      enterKey: false
  }
  </code></pre>
  
  <p>So, no need for <code>paragraphize</code>, but need to stop it printing the <code>&lt;br&gt;</code> tags.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-22T13:48:46.837Z
Answers.Text: That does work, although so does the other answer, marked correct.
Answers.UserDisplayName: Phil Gyford
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-22T13:44:37.667Z
Answers.LastActivityDate: 2015-05-22T13:44:37.667Z
Answers.UserDisplayName: Phil Gyford
Answers.Body: <p><a href="https://imperavi.com/redactor/examples/formatting/breakline-mode/" rel="noreferrer">According to docs</a>, you need a <code>breakline: true</code> line in your config like this:</p>
  
  <pre><code>{
      "buttons": [
          "bold",
          "italic",
          "underline",
          "link",
          "html"
      ],
      "plugins": ["fullscreen"],
      "toolbarFixed": true,
      "source": true,
      "breakline": true
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-03T14:31:41.747Z
Answers.Text: This should be the accepted answer! Thanks!
Answers.UserDisplayName: Fred
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-20T17:56:15.753Z
Answers.LastActivityDate: 2019-04-20T17:56:15.753Z
Answers.UserDisplayName: abdusco
Answers.Body: <p>I know this thread is pretty old, but I just figured out another way to do this you might find helpful. Rather than altering Redactor, at this uses the Twig filter striptags to get rid of unwanted tags.</p>
  
  <p><code>{{ entry.field | striptags('&lt;a&gt;&lt;b&gt;&lt;em&gt;&lt;strong&gt;') | raw }}</code></p>
  
  <p>The striptags filter here removes all tags except for  from the output. And the raw filter stops escaping the remaining tags so links and formatting shows up.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-30T03:34:51.637Z
Answers.Text: Missed the "removes all tags except..."
Answers.UserDisplayName: franklylately
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-10T21:32:24.320Z
Answers.LastActivityDate: 2019-07-10T21:32:24.320Z
Answers.UserDisplayName: Willhaus
Answers.Body: <p>There seems to be an inherited problem with redactor using the p tag as a default. I struggled to find a solution where I do need p tags and where inserted links were still getting wrapped in p tags.</p>
  
  <p>Setting linebreaks to true and deniedTags results automatically setting "paragraphize" to false and also results in not getting any "br" tags (a bit of a hackish solution considering that there is a "paragraphize" property one can set to "false", doesn't always work (dark magic)).</p>
  
  <p>But this results in my copy that needs to be wrapped in "p" tag not to be wrapped. Of course the editors have no clue what a "p" tag is so the magic of having a WSYWG editor became a horror. </p>
  
  <p>So i opted to enforce a rule that the editors should use "formatting>normal text" from the toolbar. This resulted in a type error on line 902 <code>redactor.js &gt; Uncaught TypeError: Cannot read property 'toLowerCase' of undefined</code>. I scratched my head since this works for Headings and Quotes (Selected text would be wrapped by the heading type selected eg, h1 h2).</p>
  
  <p>After debugging I found that on line 843 in Redactor <code>if (this.opts.linebreaks || tag != 'p')</code> seems to be the culprit. Now not being the architect of the code changing this to <code>if (this.opts.linebreaks || tag == 'p')</code> resulted in everything to work.</p>
  
  <p>Now I can add custom p format with custom class and the selected text would be wrapped accordingly. </p>
  
  <p>The magic = <code>this.block.formatWrap(tag);</code></p>
  
  <p>Now up to trying to make my inserted links not to be wrapped in a 'p' tag.</p>
  
  <p>The above is a nasty hack and not full proof for future use since upgrading would override the change. I would like to challenge anybody to come up with a better solution.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-06T21:53:24.593Z
Answers.Text: Making this change by not editing redactor.js seemed to be a bit more easy. Just create your own plugin, in this case 'block' and 'link' ( I transffered the existing code from redactor.js to my custom plugin). In case of redactor upgrade your work would not be overridden and if need you can make changes to it accordingly.
Answers.UserDisplayName: IColorfield
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-06T21:24:23.627Z
Answers.LastActivityDate: 2016-01-06T21:49:07.233Z
Answers.LastEditDate: 2016-01-06T21:49:07.233Z
Answers.UserDisplayName: IColorfield
Body: <p>I'm using a Rich Text field for captions beneath images, so that I can add bold, italic and links. But I'd like the output HTML to be a single line; ie, no block-level tags like <code>&lt;p&gt;</code>, or line breaks. At the moment Redactor automatically adds <code>&lt;p&gt;</code> tags, around a single line of text.</p>
  
  <p>I've tried setting both <code>paragraphize</code> and <code>replaceDivs</code> to <code>false</code> in my Redactor config JSON, as suggested <a href="https://craftcms.stackexchange.com/questions/3063/rich-text-editor-redactor-adding-additional-paragraph-p-tags">in this answer</a> but that seems to have no effect for me:</p>
  
  <pre><code>{
      buttons: ['bold', 'italic', 'link'],
      minHeight: 50,
      paragraphize: false,
      replaceDivs: false
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-31T08:32:30.463Z
Comments.Text: Inline elements are supposed to only exist within block-level elements. Redactor is just correcting your html to make it valid. Just ensure your image element is within another block-level element like <figure> or <div> and Redactor won't add <p>.
Comments.UserDisplayName: Seth Warburton
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-01T10:31:13.980Z
Comments.Text: Thanks, but inline elements can exist without a parent block level element (i.e., an inline element with its parent being the `<body>` tag). And either way, the image and caption were inside several nested block-level elements.
Comments.UserDisplayName: Phil Gyford
Tags: <redactor>
Title: Stop Redactor adding paragraph tags
ThreadText: # Stop Redactor adding paragraph tags
  
  (Asked by: username_0 on 2015-05-22)
  
  I'm using a Rich Text field for captions beneath images, so that I can add bold, italic and links. But I'd like the output HTML to be a single line; ie, no block-level tags like `<p>`, or line breaks. At the moment Redactor automatically adds `<p>` tags, around a single line of text.
  
  I've tried setting both `paragraphize` and `replaceDivs` to `false` in my Redactor config JSON, as suggested [in this answer](https://craftcms.stackexchange.com/questions/3063/rich-text-editor-redactor-adding-additional-paragraph-p-tags) but that seems to have no effect for me:
  
  ```
  {
      buttons: ['bold', 'italic', 'link'],
      minHeight: 50,
      paragraphize: false,
      replaceDivs: false
  }
  
  ```
  
  **Tags:** redactor
  
  > **Comments:**
  > **username_1**: Inline elements are supposed to only exist within block-level elements. Redactor is just correcting your html to make it valid. Just ensure your image element is within another block-level element like <figure> or <div> and Redactor won't add <p>.  
  > **username_0**: Thanks, but inline elements can exist without a parent block level element (i.e., an inline element with its parent being the `<body>` tag). And either way, the image and caption were inside several nested block-level elements.  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_0 on 2015-05-22. Score: 5
  
  I found that to get rid of `<p>` tags *and* stop it appending `<br>`s to the end of the string, I had to use:
  
  ```
  {
      buttons: ['bold', 'italic', 'link'],
      toolbarFixed: true,
      minHeight: 50,
      linebreaks: true,
      deniedTags: ['br'],
      enterKey: false
  }
  
  ```
  
  So, no need for `paragraphize`, but need to stop it printing the `<br>` tags.
  
  > **Comments:**
  > **username_0**: That does work, although so does the other answer, marked correct.  
  
  ---
  
  ### Answer by username_2 on 2019-04-20. Score: 5
  
  [According to docs](https://imperavi.com/redactor/examples/formatting/breakline-mode/), you need a `breakline: true` line in your config like this:
  
  ```
  {
      "buttons": [
          "bold",
          "italic",
          "underline",
          "link",
          "html"
      ],
      "plugins": ["fullscreen"],
      "toolbarFixed": true,
      "source": true,
      "breakline": true
  }
  
  ```
  
  > **Comments:**
  > **username_3**: This should be the accepted answer! Thanks!  
  
  ---
  
  ### Answer by username_4 on 2019-07-10. Score: 3
  
  I know this thread is pretty old, but I just figured out another way to do this you might find helpful. Rather than altering Redactor, at this uses the Twig filter striptags to get rid of unwanted tags.
  
  `{{ entry.field | striptags('<a><b><em><strong>') | raw }}`
  
  The striptags filter here removes all tags except for from the output. And the raw filter stops escaping the remaining tags so links and formatting shows up.
  
  > **Comments:**
  > **username_5**: Missed the "removes all tags except..."  
  
  ---
  
  ### Answer by username_6 on 2016-01-06. Score: 1
  
  There seems to be an inherited problem with redactor using the p tag as a default. I struggled to find a solution where I do need p tags and where inserted links were still getting wrapped in p tags.
  
  Setting linebreaks to true and deniedTags results automatically setting "paragraphize" to false and also results in not getting any "br" tags (a bit of a hackish solution considering that there is a "paragraphize" property one can set to "false", doesn't always work (dark magic)).
  
  But this results in my copy that needs to be wrapped in "p" tag not to be wrapped. Of course the editors have no clue what a "p" tag is so the magic of having a WSYWG editor became a horror.
  
  So i opted to enforce a rule that the editors should use "formatting>normal text" from the toolbar. This resulted in a type error on line 902 `redactor.js > Uncaught TypeError: Cannot read property 'toLowerCase' of undefined`. I scratched my head since this works for Headings and Quotes (Selected text would be wrapped by the heading type selected eg, h1 h2).
  
  After debugging I found that on line 843 in Redactor `if (this.opts.linebreaks || tag != 'p')` seems to be the culprit. Now not being the architect of the code changing this to `if (this.opts.linebreaks || tag == 'p')` resulted in everything to work.
  
  Now I can add custom p format with custom class and the selected text would be wrapped accordingly.
  
  The magic = `this.block.formatWrap(tag);`
  
  Now up to trying to make my inserted links not to be wrapped in a 'p' tag.
  
  The above is a nasty hack and not full proof for future use since upgrading would override the change. I would like to challenge anybody to come up with a better solution.
  
  > **Comments:**
  > **username_6**: Making this change by not editing redactor.js seemed to be a bit more easy. Just create your own plugin, in this case 'block' and 'link' ( I transffered the existing code from redactor.js to my custom plugin). In case of redactor upgrade your work would not be overridden and if need you can make changes to it accordingly.  
  
  ---
  
  