Closed Alysha-94 closed 5 years ago
The escaping rules in Stencil changed recently [sorry :(]
In my own site I use:
from stencil import SafeStr
@Site.register_context_provider
def global_context(ctx):
ctx['safe'] = SafeStr
return ctx
And in my template:
{{ safe(this.content) }}
No worries thanks, this solution is working well now but the meta-data is not being stored
index.md
title: Home
in_menu: False
---
outputs:
<p>title: Home
in_menu: False</p>
<hr>
The loader for '.md' files does not support front matter like that.
If you want a document with front matter where the body is rendered as Markdown, use a .yaml file and set content_type: MarkdownPage
We rather extensively use markdown files with .md
extensions to keep track of the content for various sites we use (Specifically GitHub flavored markdown). Take for example this file over on the site we are attempting to replace: https://github.com/CustomProgrammingSolutions/CPS_gatsby/blob/master/content/blog-posts/2018-04-01/sample-blog-post.md
I see a couple of options here:
What do you think of warning the user via a message at render time if someone attempts to build a markdown file that contains the frontmatter like what happened in this thread? (I can see how we might not want to pessimize performance on the build step my making it scan for this just for a informative message)
That would require making huge assumptions/restrictions on the users content - who are we to say you didn't want to have something yaml-ish at the start of your markdown?
This is a clear case of "it's better to document your way out of a problem".
Yes, you can register another loader to override the "default" .md loader.
The current docs on the md loader are as follows:
The .md loader reads the files contents, and returns a dict with a single key of content_type as MarkdownPage.
This wording could do with some reworking to match more clearly the description of how a loader works.
The loader for '.md' files does not support front matter like that.
I see now sorry for the confusion, thanks for pointing that out.
I'm starting work on that loader here: https://github.com/shuttle1987/gilbert-frontmatter-markdown I'll make a PR to update the docs soon hopefully.
We have tried to use a
.md
extension instead of.yaml
forpages/index.md
The markdown plugin loads successfully, and it has added a tags to links, p tags to paragraphs etc but is rendering the tag as text instead of as a HTML element. The meta-data is also not being stored.
How the home page is rendered:
With inspect and edit as HTML I can see that the markdown converter has actually outputted HTML entities rather than rendering as HTML elements.