简体   繁体   English

MediaWiki扩展:从WikiPage / ParserOutput获取节或结构化文章文本

[英]MediaWiki extension: get sections or structured article text from WikiPage/ParserOutput

I am using the following to get a WikiPage and ParserOutput: 我正在使用以下方法来获取WikiPage和ParserOutput:

$parserOutput = WikiPage::factory(Title::newFromText('sometitle')) ->getParserOutput(new ParserOptions());

Then, I can see the sections in the article: 然后,我可以看到文章中的各节:

print_r($parserOutput->getSections());

But, this just gives me a section title and information about the order/TOC level. 但是,这只为我提供了部分标题以及有关订单/ TOC级别的信息。

How can I go from here to getting the text content of the section? 我如何从这里开始获得本节的文本内容?

Alternative question: how can I get structured data from an article? 替代问题:如何从文章中获取结构化数据? That is, I want to go from an article title to an object with a map of sections to text. 就是说,我想从文章标题转到带有部分到文本的映射的对象。

Not sure if there is a nice way. 不知道是否有一个好的方法。 For a hacky one, you can look at how MobileFrontend does it . 如果您是个骇人听闻的人,可以看看MobileFrontend 如何做到的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM