예제 #1
0
        /// <summary>
        /// we only parse simple key-value pairs here
        /// </summary>
        /// <param name="yamlSnippet"></param>
        /// <returns></returns>
        private Dictionary <string, string> ParseYamlKeyValuePairs(CodeBlockNode yamlSnippet)
        {
            Dictionary <string, string> result;

            try
            {
                result = MarkdownParser.ParseYamlKeyValuePairs(yamlSnippet.Text);
            }
            catch (ArgumentException)
            {
                throw new HelpSchemaException(yamlSnippet.SourceExtent, "Invalid yaml: expected simple key-value pairs");
            }

            foreach (var pair in result)
            {
                if (!IsKnownKey(pair.Key))
                {
                    throw new HelpSchemaException(yamlSnippet.SourceExtent, "Invalid yaml: unknown key " + pair.Key);
                }
            }

            return(result);
        }