This answer shows how to use minted in tex4ht.
But options do not seem to be passed through as with pdf.
For example, trying to change the font size as shown in this answer does not work with tex4ht using same code as with pdf. The fontsize remains the same in HTML.
Here is MWE and the commands used. Question is: How to change font size of minted with tex4ht?
\documentclass[12pt]{article}
\usepackage{minted}
\begin{document}
example 1
\begin{minted}{c}
int main() {
printf("hello, world");
return 0;
}
\end{minted}
example 2
\begin{minted}[fontsize=\footnotesize]{Text}
Methods for first order ODEs: --- Trying classification methods --- trying a quadrature <- quadrature successful
\end{minted}
example 3
\begin{minted}[fontsize=\tiny]{Text}
Methods for first order ODEs: --- Trying classification methods --- trying a quadrature <- quadrature successful
\end{minted}
\end{document}
Compiled using lualatex -shell-escape foo.tex on TL 2021 gives expected output
But with tex4ht compiled using
make4ht --shell-escape -ulm default -c my_cfg.cfg foo.tex "mathjax,htm"
gives the HTML
Which shows the fontsize did not pass through.
The following is the file my_cfg.cfg used in the above command
\Preamble{xhtml,p-width}
%see https://tex.stackexchange.com/questions/554995/creating-better-html-code-with-minted-and-tex4ht
\ConfigureEnv{minted}{\NoFonts}{\EndNoFonts}{}{}
\begin{document}
\EndPreamble
Any workaround to make all minted options work with tex4ht also? if not all options, at least making fontsize work will be useful.



These command turn off and on handling of font styling.so you are explicitly turning off font handling. Assuming your final document is referencing some css you can easily globally style all the generated code by applying css to the appropriate classes – David Carlisle Mar 13 '22 at 10:39you can easily globally style all the generated code by applying css to the appropriate classesI really do not want to do this. I just wanted to use minted as is. I did not realize this limitation when I read the answer. For now, I will just live with it as is, without the fontsize being smaller in HTML. Not a big issue. It will be great if tex4ht could support minted with all its options. At least the font size option. – Nasser Mar 13 '22 at 10:46pre{font-size: smaller}and all<pre>get smaller, you don't need to touch mined at all. (or check exactly what class is generated by make4ht to give a more specific rule) – David Carlisle Mar 13 '22 at 10:50