Answers.Body: <p>I'm a total novice with Craft/Twig and I was hoping for some sort of simple and neat <code>append</code> function in Twig!</p>
  
  <p>However, I've got close to a working solution using CSS, by overriding the Extract's <code>&lt;p&gt;</code> tags' usual behavior with <code>display: inline</code>, and enclosing the 'Continue reading…' in a <code>&lt;span&gt;</code> tag.</p>
  
  <p><strong>Edit:</strong><br>
  The following (including some additional logic for a 'Summary' field) seems to work well…</p>
  
  <pre><code>&lt;div class="excerpts"&gt;
  
      {% if entry.summary %}
          {{ entry.summary }}
      {% else %}
          {{ entry.body.page(1) }}
      {% endif %}
  
      {% if entry.body.getTotalPages() &gt; 1 or entry.summary %}
          &lt;span&gt;&lt;a href="{{ entry.url }}" rel="nofollow"&gt;Continue reading…&lt;/a&gt;&lt;/span&gt;         
      {% endif %}
  
  &lt;/div&gt;
  </code></pre>
  
  <p>…and…</p>
  
  <pre class="lang-css prettyprint-override"><code>.excerpts p:last-of-type { display: inline; }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T15:41:15.920Z
Answers.Text: THIS is the way to go, Brian! I was so much in my Craft thinking that I didn't understand the problem as a whole. All you actually want to do is to STYLE the "continue reading..." link. And as we all know, styling should be done using css, semantically the link belongs outside of your paragraphs. Additionally I'd add `rel="nofollow"` to the link, as you don't want to rank for "Continue reading" at search engines.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T16:03:20.280Z
Answers.Text: Oh, and it's `p:last-of-type { display: inline; }`...
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T16:29:08.597Z
Answers.Text: Now you only have to wait 2 days before you can accept your answer :D In the meantime, you could edit it to make it even more useful for future readers (add a complete css code snippet etc.).
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T15:05:11.407Z
Answers.LastActivityDate: 2014-07-29T18:12:02.103Z
Answers.LastEditDate: 2014-07-29T18:12:02.103Z
Answers.UserDisplayName: Brian L
Answers.Body: <p>I would write a Craft plugin with a twig extension.</p>
  
  <pre><code>{% if entry.richTextFieldHandle.getTotalPages() &gt; 1 %}
    {{ entry.richTextFieldHandle.getPage(1)|continueReading('Continue reading…', entry.url)|raw }}
  {% else %}
    {{ entry.richTextFieldHandle }}
  {% endif %}
  </code></pre>
  
  <p><code>continueReading</code> plugin left as an exercise for the reader.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T14:50:37.277Z
Answers.Text: Marion, what about making `continueReading` an exercise for the answerer?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T14:52:40.340Z
Answers.Text: @ChristianSeelbach quite possible, but no promises.
Answers.UserDisplayName: Marion Newlevant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T15:00:33.123Z
Answers.Text: YEY! Redactor is no easy to deal with. Still struggling on how to add [AND remove](https://github.com/aelvan/RedactorStyles-Craft#known-issues) inline tags with a custom button.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T14:48:02.960Z
Answers.LastActivityDate: 2014-07-29T14:48:02.960Z
Answers.UserDisplayName: Marion Newlevant
Answers.Body: <p>To solve this properly you'd need to write a Craft plugin which also holds some sort of Redactor plugin.</p>
  
  <p>But as a quick solution, how about using the <a href="http://twig.sensiolabs.org/doc/filters/striptags.html" rel="nofollow">striptags</a> filter? It'll remove <em>all</em> your tags though, meaning that you will also loose all other paragraph and styling tags.</p>
  
  
  
  <pre class="lang-twig prettyprint-override"><code>{#
   # This comment is only necessary because of this bug:
   # http://meta.craftcms.stackexchange.com/questions/72/temporary-removal-of-twig-syntax-highlighting
   #}
  
  &lt;p&gt;
      {{ entry.richTextFieldHandle.getPage(1)|striptags }}
  
      {% if entry.richTextFieldHandle.getTotalPages() &gt; 1 %}
          &lt;a href="{{ entry.url }}"&gt;Continue reading…&lt;/a&gt;
      {% endif %}
  &lt;/p&gt;
  </code></pre>
  
  <p>You could also try to apply <a href="http://twig.sensiolabs.org/doc/filters/slice.html" rel="nofollow"><code>slice</code></a> filters. I'm not sure, but maybe this automatically leads to a <a href="http://twig.sensiolabs.org/doc/filters/raw.html" rel="nofollow">raw output</a> of your rich text, making all other tags not working as well.</p>
  
  <pre class="lang-twig prettyprint-override"><code>{#
   # This comment is only necessary because of this bug:
   # http://meta.craftcms.stackexchange.com/questions/72/temporary-removal-of-twig-syntax-highlighting
   #}
  
  &lt;p&gt;
      {{ entry.richTextFieldHandle.getPage(1)|slice(4)|slice(0, -4) }}
  
      {% if entry.richTextFieldHandle.getTotalPages() &gt; 1 %}
          &lt;a href="{{ entry.url }}"&gt;Continue reading…&lt;/a&gt;
      {% endif %}
  &lt;/p&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-29T14:35:47.463Z
Answers.LastActivityDate: 2014-07-30T06:06:47.263Z
Answers.LastEditDate: 2014-07-30T06:06:47.263Z
Answers.UserDisplayName: carlcs
Body: <p>The code from the <a href="http://buildwithcraft.com/docs/rich-text-fields#templatin" rel="noreferrer">RichText documentation</a> appends the 'Continue reading…' link in a new block and on a new line:</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% for entry in craft.entries.section('blog') %}
          &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
          {{ entry.richTextFieldHandle.getPage(1) }}
          {% if entry.richTextFieldHandle.getTotalPages() &gt; 1 %}
              &lt;a href="{{ entry.url }}"&gt;Continue reading…&lt;/a&gt;
          {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>Any ideas how to append the 'Continue reading…' link inside the final <code>&lt;/p&gt;</code> tag generated by Redactor at the end of the final paragraph, i.e. as a continuation of the Excerpt text, and on the same line?</p>
  
Tags: <templating><richtext><redactor>
Title: How to append 'Continue reading…' link within the last paragraph of the Excerpt
ThreadText: # How to append 'Continue reading…' link within the last paragraph of the Excerpt
  
  (Asked by: username_0 on 2014-07-29)
  
  The code from the [RichText documentation](http://buildwithcraft.com/docs/rich-text-fields#templatin) appends the 'Continue reading…' link in a new block and on a new line:
  
  ```twig
  {% for entry in craft.entries.section('blog') %}
          <a href="{{ entry.url }}">{{ entry.title }}</a>
          {{ entry.richTextFieldHandle.getPage(1) }}
          {% if entry.richTextFieldHandle.getTotalPages() > 1 %}
              <a href="{{ entry.url }}">Continue reading…</a>
          {% endif %}
  {% endfor %}
  
  ```
  
  Any ideas how to append the 'Continue reading…' link inside the final `</p>` tag generated by Redactor at the end of the final paragraph, i.e. as a continuation of the Excerpt text, and on the same line?
  
  **Tags:** templating, richtext, redactor
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2014-07-29. Score: 5 | Accepted answer
  
  I'm a total novice with Craft/Twig and I was hoping for some sort of simple and neat `append` function in Twig!
  
  However, I've got close to a working solution using CSS, by overriding the Extract's `<p>` tags' usual behavior with `display: inline`, and enclosing the 'Continue reading…' in a `<span>` tag.
  
  **Edit:**  
  The following (including some additional logic for a 'Summary' field) seems to work well…
  
  ```
  <div class="excerpts">
  
      {% if entry.summary %}
          {{ entry.summary }}
      {% else %}
          {{ entry.body.page(1) }}
      {% endif %}
  
      {% if entry.body.getTotalPages() > 1 or entry.summary %}
          <span><a href="{{ entry.url }}" rel="nofollow">Continue reading…</a></span>         
      {% endif %}
  
  </div>
  
  ```
  
  …and…
  
  ```css
  .excerpts p:last-of-type { display: inline; }
  
  ```
  
  > **Comments:**
  > **username_1**: THIS is the way to go, username_0! I was so much in my Craft thinking that I didn't understand the problem as a whole. All you actually want to do is to STYLE the "continue reading..." link. And as we all know, styling should be done using css, semantically the link belongs outside of your paragraphs. Additionally I'd add `rel="nofollow"` to the link, as you don't want to rank for "Continue reading" at search engines.  
  > **username_1**: Oh, and it's `p:last-of-type { display: inline; }`...  
  > **username_1**: Now you only have to wait 2 days before you can accept your answer :D In the meantime, you could edit it to make it even more useful for future readers (add a complete css code snippet etc.).  
  
  ---
  
  ### Answer by username_2 on 2014-07-29. Score: 1
  
  I would write a Craft plugin with a twig extension.
  
  ```
  {% if entry.richTextFieldHandle.getTotalPages() > 1 %}
    {{ entry.richTextFieldHandle.getPage(1)|continueReading('Continue reading…', entry.url)|raw }}
  {% else %}
    {{ entry.richTextFieldHandle }}
  {% endif %}
  
  ```
  
  `continueReading` plugin left as an exercise for the reader.
  
  > **Comments:**
  > **username_1**: username_2, what about making `continueReading` an exercise for the answerer?  
  > **username_2**: @ChristianSeelbach quite possible, but no promises.  
  > **username_1**: YEY! Redactor is no easy to deal with. Still struggling on how to add [AND remove](https://github.com/aelvan/RedactorStyles-Craft#known-issues) inline tags with a custom button.  
  
  ---
  
  ### Answer by username_1 on 2014-07-29. Score: 1
  
  To solve this properly you'd need to write a Craft plugin which also holds some sort of Redactor plugin.
  
  But as a quick solution, how about using the [striptags](http://twig.sensiolabs.org/doc/filters/striptags.html) filter? It'll remove *all* your tags though, meaning that you will also loose all other paragraph and styling tags.
  
  ```twig
  {#
   # This comment is only necessary because of this bug:
   # http://meta.craftcms.stackexchange.com/questions/72/temporary-removal-of-twig-syntax-highlighting
   #}
  
  <p>
      {{ entry.richTextFieldHandle.getPage(1)|striptags }}
  
      {% if entry.richTextFieldHandle.getTotalPages() > 1 %}
          <a href="{{ entry.url }}">Continue reading…</a>
      {% endif %}
  </p>
  
  ```
  
  You could also try to apply [`slice`](http://twig.sensiolabs.org/doc/filters/slice.html) filters. I'm not sure, but maybe this automatically leads to a [raw output](http://twig.sensiolabs.org/doc/filters/raw.html) of your rich text, making all other tags not working as well.
  
  ```twig
  {#
   # This comment is only necessary because of this bug:
   # http://meta.craftcms.stackexchange.com/questions/72/temporary-removal-of-twig-syntax-highlighting
   #}
  
  <p>
      {{ entry.richTextFieldHandle.getPage(1)|slice(4)|slice(0, -4) }}
  
      {% if entry.richTextFieldHandle.getTotalPages() > 1 %}
          <a href="{{ entry.url }}">Continue reading…</a>
      {% endif %}
  </p>
  
  ```
  
  
  ---
  
  