Spacing issue around parenthesis when explorer accessibility is turned on - mathjax

When the accessibility explorer is activated, there's a spacing issue. The spaces after 'f', 'M', and 'cos' are way too big. It's important that those spaces are small for readability reasons, since (for instance) "M(x)" is a single object, not two separate things as "M (x)" might suggest.
Current behavior
Expected behavior
Steps to Reproduce:
Open https://jsbin.com/ bohitetaka/edit?html,js,output
Check how math expression is displayed by making accessibility explorer property to false and true.
When explorer is set to false the spacing is correct, but I also want the accessibility feature.

This is due to the fact that the explorer uses semantic-enrichment that modifies the underlying MathML for the expression, and that adds mrows around the parentheses, which in turn causes MathJax to interpret the parentheses as though they came from \left...\right, which are spaced differently.
This was fixed in v3.1.3 via #583, but the fix has not been back-ported to v2.7.
For now, you can use the following configuration to work around the issue:
MathJax.Hub.Register.StartupHook('MathML Jax Ready', function () {
var PARSE = MathJax.InputJax.MathML.Parse;
PARSE.Augment({
_AddChildren: PARSE.prototype.AddChildren,
AddChildren: function (mml, node) {394
this._AddChildren(mml, node);
if (mml.type === "mrow" && (mml.open || mml.close)) {
if (mml.open && !mml.data[0].stretchy) delete mml.open;
if (mml.close && !mml.data[mml.data.length-1].sretchy) delete mml.close;
}
}
});
});

Related

Closing an Imgui window: this seems like it should be easy. How does one do it?

I have started using the imgui system for visualizing "whatever". I am in my first few hours, and am running up against what seem to be common snags.
However, although I can see some pretty good support for the C++ versions of ImGui (which I'll transition to eventually), the python imgui content is mostly obscured.
What I am looking for is the solution to the following problem:
while not glfw.window_should_close(window):
...
imgui.new_frame()
imgui.begin("foo-window", closable=True)
imgui.end()
Everything works fine. However, the window doesn't close. I understand that the window doesn't close because it is always created every loop.
What I am looking for is:
How do I detect and identify that the particular window has been closed, and block it from being re-generated?
I'm not at all familiar with the imGui for Python, but if it at all follows the similar pattern as in imGui for c++, then you need to follow this pattern:
static bool show_welcome_popup = true;
if(show_welcome_popup)
{
showWelcomePopup(&show_welcome_popup);
}
void showWelcomePopup(bool* p_open)
{
//The window gets created here. Passing the bool to ImGui::Begin causes the "x" button to show in the top right of the window. Pressing the "x" button toggles the bool passed to it as "true" or "false"
//If the window cannot get created, it will call ImGui::End
if(!ImGui::Begin("Welcome", p_open))
{
ImGui::End();
}
else
{
ImGui::Text("Welcome");
ImGui::End();
}
}
JerryWebOS's answer is basically correct, but to add to that here's the python version. Note that the documentation for pyimgui is a good source to find answers to questions like this one.
https://pyimgui.readthedocs.io/en/latest/reference/imgui.core.html?highlight=begin#imgui.core.begin
imgui.begin() returns a tuple of two bools: (expanded, opened).
You can use this to detect when the user closes the window, and skip rendering the window in the next frames accordingly:
window_is_open = True
while not glfw.window_should_close(window):
...
imgui.new_frame()
if window_is_open:
_, window_is_open = imgui.begin("foo-window", closable=True)
...
imgui.end()

localstorage undefined on ie11 (windows 10) what is the solution? [duplicate]

The localStorage object in Internet Explorer 11 (Windows 7 build) contains string representations of certain functions instead of native calls as you would expect.
This only breaks with vanilla JavaScript and sites like JSFiddle have no problem with this code but I suspect it's because there are localStorage polyfills in place that correct it.
Take this HTML page code for example:
<!DOCTYPE html>
<script>
localStorage.setItem('test', '12345');
alert(localStorage.getItem('test'));
localStorage.clear();
</script>
This works perfectly well in all my installed browsers except for IE11. An error occurs on the first line 'SCRIPT5002: Function expected'.
Taking a look at what type the setItem function actually is in the IE developer tools console, states that it's a string...?
typeof localStorage.setItem === 'string' // true
Printing out the string for setItem displays the following:
"function() {
var result;
callBeforeHooks(hookSite, this, arguments);
try {
result = func.apply(this, arguments);
} catch (e) {
callExceptHooks(hookSite, this, arguments, e);
throw e;
} finally {
callAfterHooks(hookSite, this, arguments, result);
}
return result;
}"
Oddly enough, not all functions have been replaced with strings, for example, the corresponding getItem function is indeed a function and works as expected.
typeof localStorage.getItem === 'function' // true
Changing the document mode (emulation) to 10 or 9 still doesn't resolve the problem and both result in the same error. Changing the document mode to 8 gives the following error 'Object doesn't support this property or method' which is expected since IE8 doesn't support localStorage.
Is anyone else having the same issue with IE11 on Windows 7 where the localStorage object seems 'broken/corrupt'?
Turns out this is a problem in the base version of IE11 (11.0.9600.16428) for Windows 7 SP1.
After installing a patch to update to 11.0.9600.16476 (update version 11.0.2 - KB2898785) the issue gets resolved. Links to other versions of Windows (32-bit etc.) can be found at the bottom of the patch download page.
It's not just IE11's fault.
Probably WEINRE is injected into the page. It hooks into several system functions to provide Developer Tools functionality, but IE11 interprets assignments to the localStorage and sessionStorage properties wrong, and converts the hook functions into strings, as if they were the data that is going to be stored.
There's a comment in the apache/cordova-weinre repo which says:
#In IE we should not override standard storage functions because IE does it incorrectly - all values that set as
# storage properties (e.g. localStorage.setItem = function()[...]) are cast to String.
# That leads to "Function expected" exception when any of overridden function is called.
object[property] = hookedFunction unless navigator.userAgent.match(/MSIE/i) and (object is localStorage or object is sessionStorage)
Looks like it's either an old version of WEINRE being used, or this change hasn't been officially released (it's been there since 2013).
My localStorage returned undefined and I couldn't figure out why - until I realized that it was because I was running the HTML-page (with the localStorage script) directly from my computer (file:///C:/Users/...). When I accessed the page from a server/localhost instead it localStorage was indeed defined and worked.
In addition to the already excellent answers here, I'd like to add another observation. In my case, the NTFS permissions on the Windows %LOCALAPPDATA% directory structure were somehow broken.
To diagnose this issue. I created a new Windows account (profile), which worked fine with the localStorage,so then I painstakingly traversed the respective %LOCALAPPDATA%\Microsoft\Internet Explorer trees looking for discrepancies.
I found this gem:
C:\Users\User\AppData\Local\Microsoft>icacls "Internet Explorer"
Internet Explorer Everyone:(F)
I have NO idea how the permissions were set wide open!
Worse, all of the subdirectories has all permissions off. No wonder the DOMStore was inaccessible!
The working permissions from the other account were:
NT AUTHORITY\SYSTEM:(OI)(CI)(F)
BUILTIN\Administrators:(OI)(CI)(F)
my-pc\test:(OI)(CI)(F)
Which matched the permissions of the parent directory.
So, in a fit of laziness, I fixed the problem by having all directories "Internet Explorer" and under inherit the permissions. The RIGHT thing to do would be to manually apply each permission and not rely on the inherit function. But one thing to check is the NTFS permissions of %LOCALAPPDATA%\Microsoft\Internet Explorer if you experience this issue. If DOMStore has broken permissions, all attempts to access localStorage will be met with Access Denied.

SVG fill animation cycle broken

i am looking to simply animate two fill colors of an SVG. ping pong, loop, however you want to call it. the pieces work on their own, but put together into a recursive function to form the loop breaks it.
here's what i have (using jQuery):
$(document).ready( function() {
var items = $('.st1');
items.css('fill', '#ff3600');
bl-colorCycle();
function bl-colorCycle() {
console.log('color cycle called');
items.animate({fill: '#00ffcc'}, 5000, 'linear', bl-colorCycle);
}
});
for some reason, this throws this error:
SyntaxError: missing ( before formal parameters
what the heck am i missing? i've torn this apart several times and for the life of me, i cannot spot where the hell the missing '(' is! i've read all that i can find here, and found nothing that helps in this scenario. i've even tried putting the function call at the very end, just to see if some weird web-voodoo was at play...bupkiss. :(
i'm hoping someone out there has sharper eyes... :P
TIA.
WR!
Hyphen ("-") is not a legal identifier character. Try underscore ("_") instead. Ie. bl_colorCycle().

Can't get range from a defined name

Excel 2016 (Office 365) 32 bits, 16.0.6965.2115, Visual Studio 14.0.25425.01 Update 3
I'm quite sure the statement below used to work, but now it doesn't work anymore:
var range = ctx.workbook.names.getItem("Countries").getRange();
I get an error stating that there is no support for getRange method, but it should be supported as documented here.
What am I'm doing wrong?
--- EDIT: this is the code I'm using ---
function paintRange() {
Excel.run(function (ctx) {
var range = ctx.workbook.names.getItem("Countries").getRange();
range.format.fill = "green";
return ctx.sync();
}).catch(function (error) {
app.showNotification("Error", error);
})
}
paintRange is attached to a button. There is a global scope defined name called Countries.
I don't have any more details of the error besides the one I mentioned, I also tried opening the quick watch window to get more clues.
UPDATE: The issue is fixed with an update to the CDN. You should be able to use namedItem.getRange() now. Thanks for reporting the issue, and allowing us to do a quick turn-around on it.
================
Felipe, looks like you're absolutely right. This is definitely a bug. Let me talk to the right folks to get this regression fixed as soon as we can. I'll see if we can put in some processes to avoid this in the future, as well.
From an immediate-workaround perspective, two options:
Use the BETA CDN (esp if it's for an in-development add-in, rather than a production one). That URL is: https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
Do a temporarily filling in of the inadvertently-removed getRange functionality. Inside of Office.initialize, include the following code:
if (!Excel.NamedItem.prototype.getRange) {
Excel.NamedItem.prototype.getRange=function () {
return new Excel.Range(this.context,
OfficeExtension.ObjectPathFactory.createMethodObjectPath(
this.context, this, "GetRange",
OfficeExtension.OperationType.Read, [], false, true, null
)
);
};
}
The workaround in #2 should not cause harm even after the functionality is restored, but I would none-the-less recommend making a mental note to remove this after we've fixed the issue. I'll update this thread once we have fixed the underlying bug, hopefully within a weeks' time (as a very rough estimate, pending any complications that might delay it).
Thanks for bringing it to our attention -- both the individual bug, and the underlying process that let the regression to this one API go unnoticed.

ExtJS Card Layout

I used the card layout to switch between two created panels:
var config = {
layout: 'card',
region : 'center',
activeItem: 0,
defaults : {
//height : 160
},
items : [this.ePanel, this.dPanel]
};
Ext.apply(this, config);
The switching takes place based on criteria:
if(params.exchange==='ABCD'){
l.setActiveItem(this.ePanel.id);
} else {
l.setActiveItem(this.dPanel.id);
}
As I switch between panels one of the panel contents get distorted. Are there any solutions to the problem? I am using ExtJS 2.2.
I've never used Ext2, but I've encountered similar difficulties with Ext3. Here are two ideas you can try...
Setting deferredRender to true.
Calling doLayout after setActiveItem, possibly after a small delay (because rendering is often deferred in Ext):
l.setActiveItem(this.ePanel.id);
setTimeout(function() {
l.doLayout();
}, 100); // more may be needed, one need to inspect Ext's code to know the precise value
doLayout is often the solution to layout issues, but it also generally requires a serious amount of debugging in order to have it applied. In effect, layouts are cached (at least in Ext3), so your call can be ignored if Ext consider internally that nothing has changed. Furthermore, as I've already said, rendering is often deferred, so if you don't delay it enough, your doLayout call may be executed before the child elements have been rendered...

Resources