Skip to content
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

Fix PDF output format with julia code block. #1119

Closed
wants to merge 3 commits into from

Conversation

June-6th
Copy link

@June-6th June-6th commented Aug 29, 2019

Before this PR:

Screenshot_20190829_190510

After this PR:

Screenshot_20190829_190630

- Don't failed to generate PDF format with `julia` code block that
contain `%`.(Fixes JuliaDocs#1118)
- Don't eat the last line of `julia` code block.
@mortenpi mortenpi added Type: Bug Format: LaTeX Related to the LaTeX / PDF output labels Aug 29, 2019
@mortenpi
Copy link
Member

Hmm, on my system at least this seems to break rendering. This code block

```julia
1 % 2
1  2
1 | 2
```

becomes

\begin{minted}[escapeinside=⊻⊻]{julia}
1 % 2
1 ⊻\unicodeveebar⊻ 2
1 | 2
\end{minted}

as it should. But that renders as

Screenshot from 2019-08-30 11-22-55

After having played around with this for a while, it seems that minted's escaping is pretty broken in general? Using % should work in my opinion (like it does for lstlisting). maybe does not work because it is non-ASCII?

This gist should reproduce it: https://gist.github.com/mortenpi/574735e33d0f2e9093681a45e37bfd80


As a general comment, I think, if we can, it would be better to have the same escaping logic for the minted and lstlisting blocks. I.e. if we change escapeinside for one, we should probably change it for the other. That should obviate the need for two _print_code_escapes functions.

@June-6th
Copy link
Author

I can't reproduce your problem. My LuaTeX version is 1.07.0, what about you?

@mortenpi
Copy link
Member

Right, I was wondering if it might be something like that. Mine is 1.0.4. But that's from the Ubuntu 18.04 repositories, so this will break things if we build with our current Docker image.

@mortenpi
Copy link
Member

mortenpi commented Aug 30, 2019

What seems to work is to add this to documenter.sty:

\newfontfamily\unicodevbarfont{DejaVu Sans Mono}[Scale=MatchLowercase]
\newcommand\unicodevbar{{\unicodevbarfont ^^7c}}

and then do the code blocks as follows:

\begin{lstlisting}[escapeinside=||]
1 % 2
1 |\unicodeveebar| 2
1 |\unicodevbar| 2
\end{lstlisting}

\begin{minted}[escapeinside=||]{julia}
1 % 2
1 |\unicodeveebar| 2
1 |\unicodevbar| 2
\end{minted}

Edit: should be DejaVu Sans Mono for this symbol.

@June-6th
Copy link
Author

It is perfect! It would be better to let and | use the same color as other operators.

@mortenpi
Copy link
Member

It would be better to let and | use the same color as other operators.

Hmm. Do you mean that minted isn't highlighting them properly at the moment because we're doing the LaTeX magic?

@June-6th
Copy link
Author

Yes, they are darker.

@mortenpi
Copy link
Member

mortenpi commented Sep 2, 2019

Yes, they are darker.

I guess that would need getting the correct font color, thicknes etc. for the minted internals and applying it manually?

@June-6th
Copy link
Author

June-6th commented Sep 3, 2019

This may be the easiest way to do it, because lstlisting do not have the problem.

@findmyway
Copy link

findmyway commented Nov 5, 2019

Hey @mortenpi ,

Is there any blocking issue or concern to merge this PR?

The building pipeline for the pdf version of the Julia Documentation in Chinese has been broken for months due to the problem described above. It would be great to see this PR get merged.

Ref: JuliaCN/JuliaZH.jl#85

@mortenpi
Copy link
Member

mortenpi commented Nov 5, 2019

I think it will still break the Docker image currently?

@mortenpi
Copy link
Member

mortenpi commented Nov 7, 2019

Ok, it doesn't actually break the Docker image, but PDFs built with it do not render correctly at the moment: #1119 (comment). Swapping the implementation to #1119 (comment) should work around that I think?

@findmyway
Copy link

What seems to work is to add this to documenter.sty:

\newfontfamily\unicodevbarfont{DejaVu Sans Mono}[Scale=MatchLowercase]
\newcommnd\unicodevbar{{\unicodevbarfont ^^7c}}

and then do the code blocks as follows:

\begin{lstlisting}[escapeinside=||]
1 % 2
1 |\unicodeveebar| 2
1 |\unicodevbar| 2
\end{lstlisting}

\begin{minted}[escapeinside=||]{julia}
1 % 2
1 |\unicodeveebar| 2
1 |\unicodevbar| 2
\end{minted}

Edit: should be DejaVu Sans Mono for this symbol.

Hi @June-6th , can you confirm this works and make the change correspondingly?


Right, I was wondering if it might be something like that. Mine is 1.0.4. But that's from the Ubuntu 18.04 repositories, so this will break things if we build with our current Docker image.

I think when #979 gets resolved, this will not be a big problem. (At least it's not a big problem for us right now. Because we are using a customized docker image here)

@June-6th
Copy link
Author

June-6th commented Nov 7, 2019

@findmyway Yes, it work well.

mortenpi added a commit that referenced this pull request Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Format: LaTeX Related to the LaTeX / PDF output Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The julia code block contains character % can not generate PDF format output.
3 participants