Skip $ character from normal text - mathjax

This is very simple question but I unfortunately didn't get any clue to get rid from this error. I am writing a blog post about jquery ajax where I need to write a symbol $. I am using Mathjax for writing mathematical notation. As I write $ (for example $.getJSON), the Mathjax library decodes this as LaTeX commands. Anybody knows how to skip that $ character so that MathJax library behaves it as normal $?

By default, MathJax does not use the single dollar as a delimiter for in-line math (for exactly the reason you indicate), and so your configuration must be explicitly enabling it. See the text2jax dpcumentation for details of how this is done.
You have several options:
Remove the configuration that turns on dollar signs for in-line math. (This won't be good if you have already used them for in-line math in other posts)
Enable the processEscapes option so that you can use \$ to get a dollar without it being used as a math delimiter
If your blog allows you to enter raw HTML, you could use <span>$</span> to prevent MathJax from using the dollar as a delimiter (math can't contain HTML tags, so this dollar will not match up with another one, so won't be used as a delimiter).
Put your code examples inside <pre> or <code> containers, as MathJax (at least by default) doesn't process math within these. Your configuration may have changed that, however, so check the skipTags setting in your configuration.
Any of these should allow you to do what you need.

Related

Why does make use a back quote and single quote around the target name?

I found in all make warning / error messages, it uses a single back quote but then a single quote to highlight the user input.
For example, the error message of the undefined makefile name is like
Makefile `xxx' was not found.
At first I thought it was a typo, but it seems to me it is intended for all messages.
https://www.gnu.org/software/make/manual/html_node/Error-Messages.html
It is distinct from the modern development to use both single / double quote around the highlight text, e.g. Makefile 'xxx' was not found.
Does anyone know the reason behind it?
I would guess it is a holdover from when fonts were displayed differently. For computer text that was intended to be read by humans, it used to be that (on many systems) using backquote/quote would produce output that resembles the way that English was normally typeset.
Consider for example: https://data.historicaltexts.jisc.ac.uk/view?pubId=bl-001973110&pageId=bl-001973110-660536-22 :
For other information, see for example:
discussion of "backtick-apostrophe" notation
Markus Kuhn's explanation of how the X Window System displayed fonts

Mathjax strangely render back-tick in code blocks

I have a TCL code gist embedded in my own website. This page uses MathJax 2.7.5 configed with "TeX-MML-AM_CHTML". However, Mathjax strangely rendered the code between back-ticks in the comments of the code. For example, one line in the source code is (can be found here in gist):
# `testPrintFlag` : integer
The letters "int" were rendered by MathJax to a integration symbol (see here).
The gist code block appears like this., but the correct one should be like this. I'm wondering how I can fix this.
Thanks!
The configuration file TeX-MML-AM_CHTML includes the AsciiMath input processor, and AsciiMath uses back-ticks as its math delimiters. So all your back-tacks will cause AsciiMath to process their contents as math. If you aren't using AsciiMath input, you probably want to use a different configuration format, like just TeX-AMS_CHTML which only does TeX input (not MathML and AsciiMath, as in your original). That will be faster as well as it is a smaller file.
If you are using AsciiMath input, then you could configure it to use a different delimiter. See the documentation for details.
You could also configure MathJax to skip containers with certain class names (e.g., class="gist"). See the ignoreClass option for the asciimath2jax preprocessor at the link above. There is a similar one for the tex2jax preprocessor.

How to write square brackets in markdown

I need to write in my gitlab project wiki page a code block that contains square brackets. Unfortunately the square brackets are turn into a link.
I assume gitlab is using markdown language or the gfm flavor.
This is my code:
```javascript
"{bla, """", [[foo],[]]}"
```
The foo],[ part is turn into a link. So basicaly I need a way to write a square brackets tah are not treated as a link. Surprisingly google doesn't provide any answer for such a trivial issue.
The current answer is that you can't do this. It is a know bug in GitLab, specifically in Wiki pages. GitLab markdown correctly handles square brackets in comments, and code blocks entered in issues, but NOT in wiki pages.
Please add your vote (thumbs up) on the issue to try and get it resolved:
https://gitlab.com/gitlab-org/gitlab-ce/issues/18725
Your (not very appealing) options boil down to these:
Use a single line code entry `"{bla, """", [[foo],[]]}"`
Use another syntax in your code block (e.g. {{), and include a note outside the code block saying to replace {{ with [[, etc - Note that you can use double brackets inside single quote blocks in GitLab Markdown.
Use a screenshot of your code.
None of these are very nice solutions, but all you have at the moment.

Alt+Space on a OSX causing defective code in HTML (Coda)

Is it a known problem that unregular spaces used in code can cause a CSS or an HTML to be defective ?
When typing a bit fast, I sometimes type ALT+SPACE instead of SPACE (before the curly braces most of the time).
Is it possible to make all alternative spaces symbols (that are invisible to the eyes, but not to the code) be the standard space symbol ?
You can create your own custom key map, simply by creating a file under ~/Library/KeyBindings, named DefaultKeyBinding.dict. For your purpose the file needs to contain the following lines:
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
/* My custom Keybinds */
{
"~ " = ("insertText:", " "); /* Option + Space = Space */
}
Unfortunately this solution doesn't work for all programs since the bindings are depending on the Cocoa framework and even some of the applications using it do ignore some combinations (more information about the deficits can be found here, under "Caveat").
Additional Links:
http://xahlee.info/kbd/osx_keybinding.html
https://web.archive.org/web/20090404114150/http://www.cocoabits.com/KeyBindingsEditor/Manual/index.html (GUI tool)
About your HTML problem
It actually shouldn't cause any problems to use non-ASCII characters in HTML or CSS but using the wrong character set can lead to unwanted display effects. Without knowing the specific context I can't give any concrete diagnosis about that.

How do I replace quotes in XSLT with their HTML entities?

This is related to my previous question -" Manipulate the output of <xsl:apply-templates>".
I want to ask about the specific problem I am looking to address.
How do I replace quotes in XSLT with their HTML entities. I want to eventually pass it to Javascript variable with special characters escaped.
You may want to have a look at the Google code project xml2json-xslt, especially the xml2js.xslt template. Perhaps your answer lies in there.

Resources