Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
HtmLawed and other input format
cdavid
New
Dear all (especially @Todd @Lincoln ),
I am trying to set up a plugin which allows you to write in a different format than HTML, mainly TeX / LaTeX. All seems to work fine, but I can't get HtmLawed (or Vanilla?) to play nicely with the new plugin.
So, in the interface I have a radio button that allows a user to select the input format (LaTeX / HTML). If the users selects LaTeX, the content is then sent to a web service that takes LaTeX and returns properly formatted XHTML (and I can guarantee that) that is added to the database in a special column (BodyXHTML), alongside with Format=LaTeX in GDN_Discussion / Comment.
The problem is that HtmLawed / Vanilla are too smart and are purifying this such that an input such as:
which would translate into XHTML + MathML
is actually rendered as
I am already hooking into: DiscussionController_BeforeCommentBody_Handler to do:
Disabling HtmLawed doesn't solve anything, making me think it's a more intricate Vanilla problem.
Any suggestions and pointers are welcome.
Thanks a lot,
/cd
I am trying to set up a plugin which allows you to write in a different format than HTML, mainly TeX / LaTeX. All seems to work fine, but I can't get HtmLawed (or Vanilla?) to play nicely with the new plugin.
So, in the interface I have a radio button that allows a user to select the input format (LaTeX / HTML). If the users selects LaTeX, the content is then sent to a web service that takes LaTeX and returns properly formatted XHTML (and I can guarantee that) that is added to the database in a special column (BodyXHTML), alongside with Format=LaTeX in GDN_Discussion / Comment.
The problem is that HtmLawed / Vanilla are too smart and are purifying this such that an input such as:
$123+3241<999$
which would translate into XHTML + MathML
<div class="document">
<div class="para">
<p style="" class="p">
<m:math display="inline">
<m:semantics>
<m:mrow>
<m:mrow>
<m:mn>123</m:mn>
<m:mo>+</m:mo>
<m:mn>3242</m:mn>
</m:mrow>
<m:mo><</m:mo>
<m:mn>999</m:mn>
</m:mrow>
</m:semantics>
</m:math>
</p>
</div>
</div>
is actually rendered as
<p> 123+3242</p>
I am already hooking into: DiscussionController_BeforeCommentBody_Handler to do:
if(isset($Sender->EventArguments["Comment"])){
$Sender->CurrentComment->Body = $Comment->BodyXHTML;
}
else{
$Sender->Discussion->Body = $Comment->BodyXHTML;
}
and in public function PostController_BeforeCommentBody_Handler($Sender) {
$Sender->CurrentComment->Body = $Sender->EventArguments['Comment']->BodyXHTML;
}
Disabling HtmLawed doesn't solve anything, making me think it's a more intricate Vanilla problem.
Any suggestions and pointers are welcome.
Thanks a lot,
/cd
Tagged:
0
Comments
So, I am still experimenting: I leave the format to be Html for the comments and disable HtmLawed by putting
return $Html;
before the actual call to the htmLawed function (a crude disable) and everything works perfectly for LaTeX posts. Still, since now HtmLawed is disabled, any mention of < > in the posts will break the XHTML .../cd
In your event handlers after you assign body: Add a formatter function to your plugin: Above your class definition you'll have to to tell the framwork about your formatter:
/cd