I have a set of markdown files that use YAML syntax for front matter . on passing these files to my jekyll project to build site , i have a set of html files generated . But if any of these files have improper front matter , they remain as .md files and not converted to html .
Now i need to validate the files for front matter before moving them into jekyll project . how can i achieve this ? is there any API or method to validate the file programmatically ?
First of all Jekyll should fail while executing build or serve commands if any of your pages has invalid front matter (since it must be a valid YAML snippet).
However, if that doesn’t work (for whatever reason), you can try run jekyll with --strict_front_matter switch to request additional scrutiny while generating your pages.
Here is an example how you run jekyll with the switch from command-line:
HI thanks for your reply , but what i need a validator program , which should check each file for front matter before i pass them to the jekyll project .
as my site gets its md files from different sources , i need to validate them for front matter before using them in my project . hope you understand my requirement now .
Sorry, I can’t help but to ask why you aren’t happy with using jekyll as your validator? It will be the only answer you can trust at the end of the day - other components may diverge from Jekyll’s definition of valid front matter and that fact might (or might not) lead to obscure issues.
Anyhow, in C# you can resort to use projects like YamlDotNet, SharpYaml or ParseYaml (for hands-on experience). Also, here is the list of projects on Github you can consider as well: https://github.com/topics/yaml?l=c%23.