Including MathJax script in headers of Blazor app does not render MathML - mathjax

I am trying to show MathML equations using MathJax. I have included the script reference for MathML in the head portion. For Razor pages application, MathML is rendered properly. In Blazor (server side app), it shows as plain linear text.
When I refresh the page, it seems like it renders the MathML correctly but quickly reverts to plain text.
I am using .NET Core 3.0. I have also tried it on .NET Core 2.2 but does not work either.
Using the script below does not work...
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax#3/es5/mml-svg.js"></script>
but if I use this instead,
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML"></script>
it works only after page is refreshed manually.
<p>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>x</mi> <mo>=</mo>
<mrow>
<mfrac>
<mrow>
<mo>−</mo>
<mi>b</mi>
<mo>±</mo>
<msqrt>
<msup><mi>b</mi><mn>2</mn></msup>
<mo>−</mo>
<mn>4</mn><mi>a</mi><mi>c</mi>
</msqrt>
</mrow>
<mrow>
<mn>2</mn><mi>a</mi>
</mrow>
</mfrac>
</mrow>
<mtext>.</mtext>
</math>
</p>
Instead of showing the value of x of quadratic equation, it shows "x = − b ± b2 − 4ac 2a ." All math symbols / formatting are omitted.
If I refresh the page, then the MathML formatting is rendered properly. If I navigate to other pages and back to the page with MathML, page has to be refreshed in order to see the correct rendering.

The basic answer is that MathJax used this way is not going to work in Blazor. Anything that modifies the DOM is going to conflict with Blazor.
As soon as a Blazor re-render occurs, Blazor is going to wonder what happened to the tags that used to be there that MathJax removed.
Either:
You need to render this as part of a component where the MathML is not part of the DOM but rather a string parameter to your component.
For every re-render, you need to undo what MathJax has done to the page, let it re-render, then re-do MathJax's stuff.
I've done #1 for both Tex and MathML. For #2, I've only done this with Tex formatting... I haven't been able to get it to work with MathML yet. See how in my repo or just try the Nuget package.
https://github.com/limefrogyank/MathJaxBlazor

Related

Need suggestions in Kentico 7 for Responsive Slides

I am using Kentico 7 as the CMS to create the website. I am searching for a Rolling Banner web part, to put on the home page as the head banner, which can:
Be responsive.
Have caption area.
have navigation button on left and right.
would be nice to have instruction for me to insert to Kentico 7.
Must works in IE8, Firefox and Chrome.
I have tried to use Camera Slider but it does not work in IE8.
Checkout Slick.
It's a pretty easy to implement slider that has good browser support, with good documentation, and can be responsive if you pass it the right arguments.
I typically place the wrapper for my rotators in the HTML Envelope of a repeater, then use build a transformation for my slides, like this:
<!--Envelope before-->
<div class="slick-wrapper">
<!--Transformation-->
<div class="slide">
<img src="{% GetImageMethod() %}">
</div>
<!--Envelope after---->
</div>
However, keep in mind that IE 8 does not support media queries, so you'll want to use a JS feature detection library like Modernizr

show dc chart on browser using node.js

I am using your dc js in node js for rendering dc chart via server but i am facing many problems.
First I found all result of the svg in variable, but i want to know how to render chart in web browser.
When i write that SVG tags to file like "index.html" trying to run that file to browser, Chart is displayed but filter is not wroking
How we can use dc.js with node.js in browser?
I have tried many ways to get result, but i am not successed. If you have any tutorial or any guid Please let me know
I have not experimented with using dc.js on the server side with node, but you should be able to write the svg tag into an html document.
For example, if you browse the DOM of a live site like http://dc-js.github.io/dc.js/ in the DOM, using the Elements tab of Chrome's Developer Tools, you'll see something like this:
<div class="row">
<div id="yearly-bubble-chart" class="dc-chart">
<strong>Yearly Performance</strong> (radius: fluctuation/index ratio, color: gain/loss)
<a class="reset" href="javascript:yearlyBubbleChart.filterAll();dc.redrawAll();" style="display: none;">reset</a>
<div class="clearfix"></div>
<svg width="990" height="250"><g>
...
Note: I don't think you can get the interactive features of dc.js using it this way.

What is the most optimized way to render 50,000+ <td>s in a HTML page?

I have a very big table to display on a HTML page. And I have to do that with HTML, not EXCEL.
How can I make it as fast as possible? By setting no CSS to it or by setting some special CSS to it? (like small fonts)
I use jQuery to generate those <td> - the whole process is quite slow. After adding some tracking code I found it's not about the DOM query but just the DOM rendering.

Embedding a Heist tag inside of a javascript

Due to some library incompatibilities, I'm not able to use both Pandoc and Heist in the same application. As such, I decided to go with Markdown.JS to handle converting from Markdown format data into HTML in the client's browser. This could have some nice extra benefits in the long run, but in the short run, it is just because Pandoc depends on Blaze-HTML 0.4 and Heist depends on Blaze-HTML 0.5.
So, in a weblog-like application, I have a template that is used to fill out each entry, but then the content of each entry needs to get converted into HTML after the page has been loaded. So, I created a template that looks like this:
<h2> <entryTitle /> </h2>
<p class="entryDate"> <entryDate /> </p>
<div id="body_${entryDate}">
<entryBody />
</div>
<script type="text/javascript">
renderDiv("body_" + <entryDate />)
</script>
Unfortunately, the renderDiv call ultimately renders like this:
<script type='text/javascript'>
renderDiv("body_" + <entryDate />)
</script>
I have also tried using the string-embedded form (like I did for the div id in the template):
<script type="text/javascript">
renderDiv("body_${entryDate}")
</script>
Again, it renders verbatim.
How do I convince Heist to splice in the entryDate inside of the javascript?
Alternately, I'm using Prototype.JS as a Javascript library. Is there a way for me to put the script inside of the div and call the script basically with "self"?
<div id="body_${entryDate}">
<entryBody />
<script type="text/javascript">
renderDiv($(self))
</script>
</div>
Heist intentionally does not do splice substitution inside script tags, because splicing is done on DOM elements, and the contents of a script tag are plain text, not a DOM. We do it this way because if we did what you want, the parser would not be able to tell whether a '<' character represented the binary less than operator, or the start of a tag. user1891025's suggestion of generating a complete script tag is one way to do it.
However a dependency conflict between Heist and Pandoc shouldn't prevent you from using our built-in markdown splice. We don't actually link the Pandoc library. We only depend on the pandoc executable program. So all you have to do to make it work is build pandoc from a clean repository (or use a build sandbox), put the pandoc binary in your path, and then build Heist from another clean repository/sandbox. Then you won't have to worry about any of this javascript stuff.
If you still want to use javascript for this or something else, I would recommend that you not generate javascript from Heist. Heist was designed for HTML generation, not javascript generation. I prefer to put all my javascript in standalone .js files. Then you can conveniently load them using this splice from the snap-extras library.
To answer your last question, you can call a div like that with renderDiv(this).

Adding presence indicator to a custom web part

I have a custom web part which is generating some user data. I have added the appropriate code to output the standard presence icon and menu however this is acting rather stangely.
The rendered html of my web part is as follows:
<span>
USERNAME
<img border="0" height="12" width="12" src="/_layouts/images/blank.gif" onload="IMNRC('USEREMAIL')" id="imnUSERID" ShowOfflinePawn="1" />
</span>
Obviously replacing USERID, USERNAME, USEREMAIL etc.
The problems are twofold.
1) In IE7 the presence information does not get retrieved. The menu displays correctly but the icon does not appear and when you hover over the gap the drop down menu does not provide IM settings.
2) In IE8 RC1 the presence information comes back correctly and the icon displays, but the drop down list is rendered severeal inches above the icon. (see this screenshot)
Any help with these issues, or with other tips about adding presence to custom web parts would be greatfully received.
Update on progress
- Adding web page to 'Trusted Sites' for IE7 - did nothing
- Compatability view for IE8 makes no difference.
- Changed to id="CSRP_id,type=sip"
Changed code to the following on recommendation:
<span>
<img class="PresenceImage" src="/_layouts/images/imnhdr.gif" onload="IMNRC('USEREMAIL')" name="imnmark" ShowOfflinePawn="1" id="contact_im,type=sip" />
</span>
None of the above updates have been succesful.
First, you are going to have to eliminate whether you have a styling issue or a javascript issue.
If all of your presence bubbles display correctly, then get the IE Developer Toolbar and try and trace the css back. Even change the themes of the site and see if you get a different result.
This is our html, which works nice
<span>
<img width="12" src="/_layouts/images/blank.gif" onload="IMNRC('[USERMAIL]')" id="IMID[GUID]" ShowOfflinePawn=1 alt="Presence bubble">[USERNAME]</span>
Note:
[USERMAIL] = obvious
[USERNAME] = obvious
[GUID] = random guid
Also note the malformed img tag with no end "/>" (just ">"). We use this as this is the html generated by SharePoint (please don't get me started on that).

Resources