mdiep / MMMarkdown

An Objective-C framework for converting Markdown to HTML.
MIT License
1.25k stars 168 forks source link

Some MMElement do not have parents #81

Closed jyhong836 closed 9 years ago

jyhong836 commented 9 years ago

Hi, I found you provide a method to add chid for MMElement, addChild:, but it seems that you do not use this method to add children somewhere. In MMParser.m, near line 865:

- (MMElement *)_parseListItemWithScanner:(MMScanner *)scanner atIndentationLevel:(NSUInteger)level
{
...
            if (canContainBlocks) // line 865
            {
                element.children = [self _parseElementsWithScanner:preListScanner];
            }
            else
            {
                element.children = [self.spanParser parseSpansInBlockElement:element withScanner:preListScanner];
            }
...
}

You assign the children directly. This will result in these children without any parent. Actually the children of list item would fail to provide parents when I need them.

Could you fix it? Or add a comment in MMElement.h to warn not to use the parent. Thanks.