fralau / mkdocs-macros-plugin

Create richer and more beautiful pages in MkDocs, by using variables and calls to macros in the markdown code.
https://mkdocs-macros-plugin.readthedocs.io
Other
335 stars 51 forks source link

{% for ...} loop creates line breaks #126

Closed alanlivio closed 2 years ago

alanlivio commented 2 years ago

The following code with indented lines generates break lines between macros elements

{% for social in config.extra.social %}
  {% set icon = social.icon.replace('/','-') %}
  :{{icon}}: [{{ social.title }}]({{ social.link }})  
{% endfor %} 

image

The desired behavior works online contatenation

{% for social in config.extra.social %}{% set icon = social.icon.replace('/','-') %}:{{icon}}: [{{ social.title }}]({{ social.link }})  {% endfor %} 

image

eyllanesc commented 2 years ago

try changing {% and %} to {%- and -%}, respectively.

fralau commented 2 years ago

@eyllanesc Spot on: mkdocs-macros uses the standard Jinja2 templating engine. That feature is documented under Whitespace Control.

alanlivio commented 2 years ago

Thank you both @eyllanesc and @fralau. The %- worked. The issue can be closed.