Comments (8)
minted
is intended for typesetting code, not running code. escapeinside
allows small snippets of LaTeX code to be included within computer code that is otherwise typeset verbatim. It is not intended for \input{|...}
or \write18
.
I'd suggest saving the output of each of your \input{|...}
or \write18
in a file, and then \inputminted
those files individually.
from minted.
Unfortunately to write to a file doesn't work in my scenario. I'd like to keep the version of a REPL that I'm showing aligned with the version of the REPL installed. So most of the code will be the same but just few characters depends on where the document is compiled.
from minted.
What I'm suggesting is extending what you are doing in
\immediate\write18{ocamlc -version > /tmp/ocaml-version.txt}
\input /tmp/ocaml-version.txt
to the other programs. That is, use \input{|...}
or \write18
to run your external program, but then save/redirect the output into a file. Then \inputminted
that file (if you really need some kind of minted
formatting). This should get you current version info without running into incompatibilities with trying to run code within minted
. For \input{|...}
, you could probably use some shell scripting to wrap your version number with \mint
or \mintinline
like \mint{<lang>}{<version>}
and skip the temp file altogether.
from minted.
Hi, this doesn't work but maybe I didn't got you hint correctly:
\documentclass[9pt,xcolor=svgnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[scaled=.90]{beramono}
\usepackage{filecontents} % to overwrite generated files
\usepackage[cachedir=.\jobname-cache]{minted}
\setminted{fontfamily=tt,fontsize=\footnotesize,encoding=utf8,style=trac,escapeinside=``}
\begin{filecontents*}[overwrite]{/tmp/escapeinside-bug.txt}
`\immediate\write18{scalac -version > /tmp/ocaml-version.txt}
\input /tmp/ocaml-version.txt`
\end{filecontents*}
\begin{document}
\textcolor{red}{In Minted}
\inputminted{shell-session}{/tmp/escapeinside-bug.txt}%
\end{document}
It compiles but it prints:
%%%% This is file `.tex',%% generated with the docstrip utility.%%%% The original source files were:%%%% fil...
even if the included files contains 4.12.0
Furthermore if I try to pipe the result of the command to grep some specific portions (as in | grep -o '[[:digit:]]*[.][[:digit:]]*[.][[:digit:]]*'
) I get:
! TeX capacity exceeded, sorry [input stack size=10000].
\curr@fontshape ->\f@encoding
/\f@family /\f@series /\f@shape
l.2 ...*[.][[:digit:]]*'> /tmp/ocaml-version.txt}}
! ==> Fatal error occurred, no output PDF file produced!
I did something wrong?
from minted.
That is still trying to mix minted
with executable code.
Why not just use
\immediate\write18{scalac -version > /tmp/ocaml-version.txt}
\input /tmp/ocaml-version.txt
or something similar directly? If you want a different font or text color, you can always add a \textcolor
or texttt
command around the inputed version.
from minted.
Because my MWE shows just the critical part of the what I'm passing to minted. In the real case I'm passing to minted a complete program (a REPL session transcript to be honest) where only a small portion is changed by my command. In my view to put the whole transcript in the post was too much but if you think it can help I can post it. Sorry for the confusion.
from minted.
I don't have any more suggestions for this. minted
can't really emulate a REPL by mixing in \write18
, so you'll have to find another way to do what you want.
from minted.
This message is just for those coming here with the same problem. I have solved it:
\documentclass[9pt,xcolor=svgnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[scaled=.90]{beramono}
\usepackage{filecontents} % to overwrite generated files
\usepackage[cachedir=.\jobname-cache]{minted}
\setminted{fontfamily=tt,fontsize=\footnotesize,encoding=utf8,style=trac,escapeinside=``}
\begin{filecontents*}[overwrite]{/tmp/escapeinside-bug.txt}
`!/tmp/version.txt!`
\end{filecontents*}
\immediate\write18{scalac -version | grep -o '[[:digit:]]*[.][[:digit:]]*[.][[:digit:]]*'> /tmp/version.txt}
\begin{document}
\begingroup
\catcode`\!=\active
\def!#1!{\input #1}
\inputminted{shell-session}{/tmp/escapeinside-bug.txt}%
\endgroup
\end{document}
There are few limitations in this solution, e.g., the file name can't contain a -, you have to enable pdflatex to write out of the current dir,... but this is a good starting point.
from minted.
Related Issues (20)
- Breaking line within \newmintinline throws error
- `linerange` to select the exact lines to output HOT 2
- `newmintedfile` env* to specify additional options HOT 9
- [bug] `gobble` results in malformed formatting, `autogobble` works HOT 5
- [show-&-tell] ad-hoc adoptations from a different style to another one. HOT 1
- [feature] Support for PDDL programming language HOT 2
- [bug][compatibility] `Verbatim` environment generated by `minted` with `mathescape` broken with `babel`'s `magyar.ldf` (Hungarian 🇭🇺 language) HOT 1
- JSX highlighting is not working in overleaf HOT 1
- breaksymbolleft flush with line numbers HOT 2
- Write env content to file HOT 2
- Failed Compilation with MikTeX on windows HOT 19
- Overfull hbox with `mintinline` and `breakanywhere` in enumerate environment HOT 1
- Escapeinside content is misplaced in pygtex file for nodejsrepl type HOT 7
- Because of changes in one of the most popular Python installer on Mac, doc needs an improvement (`pip3 install Pygments` doesn't work anymore) HOT 1
- file extension `lol' cannot be used twice HOT 3
- autogobble option not working for me HOT 12
- Can not compile via latexmk in Windows HOT 5
- Missing Pygments output; \inputminted... HOT 2
- [Feature request] named code segments HOT 1
- Get full timestamp in XeTeX through \creationdate HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minted.