/// <summary> /// TODO : Problem to fix, all lists are represented as Numbered... /// Process an array of markdown items of a list (with spaces to define the item level) /// The pattern can be detected as a CodeBlock pattern, so fix it with the try catch. /// I should probably not let defining a CodeBlock with spaces and tabulations, /// but only with tabulations... (WIP) /// </summary> /// <param name="core"></param> /// <param name="bulletedItems">Items of a list, split in an array by break lines</param> /// <param name="paragraphStyle"></param> public void MarkdownList(Md2MlEngine core, string[] bulletedItems, string paragraphStyle = "ParagraphList") { foreach (var item in bulletedItems) { // Detect if item is ordered or not var matchedPattern = PatternMatcher.GetMarkdownMatch(item); if (matchedPattern.Key != ParaPattern.OrderedList && matchedPattern.Key != ParaPattern.UnorderedList) { try { matchedPattern = PatternMatcher.GetMatchFromPattern(item, ParaPattern.OrderedList); } catch (Exception e) { matchedPattern = PatternMatcher.GetMatchFromPattern(item, ParaPattern.UnorderedList); } } // Then count spaces 3 by 3 to define the level of the item var nbSpaces = matchedPattern.Value.Groups[0].Value.TakeWhile(Char.IsWhiteSpace).Count();; var itemLvl = nbSpaces / 3; // Then Create paragraph, properties and format the text Paragraph paragraph1 = CreateParagraph(paragraphStyle); NumberingProperties numberingProperties1 = new NumberingProperties(); NumberingLevelReference numberingLevelReference1 = new NumberingLevelReference() { Val = itemLvl }; NumberingId numberingId1 = GetListType(matchedPattern.Key); numberingProperties1.Append(numberingLevelReference1); numberingProperties1.Append(numberingId1); paragraph1.ParagraphProperties.Append(numberingProperties1); MarkdownStringParser.FormatText(core, paragraph1, matchedPattern.Value.Groups[2].Value, new StyleProperties()); } }
public void MarkdownBulletedList(Md2MlEngine core, List <string> bulletedItems, string paragraphStyle) { foreach (var item in bulletedItems) { Paragraph paragraph1 = CreateParagraph(paragraphStyle); NumberingProperties numberingProperties1 = new NumberingProperties(); NumberingLevelReference numberingLevelReference1 = new NumberingLevelReference() { Val = 0 }; NumberingId numberingId1 = new NumberingId() { Val = 1 }; numberingProperties1.Append(numberingLevelReference1); numberingProperties1.Append(numberingId1); paragraph1.ParagraphProperties.Append(numberingProperties1); MarkdownStringParser.FormatText(core, paragraph1, item, new FontProperties()); } }
/// <summary> /// Transform the markdown content to openXML (docx) format. /// </summary> /// <param name="content">The markdown content to transform</param> public void WriteMdText(string content) => MarkdownStringParser.Parse(this, content);
public void WriteMdText(Paragraph para, string text) => MarkdownStringParser.Parse(this, text);
public void WriteMdText(string text) => MarkdownStringParser.Parse(this, text);