Open bubifengyun opened 6 years ago
Sorry, I don't know hs language, I don't know how to edit source directly.
Thank you for submitting a bug report. However, we cannot improve pandoc or help you unless you give us all of the following information:
pandoc -v
and try to reproduce the bug with the latest released version of pandoc, or even better: the development version or nightly build.)A small test case (just a few lines) is ideal. If your input is large, try to whittle it down to a minimum working example.
I had pointed the source code, pandoc version 2.2.1. in the source code, it forget to process when mathescape = true. so every special string would be converted. but string between $ and $, as math express should not be converted. I will make a small bug code. sorry.
pandoc
pandoc 2.2.1
Compiled with pandoc-types 1.17.4.2, texmath 0.11, skylighting 0.7.0.2
Default user data directory: /home/litianci/.pandoc
Copyright (C) 2006-2018 John MacFarlane
Web: http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
exact command
$ /usr/bin/pandoc +RTS -K512m -RTS test.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output result.tex --table-of-contents --toc-depth 2 --template template.tex --number-sections --highlight-style tango --pdf-engine xelatex --biblatex --listings --top-level-division=chapter --variable tables=yes --standalone
$ xelatex result.tex
you can see result.pdf
all the file all in folder i had submit.
.
├── result.pdf
├── result.tex
├── template.tex
└── test.md
ps:
all related words was speak in result.pdf
bug source in https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/Writers/LaTeX.hs?#L1048#L1053
I still don't quite understand, since you provide a lot of information, but the example is neither minimal (best would be a simple echo 'my input' | pandoc -t latex
) nor do you specify the expected output... but maybe jgm can figure out what you're getting at, since he wrote the LaTeX writer.
@jgm I think it is simple enough, even the source code, I had already circled.
before complete escape, take if it is mathescape, then can take convert in double $?
I had ref to https://github.com/dotlambda/pandoc/commit/730796ee314d42477fab216621b8e44539c94656#comments I think the person who add this feature can understand this bug. Thank you.
The LaTeX writer doesn't have any idea what is in the template and (with a minor exception) doesn't adjust its behavior based on that. It definitely doesn't parse the template. Moreover, there is currently no setting corresponding to mathescape=true.
I had contacted with the listings package author, here is their reply.
Re: how about add lstget in listings package
Hoffmann, Jobst于2018年9月21日 星期五 下午21:01发送给bubifengyun...查看2个附件
详细信息
关闭按钮
Hi,
Am Freitag, den 21.09.2018, 12:39 +0800 schrieb bubifengyun@sina.com:
> I find that some time, I need to get some state of listings, to produ
> ce some code, like in pandoc.
>
> https://github.com/jgm/pandoc/issues/4716
>
> if there are some code like \lstget{mathescape}, it would be easy to
> solve such problem. thank you.
> 来自新浪邮箱触屏版
the problem ist, that there is no generic "true" or "false", so you
cannot do something like
if \lstget{mathescape} a \else b \fi
but you have to write
\makeatletter
\lst@ifmathescape mathescape is true\else mathescape is false.\fi
\makeatother
I attach a small example as source and as formatted text.
Kind regards
J. Hoffmann
--
Prof. Dr. Jobst Hoffmann Tel: +49 (241) 6009-5 31 59
Fachhochschule Aachen Abt. Jülich Fax: +49 (241) 6009-5 31 89
Fachbereich 09 email: j.hoffmann@fh-aachen.de
and there two files.
I had contacted with the listings package author, here is their reply.
Re: how about add lstget in listings package
Hoffmann, Jobst于2018年9月21日 星期五 下午21:01发送给bubifengyun...查看2个附件
详细信息
关闭按钮
Hi,
Am Freitag, den 21.09.2018, 12:39 +0800 schrieb bubifengyun@sina.com:
> I find that some time, I need to get some state of listings, to produ
> ce some code, like in pandoc.
>
> https://github.com/jgm/pandoc/issues/4716
>
> if there are some code like \lstget{mathescape}, it would be easy to
> solve such problem. thank you.
> 来自新浪邮箱触屏版
the problem ist, that there is no generic "true" or "false", so you
cannot do something like
if \lstget{mathescape} a \else b \fi
but you have to write
\makeatletter
\lst@ifmathescape mathescape is true\else mathescape is false.\fi
\makeatother
I attach a small example as source and as formatted text.
Kind regards
J. Hoffmann
--
Prof. Dr. Jobst Hoffmann Tel: +49 (241) 6009-5 31 59
Fachhochschule Aachen Abt. Jülich Fax: +49 (241) 6009-5 31 89
Fachbereich 09 email: j.hoffmann@fh-aachen.de
and there two files.
I had contacted with the listings package author, here is their reply.
Re: how about add lstget in listings package
Hoffmann, Jobst于2018年9月21日 星期五 下午21:01发送给bubifengyun...查看2个附件
详细信息
关闭按钮
Hi,
Am Freitag, den 21.09.2018, 12:39 +0800 schrieb bubifengyun@sina.com:
> I find that some time, I need to get some state of listings, to produ
> ce some code, like in pandoc.
>
> https://github.com/jgm/pandoc/issues/4716
>
> if there are some code like \lstget{mathescape}, it would be easy to
> solve such problem. thank you.
> 来自新浪邮箱触屏版
the problem ist, that there is no generic "true" or "false", so you
cannot do something like
if \lstget{mathescape} a \else b \fi
but you have to write
\makeatletter
\lst@ifmathescape mathescape is true\else mathescape is false.\fi
\makeatother
I attach a small example as source and as formatted text.
Kind regards
J. Hoffmann
--
Prof. Dr. Jobst Hoffmann Tel: +49 (241) 6009-5 31 59
Fachhochschule Aachen Abt. Jülich Fax: +49 (241) 6009-5 31 89
Fachbereich 09 email: j.hoffmann@fh-aachen.de
and there two files.
I had contacted with the listings package author, here is their reply.
Re: how about add lstget in listings package
Hoffmann, Jobst于2018年9月21日 星期五 下午21:01发送给bubifengyun...查看2个附件
详细信息
关闭按钮
Hi,
Am Freitag, den 21.09.2018, 12:39 +0800 schrieb bubifengyun@sina.com:
> I find that some time, I need to get some state of listings, to produ
> ce some code, like in pandoc.
>
> https://github.com/jgm/pandoc/issues/4716
>
> if there are some code like \lstget{mathescape}, it would be easy to
> solve such problem. thank you.
> 来自新浪邮箱触屏版
the problem ist, that there is no generic "true" or "false", so you
cannot do something like
if \lstget{mathescape} a \else b \fi
but you have to write
\makeatletter
\lst@ifmathescape mathescape is true\else mathescape is false.\fi
\makeatother
I attach a small example as source and as formatted text.
Kind regards
J. Hoffmann
--
Prof. Dr. Jobst Hoffmann Tel: +49 (241) 6009-5 31 59
Fachhochschule Aachen Abt. Jülich Fax: +49 (241) 6009-5 31 89
Fachbereich 09 email: j.hoffmann@fh-aachen.de
and there two files.
%%% test_ifmathescape.tex ---
%
%% Author: j.hoffmann@fh-aachen.de
%% Version: $Id: test_ifmathescape.tex 0 2018/09/21 12:23:46 ax006ho Exp $
\RequirePackage{ifpdf}
\RequirePackage{ifluatex}
% \documentclass[12pt,a4paper,english,ngerman]{article}
\documentclass[12pt,a4paper,english,ngerman]{scrartcl}
\usepackage{etex}
\makeatletter
\@ifclassloaded{article}{%
\usepackage{typearea}
}{}
\makeatother
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\fontspec{Latin Modern Roman}
\else
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\fi
\usepackage{babel}
\usepackage{listings}
\begin{document}
\begin{itemize}
\item Use mathescape local: \lstinline|$x_1$|
vs. \lstinline[mathescape]|$x_1$|.
\item Use mathescape global in the current environment:
\lstset{mathescape=true}\lstinline|$x_1$|
vs. \lstinline[mathescape]|$x_1$|.
But: \lstinline[mathescape=false]|$x_1$|
vs. \lstinline[mathescape]|$x_1$|.
\end{itemize}
Outside the environment:
\makeatletter
\lst@ifmathescape mathescape is true\else mathescape is false.\fi
\makeatother
\lstset{mathescape=true}
And now after setting mathescape global again:
\makeatletter
\lst@ifmathescape mathescape is true\else \fi
\makeatother
As macro one can write in \LaTeX:
\makeatletter
\newcommand{\ifmathescape}[2]{%
\lst@ifmathescape #1\else #2\fi
}
\makeatother
and use it like \ifmathescape{mathescape is true.}{mathescape is false.}
\lstset{mathescape=false} or
\ifmathescape{mathescape is true.}{mathescape is false.}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-engine: default
%%% TeX-source-correlate-mode: t
%%% mode: flyspell
%%% ispell-local-dictionary: "deutsch8"
%%% End:
I am sorry for that. my phone works slowly, I press too many times comment button.
i think it can add one condition in the output of pandoc.
\ifdisableEscapeString output the original text, \lstinline!text! \else output the escape text,\passthrough\lstinline!text! \fi
then, user could define themselves \newif\ifEscapeString in other place. for example the \ifmathescape
Good. Perhaps instead of using \passthrough
we could use this \ifmathescape
macro and generate both possibilities. That might be a way forward, although it would mean including an extra definition in the default template (perhaps conditionally on listings being used) and having more verbose output for listings.
I find that this problem still. I want to solve it. Have you any suggestion? Thank you.
Watch source https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/Writers/LaTeX.hs?#L1048#L1053
when
code in two
$
should not be converted, such as$x_1$
should bebut in fact it is,
I think, when in mathescape=true, it should not convert the strings between two
$
s.https://github.com/jgm/pandoc/issues/4713
https://stackoverflow.com/questions/50898498/how-to-insert-in-lstinline/50919878#50919878