Open gortok opened 3 years ago
fix it in the parsing stage so there isn't a tooling mismatch between Visual Studio and Statiq
I like this approach since it saves the developer from their tools. We can check if the document being parsed for front matter is Razor and skip/move any @
lines down below the dashes (it wouldn't work for block statements, but we'd at least get the usings).
I don't love that it's not "pure" though, so I'll probably have it emit a warning as well so the developer knows what happened and can correct it later.
Gave this a little more thought and I’m going to move the issue to Statiq Framework and resolve it mostly in the ExtractFrontMatter
module. Specifically, I think there are two general cases we can handle in that module:
//
can be ignored entirely before being passed to YAML/JSON/XML parsers).@using
would fall into this category. In these cases I think a warning should always be generated since the content falling through is better placed in the body of the document, but at least it won’t totally break the build and there will be an indication of what to fix up.For each, the media type of the underlying file where front matter is being extracted may or may not be important. For example, we may want commented lines to be ignored regardless of media type, but @using
should only fall through for Razor files.
Then once the ExtractFrontMatter
module supports both these cases in general, I can implement specific content to either ignore or fall through in Statiq Web (like @using
for Razor files). It would be nice if the user could also specify additional front matter ignore or fall through rules as well.
If you have a code block in Visual Studio .cshtml that needs to include a using directive, like
@using Statiq.Razor
, Visual Studio puts the using directive at the top of the file; and in Statiq, this is sometimes reserved for Frontmatter(?)Example:
after using statement is added:
I understand a sidecar file may be added to resolve this issue; unclear if the existing error message should be updated when a
@using
statement is encountered for it to specially parse that as an error the user needs to fix; or otherwise fix it in the parsing stage so there isn't a tooling mismatch between Visual Studio and Statiq.Here's the error stack that is generated when this happens: