Forrest logo
back to the pygmentize tool

pygmentize:tldr:02e75

pygmentize: Save output to a file in HTML format.
$ pygmentize -f html -o ${output_file-html} ${input_file-py}
try on your machine

The command "pygmentize -f html -o ${output_file-html} ${input_file-py}" uses the pygmentize program to convert a source code file from Python syntax to highlighted HTML syntax.

Let's break down the command:

  • "pygmentize" is the command to execute the pygmentize program.
  • "-f html" specifies the output format as HTML. This tells pygmentize to generate a highlighted HTML representation of the source code.
  • "-o ${output_file-html}" specifies the output file name as "${output_file-html}". This is a placeholder that can be replaced with the desired output file name. If not replaced, it will default to "html" with no file extension.
  • "${input_file-py}" specifies the input file name as "${input_file-py}". Similar to the output file name, it is a placeholder that should be replaced with the actual input file name. It assumes the input file is a Python file with a ".py" extension.

By running this command, the pygmentize program will take the specified input file, apply syntax highlighting to it using the Python lexer, and generate an HTML file containing the highlighted code, which is saved using the specified output file name or the default name if not provided.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the pygmentize tool