Answers.Body: <p>You could potentially use Twig's <a href="https://twig.symfony.com/doc/3.x/filters/replace.html" rel="nofollow noreferrer">replace</a> filter to replace any instance of <code>h2</code> with <code>h3</code>. If for some reason that's not powerful enough, there's also the Retcon plugin which could work too - specifically the <code>change</code> method: <a href="https://github.com/mmikkel/Retcon-Craft/wiki/Change" rel="nofollow noreferrer">https://github.com/mmikkel/Retcon-Craft/wiki/Change</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-07T11:57:04.583Z
Answers.Text: Hey James, thanks for the comment. I was trying something with replace filter. I couldn't get something conclusive (yet). I will dig a bit further in that direction. In the meantime, I'll check the Retcon plugin :)
Answers.UserDisplayName: katsele
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-20T17:14:20.403Z
Answers.Text: Hey James, I did some tests with this solution, it seems that replace filter returns a string. So I tried to wrap the content in a `{% html %}` tag. Unfortunately, with this tag, nothing shows up in the rendered page. Ever faced something like this?
Answers.UserDisplayName: katsele
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-22T08:21:28.503Z
Answers.Text: Try using the `raw` filter
Answers.UserDisplayName: James Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-22T14:27:45.643Z
Answers.Text: It worked! Thank you so so much :)
Answers.UserDisplayName: katsele
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-07T10:41:30.420Z
Answers.LastActivityDate: 2021-07-07T10:41:30.420Z
Answers.UserDisplayName: James Smith
Body: <p>I am currently building a doc system with multiple levels. I have build individual entries, but I'd like to parse the whole documentation in one page. Currently, I'm doing it like this:</p>
  <pre><code>{% set pages = craft.entries()
                      .section('documentation')
                      .all()
  %}
  
  {% for page in pages %}
  
    {{ page.articleContent }}
  
      {% if page.hasDescendants %}
  
        {% set children = page.children.all() %}
  
        {% for child in children %}
  
          {{ child.articleContent }}
  
        {% endfor %}
  
      {% endif %}
  
  {% endfor %}
  </code></pre>
  <p>Though, with Redactor, all h2 defined in deeper levels remain h2. Is there a way to detect if an entry is at level 2 or 3 and set all the headings to n-level?</p>
  <p>Thanks! :)</p>
  
Tags: <templating><redactor>
Title: Decrease heading level if entry is descendant in Redactor
ThreadText: # Decrease heading level if entry is descendant in Redactor
  
  (Asked by: username_0 on 2021-07-06)
  
  I am currently building a doc system with multiple levels. I have build individual entries, but I'd like to parse the whole documentation in one page. Currently, I'm doing it like this:
  
  ```
  {% set pages = craft.entries()
                      .section('documentation')
                      .all()
  %}
  
  {% for page in pages %}
  
    {{ page.articleContent }}
  
      {% if page.hasDescendants %}
  
        {% set children = page.children.all() %}
  
        {% for child in children %}
  
          {{ child.articleContent }}
  
        {% endfor %}
  
      {% endif %}
  
  {% endfor %}
  
  ```
  
  Though, with Redactor, all h2 defined in deeper levels remain h2. Is there a way to detect if an entry is at level 2 or 3 and set all the headings to n-level?
  
  Thanks! :)
  
  **Tags:** templating, redactor
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-07-07. Score: 2 | Accepted answer
  
  You could potentially use Twig's [replace](https://twig.symfony.com/doc/3.x/filters/replace.html) filter to replace any instance of `h2` with `h3`. If for some reason that's not powerful enough, there's also the Retcon plugin which could work too - specifically the `change` method: <https://github.com/mmikkel/Retcon-Craft/wiki/Change>
  
  > **Comments:**
  > **username_0**: Hey username_1, thanks for the comment. I was trying something with replace filter. I couldn't get something conclusive (yet). I will dig a bit further in that direction. In the meantime, I'll check the Retcon plugin :)  
  > **username_0**: Hey username_1, I did some tests with this solution, it seems that replace filter returns a string. So I tried to wrap the content in a `{% html %}` tag. Unfortunately, with this tag, nothing shows up in the rendered page. Ever faced something like this?  
  > **username_1**: Try using the `raw` filter  
  > **username_0**: It worked! Thank you so so much :)  
  
  ---
  
  