Mathjax strangely render back-tick in code blocks - mathjax

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.

Related

Markdown tabs in GitLab Markdown

I am writing documentation that has steps for Windows, Mac, Linux.
I want to make it look like this HTML5 tabbed HTML5 example
there is support for HTML in gitlab markdown
There is a reference to a sanitation class that validates the inline HTML in gitlab marrkdown
My question is:
Recommendations to achieve the tabbed documentation. Is there a workaround for displaying CSS correctly in markdown?
how to make this work?
Simply insert the relevant HTML/CSS/JS into your Markdown document.
As Markdown's Syntax Rules state (emphasis in original):
Markdown's syntax is intended for one purpose: to be used as a format
for writing for the web.
Markdown is not a replacement for HTML, or even close to it. Its
syntax is very small, corresponding only to a very small subset of
HTML tags. The idea is not to create a syntax that makes it easier
to insert HTML tags. In my opinion, HTML tags are already easy to
insert. The idea for Markdown is to make it easy to read, write, and
edit prose. HTML is a publishing format; Markdown is a writing
format. Thus, Markdown's formatting syntax only addresses issues that
can be conveyed in plain text.
For any markup that is not covered by Markdown's syntax, you simply
use HTML itself. There's no need to preface it or delimit it to
indicate that you're switching from Markdown to HTML; you just use
the tags.
The only restrictions are that block-level HTML elements -- e.g. <div>,
<table>, <pre>, <p>, etc. -- must be separated from surrounding
content by blank lines, and the start and end tags of the block should
not be indented with tabs or spaces. Markdown is smart enough not
to add extra (unwanted) <p> tags around HTML block-level tags.
However, there is one down side to this:
Note that Markdown formatting syntax is not processed within block-level
HTML tags. E.g., you can't use Markdown-style *emphasis* inside an
HTML block.
Finally, there is the concern that you appear to looking to have this document hosted on a third party site (perhaps in a readme on Gitlab). Most third party sites who process and host Markdown documents (including Gitlab) run the output through an HTML sanitizer for security reasons (to avoid XSS attaches, etc). Therefore, you are likely to find that various required hooks in your HTML will be stripped out and it won't work. Of course, this won't be a problem on your own site where you have total control.
The solution was tried in readme.rd from the text processor used by Microsoft VsCode and commited to gitlab. In the attached picture there is the rendering. It was not as expected. Perhaps the functionality to have tabs will be available soon.
An alternative is "collapsible sections" in GitLab Flavored Markdown. Link to documentation: link

Customize padding of \boxed environment in MathJax

What is the most appropriate way of customizing the amount of padding that Mathjax produces for the \boxed{} envorinment? I know there is a \bbox[]{} alternative with such an option, but it is buggy for the CommonHTML output that I use (it excludes the punctuation symbols).
If it helps to answer the question, I am specifically using page2html from the mathjax-node package to pre-render all the math.

Generate HTML from MathJax code in a batch script

I know how to use MathJax to convert TeX commands in a web page to mathematical formulae. The MathJax scripts would search the page for TeX commands and convert them inline to HTML statements.
Is there a way to do this as a form of pre-processing? In other words, I have some text or HTML files on my harddisk that contain raw TeX commands. I'd like to use MathJax to convert them to HTML, so that they can be viewed without having the MathJax scripts.
The reason I need this is that these pages are very long and contain many, many TeX statements. MathJax is fast, but it's not fast enough for such huge pages, so I need to preprocess them.
Thanks for any hints.
MathJax-node provides APIs for using MathJax in nodejs, thus enabling this kind of preprocess. There are examples in the repository for handling HTML fragments.
The SVG output can be used this way but the HTML-CSS output cannot because it is very client dependent.
However, the new CommomHTML output -- which has been completed in MathJax v2.6, currently in beta -- will be usable this way. It will be integrated into mathjax-node once v2.6 is out of beta.

Defining a vim syntax file that selectively applies other syntax files in different regions

Is there a way to define a syntax file in Vim that is essentially a "meta" layer on top of other syntax files? By this I mean that the file defines syntax highlighting regions, but all it does for each region is specify a different syntax file to be applied to that region. This is useful for PHP embedded in HTML, or any other sort of file mixing languages. I am aware that there are scripts that handle PHP and HTML together, but I don't think they do it in the manner I described. I'm interested in the general solution to this problem.
That's what :syntax include is for. With it, you can mark certain regions in the buffer, and apply the subordinate syntax in there. As long as the regions are clearly delimited and do not mix, this works pretty well. This is used for example in the HTML syntax to include JavaScript inside <script> tags, and Vimscript uses that for Perl, Python, and other integration languages. You'll find these scripts at $VIMRUNTIME/syntax/.
Alternative
My SyntaxRange plugin provides a different approach, where you can highlight certain regions with another syntax, without defining a separate new syntax. This is used for more adhoc markup, e.g. to highlight a Python snippet inside an HTML blog post, or to automatically highlight inline patches inside an email body.
Composite filetypes
Finally, there are add-on syntaxes that go "on top" of a main syntax. An example is cpp.doxygen. You cannot do that with arbitrary syntaxes, though; the script has to be specially written to support that.

Skip $ character from normal text

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.

Resources