statiqdev / Statiq.Web

Statiq Web is a flexible static site generator written in .NET.
https://statiq.dev/web
Other
1.65k stars 236 forks source link

Can't use code tags in Front Matter descriptions #728

Open SilentSin opened 6 years ago

SilentSin commented 6 years ago

Using markdown code tags in the Description in a page's front matter doesn't work. The index table just shows the ` characters without applying the code formatting or creating a link to the API documentation.

I also tried the YAML block scalar styles described here https://stackoverflow.com/a/21699210/807064 as suggested by @daveaglick but Wyam gives an error when I use any of them: Exception while processing document file:///C:/Users/ .......... While scanning a block scalar, did not find expected comment or line break.. Maybe Wyam is only giving the YAML parser a single line even if I put a blank one after it?

daveaglick commented 6 years ago

I know the YAML multi-line scalars work in front matter (I use them in several of my own sites), so it could be something with the docs recipe is getting in the way.

The front matter also isn’t sent through a Markdown processor by default, so I’d expect any code fencing not to render as <code> elements.

I think this issue has two components:

SilentSin commented 6 years ago

I just tried it again and got it working with a double space at the start of each line. I must not have tried that before.

Would it be feasible to enable markdown as part of the front matter itself instead of for the whole project? Either as a separate FrontMatterMarkdown: on or as some sort of modifier to the Description such as MarkdownDescription: ...?

daveaglick commented 6 years ago

Would it be feasible to enable markdown as part of the front matter itself instead of for the whole project?

I like that idea. In fact, we could do both since global metadata "trickles down" to the document - so if you define that front matter should be processed as Markdown globally, it'll act the same as if you added that flag to each document directly.

We can also make it apply to specific front matter properties. I'm thinking something like:

Description: Hello **world!**
SomeOtherField: Foo _Bar_
FrontMatterMarkdown:
  - Description
  - SomeOtherField
---
...

Or globally in the config file:

Settings["FrontMatterMarkdown"] = new [] { "Description", "SomeOtherField" };