public OverwriteDocumentModel Create(MarkdownFragmentModel model) { return(new OverwriteDocumentModel { Uid = model.Uid, Metadata = CreateMetadata(model) }); }
public static OverwriteDocumentModel Create(MarkdownFragmentModel model) { // TODO: support multi-layer yaml var yamlCodeBlockMetadata = ConvertYamlCodeBlock(model.YamlCodeBlock, model.YamlCodeBlockSource); var contentsMetadata = ConvertContents(model.Contents); return(new OverwriteDocumentModel { Uid = model.Uid, Metadata = MergeYamlCodeMetadataWithContentsMetadata(yamlCodeBlockMetadata, contentsMetadata) }); }
private MarkdownFragmentModel MarkdownFragment() { var result = new MarkdownFragmentModel(); result.UidSource = Eat(_l1InlineCodeHeadingRule, out var uid); result.Uid = uid; if (_yamlCodeBlockRule.Parse(Peek(), out var yamlCodeBlock)) { result.YamlCodeBlock = yamlCodeBlock; result.YamlCodeBlockSource = Next(); } result.Contents = PropertySection(); return(result); }
public static MarkdownFragment ToMarkdownFragment(this MarkdownFragmentModel model, string originalContent = null) { Dictionary <string, object> metadata = null; if (!string.IsNullOrEmpty(model.YamlCodeBlock)) { using (TextReader sr = new StringReader(model.YamlCodeBlock)) { metadata = YamlUtility.Deserialize <Dictionary <string, object> >(sr); } } return(new MarkdownFragment() { Uid = model.Uid, Metadata = metadata, Properties = model.Contents?.Select(prop => prop.ToMarkdownProperty(originalContent)).ToDictionary(p => p.OPath, p => p) }); }
private Dictionary <string, object> CreateMetadata(MarkdownFragmentModel model) { var metadata = ConvertYamlCodeBlock(model.YamlCodeBlock, model.YamlCodeBlockSource); return(ConvertContents(metadata, model.Contents)); }