Mathjax how to do - mathjax

I have set my MathJax script to have its font larger. It works all ok. But now it doesn't display when i put the code between $.
It does only when the code is between $$. I want both $ and $$ to render MathJax.
Here is my code:
<!-- MathJax CDN -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config{
CommonHTML: {
scale: 120
}
});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
</script>

Add the text2jax.js extension in your config to set inline delimiter.
See here for details :
http://docs.mathjax.org/en/latest/configuration.html#using-in-line-configuration-options
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
tex2jax: {inlineMath: [["$","$"]]},
CommonHTML: {
scale: 120
}
});
</script>
<script type="text/javascript" async src=
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=
TeX-MML-AM_CHTML"></script>
$x^y$
(note that you have a typo in config - parenthesis is missing)
note also this warning from mathjax doc :
By default, the tex2jax preprocessor defines the LaTeX math delimiters, which are \(...\) for in-line math, and \[...\] for displayed equations. It also defines the TeX delimiters $$...$$ for displayed equations, but it does not define $...$ as in-line math delimiters. That is because dollar signs appear too often in non-mathematical settings, which could cause some text to be treated as mathematics unexpectedly. For example, with single-dollar delimiters, “… the cost is $2.50 for the first one, and $2.00 for each additional one …” would cause the phrase “2.50 for the first one, and” to be treated as mathematics since it falls between dollar signs. For this reason, if you want to use single-dollars for in-line math mode, you must enable that explicitly in your configuration

Related

fw/1 - Can not display foreign characters in views

I have got the following main Controller default action in fw/1 (framework one 4.2), where i define some rc scope variables to be displayed in views/main/default.cfm.
main.cfc
function default( struct rc ) {
rc.name="ΡΨΩΓΔ";
rc.dupl_name="üößä";
}
views/main/default.cfm
<cfoutput>
<p> #rc.name# </p>
<p> #rc.dupl_name# </p>
</cfoutput>
and finally in layouts/default.cfm
<cfoutput><!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
A Simple FW/1 Layout Template
</title>
</head>
<body>
#body#
</body>
</html>
</cfoutput>
Unfortunately i receive the following output
ΡΨΩΓΔ
üößä
Any idea that could help me?
Regards
Because I already gave you a solution within my comments, I’m posting it as an answer here, so that others with similar issues may find the root of their charset issues.
The issue described above is very often the result of conflicting charset encodings. For example, if you are reading an ISO-8859-1 encoded file and outputting it with UTF8 without having them converted (de-/encoded) properly.
For the purpose of sending characters through a webapp as you are doing, the most common charset encoding as of today is UTF-8.
All you need to do is to harmonize characterset encodings or at least ensure that the encodings are set in such a manner that the processing engine is able to encode and decode the charsets correctly. What you can do in your case is:
Verify the encoding of the template .cfm file and make sure it’s saved as UTF-8
Define UTF-8 as your web charset in Lucee Administrator » Settings » Charset » Web charset
Define UTF-8 as your ressource charset in Lucee Administrator » Settings » Charset » Resource charset.
Make sure there are no other places where charset encodings are incorrectly set, such as a http server response header of “content-type: text/html;charset...” or a html meta-tag with a charset directive.
If you have other type of ressources, such as a database, then you may need to check those also (connection and database/table settings).
Note: That charset doesn’t always have to be UTF-8 (UTF-8 might use multiple bytes for certain characters). There may be use cases you would achieve the same result with single byte encodings, such as ISO-8559-1, that would also need less computing ressources and less payload.
I hope this may help others with similar issues.

How to include space and new line in regular expression?

I have an HTML file which contains the below code snippet.
<div class="col-sm-2 col-sm-offset-1">
<div class="countBox success" id="success">
<h2>467</h2>
Passed Tests
<span class="glyphicon glyphicon-eye-open"></span>
</div>
</div>
I have a regular expression (.*)</h2>\r\nPassed to get the value 467. It is worked till yesterday. But, it is not working now. I have tried by replacing single slash by double slash to new line and row. Used "\s+" to cover whitespace. All failed in error. Could anyone please guide me on how to get the value as 467 by using regular expression for the above code snippet?
It is better to catch <h2>(\d+)</h2> to ensure only a h2 header with a number inside. By the way, \r\n is only one convention (in windows) to represent end of line, but in unix it is only \n so to be more platform independent, you can do \r?\n (marking the \r as optional) and you have to get on the whitespace in front of Passed., so a good (but not probably the best) regexp would be:
<h2>(\d+)<\/h2>\r?\n\s*Passed
See demo.

Does heist support substituting (strings / JSON) into an arbitrary location within a template?

Regarding heist, I've got a template such as:
<script>
var json = ???;
</script>
<h1>Example</h1>
Is there a way to substitute the ??? string with another string?
I think the following function might be the solution https://hackage.haskell.org/package/heist-1.0.1.0/docs/Heist-Splices-Json.html#v:bindJson but I have difficulty understanding that function and or what markup to use in the template.
No. You cannot substitute anything inside a <script> tag because the text inside a script tag is not treated as HTML. It's treated as plain text. If this was not done, you wouldn't be able to write JS code like if ( x < 42 ) because the less than would get treated as the beginning of a tag.

Escape `#` in yesod templates

I'm trying to use #font-face selector in cassius template with no luck.
Cassius uses # for interpolation, is there any way to escape it?
I've tried ## and \#, none of them works.
Following template
#font-face
font-family: 'Monsieur La Doulaise'
src: url('http://fonts.googleapis.com/css?family=Monsieur+La+Doulaise')
Results in
src: url('http://fonts.googleapis.com/css?family=Monsieur+La+Doulaise');}
This is pretty ugly, but may work:
...
defaultLayout $ do
let atSym = "#"
[cassius|#{atSym}font-face ... |]
...
in other words, bind a string to the value of "#" and interpolate that in the cassius file. I can't check the syntax now but it may work.
This is not a solution to your question but I thought I will let you know that ran into something related this morning. I had the following CSS section:
.myclass {
background: #d880efe;
background-image:url(#{StaticR img_myimage_png});
/* more stuff */
}
When Yesod compiled the CSS file, it did not generate the URL for the background-image. In fact, it skipped over the entire line and created a slightly different background property. I ended up skipping the `#{StaticR ...} and hard-coded the URL. When I get a chance I will create a reproducible code.
So I am guessing this is an issue with # interpolation and not so much escaping. Do you mind trying a #{Handler} for your src? If that line is not getting generated then it may be a different issue that we need to file a bug report for.

How to escape special characters from a markdown string?

I have a markdown file (utf8) that I am turning into a html file. My current setup is pretty straight forward (pseudo code):
var file = read(site.postLocation + '/in.md', 'utf8');
var escaped = marked( file );
write('out.html', escaped);
This works great, however I've now run into the issue where there are special characters in the markdown file (such as é) that will get messed up when viewed in a browser (é).
I've found a couple of npm modules that can convert html entities, however they all convert just about all convertable characters. Including those required by the markdown syntax (for example '#' becomes '&num;' and '.' becomes '&period;' and the markdown parser will fail.
I've tried the libs entities and node-iconv.
I imagine this being a pretty standerd problem. How can I only replace all strange letter characters without all the markdown required symbols?
As pointed out by hilarudeens I forgot to include meta charset html tag.
<meta charset="UTF-8" />
If you come across similar issues, I would suggest you check that first.

Resources