       {% capture anchor %}{{ anchor }} {{ include.anchorAttrs | replace: '%heading%', header }}{% endcapture %}
      {% endif %}

      {% capture anchor %}<a {{ anchor }}>{{ include.anchorBody | replace: '%heading%', header | default: '' }}</a>{% endcapture %}

      <!-- In order to prevent adding extra space after a heading, we'll let the 'anchor' value contain it -->
      {% if beforeHeading %}
        {% capture anchor %}{{ anchor }} {% endcapture %}
      {% else %}
        {% capture anchor %} {{ 