Statiq.Web icon indicating copy to clipboard operation
Statiq.Web copied to clipboard

Can't use code tags in Front Matter descriptions

Open SilentSin opened this issue 5 years ago • 3 comments

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?

SilentSin avatar Oct 10 '18 07:10 SilentSin

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:

  • Take a closer look at multi-line scalars in docs recipe front matter and make sure there isn’t a bug there
  • Consider adding an option to the docs recipe to process front matter with the Markdown processor (leave the default at off) - this will be a trade off between functionality and performance since running all front matter through a Markdown engine will add some time

daveaglick avatar Oct 14 '18 19:10 daveaglick

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: ...?

SilentSin avatar Oct 15 '18 00:10 SilentSin

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" };

daveaglick avatar Oct 15 '18 18:10 daveaglick