Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
544 views
in Technique[技术] by (71.8m points)

markdown - How to produce \ at end of line with kramdown?

I have a Jekyll site hosted on github pages. I have successfully loaded MathJax in my _layouts/default.html and now want to author my document. I have tried to set all cofiguration to default to not complicate matters.

The problem is that in some MathJax environments you want to write \ to denote a newline (such as the align environment, but backslash is a special character in markdown. See example below.

Desired output

<p>egin{align}
x&amp;=3+2\
 &amp;=5
end{align}</p>

Since one must escape backslash in markdown, I have writte the document below

Current input

\begin{align}
x&=3+2\\
 &=5
\end{align}

running kramdown myfile.md produces

Current output

<p>egin{align}
x&amp;=3+2<br />
 &amp;=5
end{align}</p>

This is expected given the kramdown syntax for paragraphs.

How do I get kramdown to output \ at the end of the row, instead of giving me a <br />?

question from:https://stackoverflow.com/questions/65933424/how-to-produce-at-end-of-line-with-kramdown

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

kramdown has some support for MathJax, which i just found in the documentation. The easy way to do get it right is with input

$$
egin{aligned}
x&=3+2\
 &=5
end{aligned}
$$

producing

[egin{aligned}
x&amp;=3+2\
 &amp;=5
end{aligned}]

and that is for all intents and purposes the same as above. There are subtle semantic differences (one equation on two lines vs two equations), but it will look the same. So it is a valid solution to me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...