public static TocViewModel LoadToc(string tocContent, string filePath)
{
ParseState state = new InitialState(filePath);
var rules = new ParseRule[]
{
new TopicTocParseRule(),
new ExternalLinkTocParseRule(),
new TopicXrefAutoLinkTocParseRule(),
new TopicXrefShortcutTocParseRule(),
new ContainerParseRule(),
new CommentParseRule(),
new WhitespaceParseRule(),
};
var content = tocContent.Replace("\r\n", "\n").Replace("\r", "\n");
int lineNumber = 1;
while (content.Length > 0)
{
state = state.ApplyRules(rules, ref content, ref lineNumber);
}
return state.Root;
}