Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在“pygments”的命令行工具“pygmentize”中设置html字体大小`_Python_Html_Command Line_Pygments_Pygmentize - Fatal编程技术网

Python 在“pygments”的命令行工具“pygmentize”中设置html字体大小`

Python 在“pygments”的命令行工具“pygmentize”中设置html字体大小`,python,html,command-line,pygments,pygmentize,Python,Html,Command Line,Pygments,Pygmentize,我试图通过命令行工具pygmentize使用pygments并使用以下命令将python文件转换为html文件: pygmentize -f html -O full -O linenos=1 out_file.html in_file.py 不幸的是,默认的fontsize太小,我不知道如何增加它。使用-O fontsize=16不会产生错误,但也不会产生任何影响 此外,我尝试了一个丑陋的补丁,将html*{font size:1.05em!important;}插入到html文档的css部

我试图通过命令行工具
pygmentize
使用
pygments
并使用以下命令将python文件转换为html文件:

pygmentize -f html -O full -O linenos=1 out_file.html in_file.py
不幸的是,默认的fontsize太小,我不知道如何增加它。使用
-O fontsize=16
不会产生错误,但也不会产生任何影响

此外,我尝试了一个丑陋的补丁,将
html*{font size:1.05em!important;}
插入到html文档的css部分,但这会影响行号布局


我可以通过python终端调用“pygments”,但不知道如何将命令行实现到python代码中

from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import get_formatter_by_name

lexer = get_lexer_by_name('python')
formatter = get_formatter_by_name('html', linenos='inline', full=1)

with open("conver_me.py", 'r') as f_in:
    code = "".join(f_in.readlines())

with open("output.html", 'w') as f_out:
    highlight(code, lexer, formatter, f_out)
然后我加了一行

html *{font-size: 1.05em !important;}
进入html文档的css部分,并调整了表格填充

span.lineno { background-color: #f0f0f0; padding: 0px 5px 5px 5px; }