private StringBuffer Insert(StringBuffer name, StringBuffer tokenContent, Type tokenType) { StringBuffer result = $"{{\"name\":\"{name}\""; switch (tokenType) { case Type.NonLeaf: { // If tokenContent is not empty ,should remove the last character(',') if (tokenContent.GetLength() > 0 && tokenContent.EndsWith(',')) { // TODO: add a method 'remove' of StringBuffer string contentTemp = tokenContent; tokenContent = contentTemp.Remove(contentTemp.Length - 1); } result += $",\"children\":[{tokenContent}]}},"; break; } case Type.Leaf: { // Leaf will be needed later // TODO: result += "\"size\":" + tokenContent + "\n},"; result += "},"; break; } default: return(StringBuffer.Empty); } return(result); }
private static IMarkdownToken GroupTextTokens(IMarkdownParser parser, IMarkdownRule rule, bool wrapParagraph, StringBuffer textContent, SourceInfo si) { if (textContent.EndsWith('\n')) { textContent = textContent.Substring(0, textContent.GetLength() - 1); } var rawMarkdown = textContent.ToString(); return CreateTwoPhaseToken(parser, rule, wrapParagraph, si.Copy(rawMarkdown)); }
private static IMarkdownToken GroupTextTokens(IMarkdownParser parser, IMarkdownRule rule, bool wrapParagraph, StringBuffer textContent, SourceInfo si) { if (textContent.EndsWith('\n')) { textContent = textContent.Substring(0, textContent.GetLength() - 1); } var rawMarkdown = textContent.ToString(); return(CreateTwoPhaseToken(parser, rule, wrapParagraph, si.Copy(rawMarkdown))); }