-
-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
other-language: #36
other-language: #36
Conversation
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
It's surprising to me that polyglossia does these transformations inside verbatim contexts. Is it because pandoc's highlighted code blocks use a custom environment that polyglossia doesn't recognize? If you just have a code block without syntax marked, does it do the same thing? Just wondering whether this should be handled with a modification to pandoc rather than a filter. |
Interestingly, this only happens with |
From polyglossia manual:
So perhaps we could conditionally include these around all code blocks, or make them part of the special environment definition? |
I don't know if it's worth adding all the additional complexity to the default template that this would require to redefine the verbatim environments. But for this filter, it would probably be cleaner to add Of course, because these commands are from polyglossia, you'd probably want to do something like
|
that would have been so neat and easy, but I didn't manage to get it working (using xelatex) \documentclass[]{article}
\usepackage{polyglossia}
\setmainlanguage[]{french}
\setotherlanguage[]{english}
\begin{document}
lang: fr
\disablehyphenation
lang: fr-nohyphen
\enablehyphenation
\begin{otherlanguage}{english}
lang: en
\end{otherlanguage}
\end{document} |
I guess that makes sense: it's not really a matter of hyphenation, after all. |
But I do think the name of this filter is confusing. Wouldn't a better name somehow mention code or verbatim blocks, so people will know what this pertains to? |
PS. Instead of adding a Para before and after containing raw latex, you might try putting each code block inside a Div with attribute lang="en". This works just as well and it's cleaner and simpler. |
I need a little help with the lua side though... sorry. When putting the
Although, in the following Lua
Thanks! |
I think what you want is
pandoc.Attr("", {}, {lang = "en"})
Yoan Blanc <notifications@github.com> writes:
… I need a little help with the lua side though... sorry.
When putting the `<div lang="en">` in the markdown, it produces this.
Div ("",[],[("lang","en")]) [ ... ]
Although, in the following Lua `pandoc.Div(el, pandoc.Attr("lang", {"en"}))` produces.
Div ("lang",["en"],[]) [ ... ]
Thanks!
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#36 (comment)
|
This does appear to be a bug specific to Polyglossia and XeTeX. It works fine with Babel: \documentclass{article}
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{#1}}
\usepackage[shorthands=off,main=french]{babel}
\begin{document}
\begin{Shaded}
\begin{Highlighting}[]
\OtherTok{---}
\FunctionTok{title:}\AttributeTok{ Mon titre}
\FunctionTok{lang:}\AttributeTok{ fr}
\OtherTok{---}
\end{Highlighting}
\end{Shaded}
\end{document} |
There's a workaround for Polyglossia posted in reutenauer/polyglossia#27. |
Good find. We could simply add this to the default
pandoc template where polyglossia is loaded:
\makeatletter
\appto\verbatim@font{\nofrench@punctuation}
\makeatother
It's a bit verbose to have all of this in the
template, since it's irrelevant unless lang is fr.
I suppose we could have the writer check the
lang in metadata, and set a special variable if
lang = fr; these lines could be included if the
variable is set.
If this seems a good idea, perhaps an issue should
be opened for pandoc. (Though if we decide to make
polyglossia optional, not default, for xelatex,
then it may be a nonissue.)
Andrew Dunning <notifications@github.com> writes:
… There's a workaround for Polyglossia posted in <reutenauer/polyglossia#27>.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#36 (comment)
|
@greut - given the workaround, is this filter even necessary any more? |
@jgm I cannot get the work around to work. Although, it became clear that polyglossia+xelatex are the bad guys here, I'll keep this filter and consider it a hack rather than something worth spreading. Thanks everyone for you help! |
@greut Are you receiving an error, or is it simply not displaying properly? This works for me under either XeTeX or LuaTeX: \documentclass{article}
% Polyglossia with workaround
\usepackage{polyglossia}
\setdefaultlanguage{french}
\setotherlanguage{english}
\makeatletter
\appto\verbatim@font{\nofrench@punctuation}
\makeatother
%
% or use Babel
% \usepackage[english, main=french]{babel}
\begin{document}
\verb|00:11:43:D4:86:A0|
\selectlanguage{english}
\verb|00:11:43:D4:86:A0|
\selectlanguage{french}
\begin{verbatim}
00:11:43:D4:86:A0
\end{verbatim}
\end{document} Note that you might have to delete your .aux file between runs when switching between Babel and Polyglossia. If you're still having trouble, perhaps try checking that you're running the latest version of TeX Live by running |
pandoc produces |
A filter I've been using to avoid french hyphenation in code blocks once transformed into a TeX document.
source
without
with
Extracted from this project: https://github.com/HE-Arc/rapport-technique