How to define a macro to interpret a unicode character with Mathjax - macros

I have the following markup in my page:
<p>$$\textbf{P} = \left⌊ \frac{\left( \left⌊ \frac{\textbf{A}}{100}\right⌋ \times 8 + 13 \right)}{25}\right⌋ - 5$$</p>
When MathJax tries to render it, I have the following error:
Missing or unrecognized delimiter for \left
I figured that the left floor (⌊) and right floor (⌋) unicode characters are what is not recognized in my expression because when I replace them with \lfloor and \rfloor, it's working properly.
My MathJax configuration is the following:
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$']]
}
};
I've tried to add macros to interpret the unicode characters with the following configuration with no luck:
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$']],
macros: {
"⌊": '{\\lfloor}',
"⌋": '{\\rfloor}'
}
}
};
Knowing that I can't change the markup because I not the one maintaining it and I have no way of changing it, is there a configuration that will allows me to make it work.

Related

How do I change the formatter line length with neovim lsp dart?

I'm running nvim using the built in LSP (via the superb AstroVim) to develop dart and flutter.
Loving everything, except how the lsp formatting (which formats on save) is wrapping my lines at 80 characters.
I can see how the dart command line formatter supports
--line-length=<value>
My question: how do I include that parameter to the lsp in the
lua vim.lsp.buf.formatting()
command in order to format at a longer line length.
PS. yes I'm fully aware of the religious war over line length.
PPS. I've tried this in my AstroVim user config, but it doesn't seem to work
["server-settings"] = {
dartls = {
settings = {
["line-length"] = 120
}
}
}
With AstroNvim, you could add options for your LSP configuration with lsp.server-settings.<lsp> option.
Replace <lsp> by the name of the LSP server used for dart/flutter and add option for line-length (options could be a table or a function). See examples in https://github.com/AstroNvim/AstroNvim/tree/main/lua/configs/lsp/server-settings and https://github.com/AstroNvim/AstroNvim/blob/main/lua/user_example/init.lua
According to dartls documentation, the correct configuration should be :
["server-settings"] = {
dartls = {
settings = {
dart = {
lineLength = 120
}
}
}
}

How to make my own encoding for a file in VSCode Editor

Is it possible to have an own encoding in VSCode editor, inheritd from an exising?
class myEcoding implements utf-8
{
// changes for some codes
}
I have some files, which contains german characters like "ä ö ü" that are encoded as unicode numbers in this file.
So for example, the file conatins the following line
Pr\u00FCfsignal
While I want to edit this file with the correct german characters, it should exist on the harddisk in the form above.
This is how I want to see it in the editor
Prüfsignal
I already have a function, that can transform a string in both directions:
function translate(content: string, direction: boolean): string {
if (direction) {
content = content
.replace(/\\u00E4/g, "ä")
.replace(/\\u00F6/g, "ö")
.replace(/\\u00FC/g, "ü")
.replace(/\\u00C4/g, "Ä")
.replace(/\\u00D6/g, "Ö")
.replace(/\\u00DC/g, "Ü")
.replace(/\\u00DF/g, "ß")
.replace(/\\u00B0/g, "°")
.replace(/\\u00B1/g, "±")
.replace(/\\u00B5/g, "µ");
}
else {
content = content
.replace(/ä/g, "\\u00E4")
.replace(/ö/g, "\\u00F6")
.replace(/ü/g, "\\u00FC")
.replace(/Ä/g, "\\u00C4")
.replace(/Ö/g, "\\u00D6")
.replace(/Ü/g, "\\u00DC")
.replace(/ß/g, "\\u00DF")
.replace(/°/g, "\\u00B0")
.replace(/±/g, "\\u00B1")
.replace(/µ/g, "\\u00B5");
}
return content;
}
Can this be solved with a custom encoding, and if yes, any hints?
Is there possibly a better solution?
There has been an open feature request for some years to Provide encoding-related APIs for editor extensions:
https://github.com/microsoft/vscode/issues/824
For now you could just wrap that function in a loop that encodes all files in the working directory.

SCSS Processor Unicode Output Incorrect

I have tested this issue using Scout-App and Visual Studio Code on Windows 10.
Having just downloaded Font-Awesome 4.7.0 SCSS files and set up a project/workspace, I have noticed a problem with unicode output. As an example:
in the '_variables.scss' partial, we have:
$fa-css-prefix: fa;
$fa-var-music: "\f001";
and in '_icons.scss' partial, we have:
.#{$fa-css-prefix}-music:before { content: $fa-var-music; }
with an expected result of:
.fa-music:before { content: "\f001"; }
but the output is:
.fa-music:before { content: ""; }
So all the unicode values stored in variables are processed to 
Thus I am unable to correctly compile the correct output for a modified font-awesome CSS file.
I have tried placing UTF8 encoding at the top of each SCSS file but the issue is still unresolved.
For a quick test, this will produce the result described:
test.scss
#charset "UTF-8";
$fa-css-prefix: fa;
$fa-var-music: "\f001";
.#{$fa-css-prefix}-music:before { content: $fa-var-music; }
It seems by writing:
"\f0a9" ,
Scout will compile the unicode character.
But, if you use interpolation:
#{'"' + \f0a9 + '"'}
then Scout will compile to "\f0a9".
You can also use variables like
$escaped: \f0aa;
...
#{'"' + $escaped + '"'}
or:
$escaped: f0aa;
...
#{'"\\' + $escaped + '"'}
Remarks:
The compiled unicode character may become a problem to the browser in the content attribute. Therefore you want to give him the written hex code.
If you mess around with the backslash and the interpolation, see also here:
Sass variable interpolation with backslash in output

How to select symbols onWorkspaceSymbol

I am developing an extension for visual studio code using language server protocol, and I am including the support for "Go to symbol in workspace". My problem is that I don't know how to select the matches...
Actually I use this function I wrote:
function IsInside(word1, word2)
{
var ret = "";
var i1 = 0;
var lenMatch =0, maxLenMatch = 0, minLenMatch = word1.length;
for(var i2=0;i2<word2.length;i2++)
{
if(word1[i1]==word2[i2])
{
lenMatch++;
if(lenMatch>maxLenMatch) maxLenMatch = lenMatch;
ret+=word1[i1];
i1++;
if(i1==word1.length)
{
if(lenMatch<minLenMatch) minLenMatch = lenMatch;
// Trying to filter like VSCode does.
return maxLenMatch>=word1.length/2 && minLenMatch>=2? ret : undefined;
}
} else
{
ret+="Z";
if(lenMatch>0 && lenMatch<minLenMatch)
minLenMatch = lenMatch;
lenMatch=0;
}
}
return undefined;
}
That return the sortText if the word1 is inside the word2, undefined otherwise. My problem are cases like this:
My algorithm see that 'aller' is inside CallServer, but the interface does not mark it like expected.
There is a library or something that I must use for this? the code of VSCode is big and complex and I don't know where start looking for this information...
VSCode's API docs for provideWorkspaceSymbols() provide the following guidance (which I don't think your example violates):
The query-parameter should be interpreted in a relaxed way as the editor will apply its own highlighting and scoring on the results. A good rule of thumb is to match case-insensitive and to simply check that the characters of query appear in their order in a candidate symbol. Don't use prefix, substring, or similar strict matching.
These docs were added in response to this discussion, where somebody had very much the same issue as you.
Having a brief look at VSCode sources, internally it seems to use filters.matchFuzzy2() for the highlighting (see here and here). I don't think it's exposed in the API, so you would probably have to copy it if you wanted the behavior to match exactly.

How to tell eclipse to not format parts of a codefile (pressing Strg + Shift + F)

I really love the autofromat feature. I makes your code more readable and in case of JavaScript tells you, when there are synatcs errors (missing brackets etc.).
However sometimes the formatting makes the code harder to read. e.g. when it puts a long array inizalisation into a single line. In that case I don't want him to format it, but rather leave it ofer multiple lines.
E.g.
define([
'jquery',
'aloha',
'aloha/plugin',
'ui/ui',
'ui/scopes',
'ui/button',
'ui/toggleButton',
'ui/port-helper-attribute-field',
'ui/text'
// 'css!youtube/css/youtube.css'
],
function(
$,
Aloha,
Plugin,
Ui,
Scopes,
Button,
ToggleButton,
AttributeField)
{
this array should stay like this and don't become this:
define(['jquery', 'aloha', 'aloha/plugin', 'ui/ui', 'ui/scopes', 'ui/button', 'ui/toggleButton', 'ui/port-helper-attribute-field', 'ui/text' ], function($, Aloha, Plugin, Ui, Scopes, Button, ToggleButton, AttributeField) {
Is there a special tag, to tell eclipse not to format the code?
OK, it took me some time to find the right setting so I will post a toturial here.
Go to Window Preferences and Search the Formatter you are using. In my case it was under 'Aptana Studia' -> 'Formatter'. (Depending on your Package this differs, e.g. the Java Formatter is under 'Java' -> 'Code Style' -> 'Formater').
Noww create a new Build profile since you can't override the old one.
Now enable the Formatter tags.
Now you can use the
- #formatter:on
- #formatter:off
tags to disable code formatting.
Example:
this code:
function hello() { return 'hello';
}
//#formatter:off
/*
|\ _,,,---,,_
/,`.-'`' -. ;-;;,_
|,4- ) )-,_..;\ ( `'-'
'---''(_/--' `-'\_) fL
*/
//#formatter:on
function
world() {
return 'world';
}
Will get formatted to like this
function hello() {
return 'hello';
}
//#formatter:off
/*
|\ _,,,---,,_
/,`.-'`' -. ;-;;,_
|,4- ) )-,_..;\ ( `'-'
'---''(_/--' `-'\_) fL
*/
//#formatter:on
function world() {
return 'world';
}
Note how the function definition is formatted correct, while the ascii art isn't
Credits:
Katja Christiansen for his comment
https://stackoverflow.com/a/3353765/639035 : for a similar answer
Try to make an empty comment after each line:
define([ //
'jquery', //
'aloha', //
'aloha/plugin', //
'ui/ui', //
'ui/scopes', //
'ui/button', //
'ui/toggleButton', //
...
Not nice, but I think it will work.