long division is not properly displayed in Mathjax - mathjax

<math xmlns="http://www.w3.org/1998/Math/MathML">
<mlongdiv charalign="center" charspacing="0px" stackalign="left">
<mn>8</mn>
<mrow>
<none></none>
<mn>3</mn>
</mrow>
<msgroup>
<mn>251</mn>
<msrow>
<menclose notation="bottom">
<mn>2</mn>
</menclose>
<menclose notation="bottom">
<mn>4</mn>
</menclose>
</msrow>
<msrow>
<none></none>
<mn>1</mn>
</msrow>
</msgroup>
</mlongdiv>
</math>
This is how it's currently displayed(https://jsbin.com/gobojih/edit?html,output)
This is how it's displayed in wiris Mathtype demo page(https://demo.wiris.com/mathtype/en/developers.php)

The MML3 extension is experimental, and may not real all possible elementary math expressions, or handle all possible attribute values. Also, the output is not always optimal.
In your case, the outermost <msgroup> is causing problems, as the extension doesn't seem to read it properly. If you move the <mn>251</mn> outside the msgroup, that will allow the output to render better.
The MML3 extension doesn't handle the <none> element, but changing the nrow that contains it to be <mn>3 </mn> allows that to render in the way you indicate. So
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mlongdiv charalign="center" charspacing="0px" stackalign="left">
<mn>8</mn>
<mn>3 </mn>
<mn>251</mn>
<msgroup position="1">
<msrow>
<menclose notation="bottom">
<mn>2</mn>
</menclose>
<menclose notation="bottom">
<mn>4</mn>
</menclose>
</msrow>
<mn>1</mn>
</msgroup>
</mlongdiv>
</math>
renders as
which may be sufficient for your needs. This does mean you will need to edit the MathType output, I'm sorry to say.

Related

How to fix the error of Maximum call stack size exceeded when using pattern lab?

In pattern lab Maximum call stack size exceeded error and I don't know why. I'm not doing anything that I haven't done before.
In 01-molecules/02-cart/cart.mustache I have this code
{{#miniCart}}
<div class="mini_cart_item">
<img class="mini_cart_image" src={{img}} alt="">
<div class="mini_cart_info">
<span>£{{price}}</span>
<h4 class="mini_cart_title">{{title}}</h4>
</div>
</div>
{{/miniCart}}
That data comes from 01-molecules/02-cart/cart.json. It works fine.
Then I have 02-organisms/mini-cart.mustache and the code is
<div class="mini_cart">
{{#miniCart}}
{{> cart}}
{{/miniCart}}
</div>
The cart comes from the molecule above, the data comes from 02-organisms/mini-cart.json. Is is the some json code just with more objects.
That {{> cart}} throws the Maximum call stack size exceeded error. If I remove that line of code and replace it with anything, like {{title}} the code just works.
What might be the problem?
To run pattern lab I am running this
/MyMAMP/www/2016/edition-node-gulp/node_modules/gulp/bin/gulp.js patternlab:serve
From google search I tried this
/MyMAMP/www/2016/edition-node-gulp/node_modules/gulp/bin/gulp.js patternlab:serve --stack_size=2048
but the result is the same thing.
Maintainer of Pattern Lab Node here.
{{> cart}} should be {{> molecules-cart}}
Give that a shot.
remove reference to 'miniCart' template inside the 'cart' template
this causes an infinite recursion in template engine

flask_moment current time refresh in browser not updating

Following basic setup with python3.4, jinja2, flask_moment (0.5.1), Flask(0.10.1) integration.
I am trying out the capability to simply understand the workings.
The example is nonsensical but I want to get browser to display:
firstly, the actual time in real time ("The local time is ...") continually updated in real time
secondly, the time elapsed ("That was ...").
Jinja2 code:
<p>The local time is {{ moment(current_time).format('LT', refresh=True) }}.</p>
<p>That was {{ moment(current_time).fromNow(refresh=True) }}</p>
The second line refresh works fine in the browser ("That was 1/2/3 minutes ago"), indicating all libraries working correctly, but the first line refresh doesn't work.
The method moment(current_time).format('LT', refresh=True) I thought would display the time in real time with the refresh option set to "True", but it doesn't.
Looking at browser markup, all the libraries are there and there are no errors. See markup below.
Any hints appreciated or maybe I am misunderstanding the capability?
Browser source:
<div class="container">
<div class="page-header">
<h1>Hello, Flask!</h1>
</div>
</div>
<p>The local time is <span class="flask-moment" data-timestamp="2016-01-28T12:19:20Z" data-format="format('LT')" data-refresh="60000" style="display: none">2016-01-28T12:19:20Z</span>.</p>
<p>That was <span class="flask-moment" data-timestamp="2016-01-28T12:19:20Z" data-format="fromNow(0)" data-refresh="60000" style="display: none">2016-01-28T12:19:20Z</span></p>
<script src="/static/bootstrap/jquery.min.js?bootstrap=3.3.5.7"></script>
<script src="/static/bootstrap js/bootstrap.min.js?bootstrap=3.3.5.7"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment-with-locales.min.js"></script>
<script>
moment.locale("en");
function flask_moment_render(elem) {
$(elem).text(eval('moment("' + $(elem).data('timestamp') + '").' + $(elem).data('format') + ';'));
$(elem).removeClass('flask-moment').show();
}
function flask_moment_render_all() {
$('.flask-moment').each(function() {
flask_moment_render(this);
if ($(this).data('refresh')) {
(function(elem, interval) { setInterval(function() { flask_moment_render(elem) }, interval); })(this, $(this).data('refresh'));
}
})
}
$(document).ready(function() {
flask_moment_render_all();
});
This is a misunderstanding on how Flask-Moment works, probably due to my not very clear documentation.
The moment(current_time).format('LT', refresh=True) expression that you put in the Jinja template runs in the server, not the browser. In particular, the current_time variable has a fixed value that I presume you assigned in the Python code.
The result of running this expression is some Javascript code that runs on the browser. When you pass refresh=True, this Javascript code runs every minute. But while the code does run repeatedly, the rendered time is always the same, because a value for current_time was set on the server and isn't being updated. The use of auto-refresh only makes sense with one of the "dynamic" rendering options of moment.js, such as the "X secs/mins ago" format, because those change as time passes.
If you wanted to implement something like a clock, that updates the time, then you would probably need a solution that does it all in Javascript on the browser.
So it appears that according to the documentation, the refresh=true is only going to be updated every minute. Have you given it a minute to verify that it's not refreshing?
The rendered dates and times can be refreshed periodically by passing
a refresh = True argument to any of the above functions. This is
useful for the relative formats, because they are updated as time
passes. The refresh interval is fixed at one minute.
http://blog.miguelgrinberg.com/post/flask-moment-flask-and-jinja2-integration-with-momentjs

DustJS logic to verify empty string

I need to write logic to check whether the value is empty or it has string. Any help on this.. i tried this following. but it doesn't work in nodejs and throwing error
{#if cond="'{notes}' != '' || '{errors}' != '' "}
display html
{/if}
The #if helper is deprecated and should not be used. However, based on the code you've given, you should probably be able to use an exists check.
{?notes}
{?errors}
{! Display HTML !}
{/errors}
{/notes}
If that doesn't work for some reason, you could use the #ne helper.
{#ne key=notes value=""}
...
{/ne}
If that still isn't good enough, you could try writing a context helper. The documentation on dustjs.com is excellent.
{?notes}
Display HTML
{:else}
{?errors}
Display HTML
{/errors}
{/notes}
should do the trick.

Modx Get page and sorting with &sortbyTV

Ok, before anyone points me to the Modx RTFM, let me just say, that I've actually implemented this on a few sites, using getpage rather than just getresources and they have all worked according to my needs, and what those needs were was to give visitors the ability to sort a list according to a template variable.
Now in all instances I used a listbox (single select)template variable as so (in this case for rating):
1==[[$one_star]] || 1.5==[[$one_and_half]] || 2==[[$two_star]] || 2.5==[[$two_and_half]] || 3==[[$three_star]] || 3.5==[[$three_and_half]] || 4==[[$four_star]] || 4.5==[[$four_and_half]] || 5==[[$five_star]]
Now, on my current project which is days from launch, I created a template variable called "price", in which the numerical value is entered into a text field, nothing more and, for some reason, getpage doesn't return the proper output. For example on a "low to high" page the first in the list is not the lowest priced item.
here's an example of the call. (I use getpage for pagination)
[[!getPage?
&elementClass=`modSnippet`
&showHidden=`1`
&sortbyTV=`price`
&sortdirTV=`ASC`
&element=`getResources`
&parents=`7,8,9,10,11,12`
&limit=`8`
&pageLimit=`2`
&pageVarKey=`page`
&includeTVs=`1`
&includeContent=`1`
&tpl=`store_post`
&tvPrefix=`tv.`
&cache=`0`
]]
<div class="paging">
<ul class="pageList">
[[!+page.nav]]
</ul>
</div>
and here's the template:
<div class="product_info_container">
<div class="product_name">[[+tv.product_name]]</div>
<div class="product_details">[[+tv.product_details]]</div>
<div class="product_price">price: [[+tv.price]] USD</div>
<div class="product_purchase">[[+tv.pay_button]]</div>
<div class="view_cart">[[$viewcart]]</div>
</div>
I'm on Revolution 2.2.13-pl (I tried updating to 2.2.14 but there was a php error which scared the heck outta me and until I isolate the cause, with launch looming, I'm not touching it! :P) All packages are current as well.
Any help or suggestions would be greatly appreciated because, needless to say, I'm stumped :)
p.s. I know the above getpage call is for ASC not DESC...I was just using the low to high as an example

Text wrapping inconsistent in Firefox 3 on PC only

This is a recurring problem I have in Firefox 3.0. It seems when I keep refreshing sometimes it wraps, sometimes it doesn't. When it doesn't wrap, I can adjust the window size and the sIFR'd element will snap to its correct size. I need my elements to wrap on load, based on the width of it's container.
I have the most current 'nightly build' of sIFR 3.0.
I want to sIFR a h2 tag. The h2 tag is enclosed in a div, and both have set widths.
<div class="recipe-title">
<h2>This is a recipe title</h2>
</div>
In my sifr.js file, I have the following parameters set:
forceWidth = true;
fitExactly = true;
preventWrap = false;
My .sifr.CSS file looks like this:
#media screen {
.sIFR-active .recipe-title h2 { width:455px; font-size:16px; text-transform:uppercase; }
}
And my normal CSS file looks like this:
.recipe-title, .recipe-title h2 { width:400px; }
Everything else seems to work in all other browsers except for FF3 on PC only. Is this a known bug?
sIFR may be initializing too early. Easiest fix is to set sIFR.useDomLoaded = false; before sIFR.activate(), which will wait until page load before replacing the elements.
You can also look into using sIFR.useStyleCheck = true; which needs a bit more CSS but will wait until the CSS has loaded.
I'm pretty sure it's text-transform:uppercase enlarging the word width after the flash width has been set
I've been trying to figure a solution to this for some time
For the common user... make sure that you set your width and height of the div container for your object or image. Firefox will wrap any text following if these values are not set.
A possibility is that you might need to specify a height on the element. IE7 can have a similar problem.
Is sIFR.activate() located in the sifr.js file or the sifr-addons.js file?
Per Mark's advice, uncommenting sIFR.useStyleCheck = true; just before sIFR.activate() worked for me.
Robert, sIFR.activate() is found in sifr.js.

Resources