Open kevinmpowell opened 8 years ago
I'm definitely open for PRs.
This is happening to me. I am not using the include tag, I am using
{% markdown %}{{textToRender}}{% endmarkdown %}
from within a macro.
Fixed by changing it to:
{% markdown %}
{{textToRender}}
{% endmarkdown %}
@colinsullivan are you only rendering one line of markdown at a time?
I was experiencing this for both:
textToRender
variable.textToRender
.In both templates I was attempting the single line approach (this line was indented):
{% markdown %}{{textToRender}}{% endmarkdown %}
In both cases, I was able to work around the issue by adjusting indentation of the {% markdown %}
and {{textToRender}}
lines relative to one another.
@zephraph I'm not sure how to fix this problem without breaking the indentation feature.
The indentation normalization feature makes it nice when you are writing markdown directly in your nunjucks files, but messes up when nunjucks-markdown is being used in a more automated fashion.
I think that the best solution is simply to make the indentation feature easy to disable.
.....or even disabled by default.
It's a super weird bug. We could pass a flag in to disable the indention feature. I'm sure there's got to be a way to actually fix it. The first step to that is writing tests to replicate the issue.
Just ran into this issue myself. Worked around it using a macro:
{% macro markdown() %}
{% set content=
caller() %}
{% markdown %}
{{ content }}
{% endmarkdown %}
{% endmacro %}
Then rendering the markdown like so:
{% call() markdown() %}{{ my_markdown }}{% endcall %}
I think the best solution for this problem, at least for @colinsullivan's case (and my own) would be to allow markdown to be applied as a filter as well, so that for those cases you know you're only feeding it the contents of the model attribute:
{{ textToRender | markdown }}
Ran into this issue myself. As a temp-fix it should be mentioned in the readme maybe?
In my case at least: https://gist.github.com/haavardb/643d78d6914992dcb955a4abac5e370a
I'm having a similar issue as reported here: https://github.com/zephraph/nunjucks-markdown/issues/4#issuecomment-169419993
But it only occurs when I use the
{% include 'file.md' %}
method. I'm actually seeing different bugs with the first and second lines of the included file depending on the indentation of the call.Example:
I'm using the
grunt-nunjucks-2-html
package in a project that has 4 spaces as the indentation method.