Commit ec8fa976 authored by Marijn van Wezel's avatar Marijn van Wezel
Browse files

Parse the reply content before storing it

parent f37b9ec7
Pipeline #2760 passed with stage
in 9 seconds
{
"name": "Semantic Structured Discussions",
"type": "semantic",
"version": "1.1.0",
"version": "1.2.0",
"author": [
"Marijn van Wezel ([https://wikibase-solutions.com Wikibase Solutions])"
],
......
......@@ -20,6 +20,9 @@
namespace SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\ReplyAnnotators;
use MediaWiki\MediaWikiServices;
use Parser;
use SemanticStructuredDiscussions\StructuredDiscussions\SDReply;
use SMW\DIProperty;
use SMW\SemanticData;
use SMWDIBlob;
......@@ -28,13 +31,32 @@ use SMWDIBlob;
* This annotation contains information about the content of a reply.
*/
class ContentAnnotator extends ReplyAnnotator {
/**
* @var Parser The current MediaWiki parser
*/
private Parser $parser;
/**
* ContentAnnotator constructor.
*
* @param SDReply $reply
*/
public function __construct( SDReply $reply ) {
parent::__construct($reply);
$this->parser = MediaWikiServices::getInstance()->getParser();
}
/**
* @inheritDoc
*/
public function addAnnotation( SemanticData $semanticData ): void {
$wikitext = $this->reply->getContent();
$content = strip_tags( $this->parser->recursiveTagParseFully( $wikitext ) );
$semanticData->addPropertyObjectValue(
new DIProperty( self::getId() ),
new SMWDIBlob( $this->reply->getContent() )
new SMWDIBlob( $content )
);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment