| 1719 | parser = self, **kwargs) |
| 1720 | |
| 1721 | def _parse_article_sections(self, article, data): |
| 1722 | # If "References" is a section in the article, |
| 1723 | # the HTML will contain a marker <h*><span class="mw-headline" id="References">. |
| 1724 | # http://en.wikipedia.org/wiki/Section_editing |
| 1725 | t = article.title |
| 1726 | d = 0 |
| 1727 | i = 0 |
| 1728 | for x in data.get("sections", {}): |
| 1729 | a = x.get("anchor") |
| 1730 | if a: |
| 1731 | p = r"<h.>\s*.*?\s*<span class=\"mw-headline\" id=\"%s\">" % a |
| 1732 | p = re.compile(p) |
| 1733 | m = p.search(article.source, i) |
| 1734 | if m: |
| 1735 | j = m.start() |
| 1736 | article.sections.append(self.MediaWikiSection(article, |
| 1737 | title = t, |
| 1738 | start = i, |
| 1739 | stop = j, |
| 1740 | level = d)) |
| 1741 | t = x.get("line", "") |
| 1742 | d = int(x.get("level", 2)) - 1 |
| 1743 | i = j |
| 1744 | return article |
| 1745 | |
| 1746 | def _parse_article_section_structure(self, article): |
| 1747 | # Sections with higher level are children of previous sections with lower level. |