QmdToPyConverter

converter.QmdToPyConverter(linter)

Convert lines from a .qmd file to .py file.

  1. Preserve line alignment.
  2. Amend Quarto code chunk options (“#|” to “# |”) to prevent lint errors, with handling for leading indentation and blank lines at cell start.

Attributes

Name Type Description
py_lines list Stores the lines to be written to the output Python file.
in_python boolean True if currently processing lines inside a Python code chunk.
in_chunk_options boolean True if currently at the start of a code chunk, parsing Quarto chunk options or leading blank lines.
linter str Name of the linter that will be used.

Notes

Adapted from code generated by Perplexity.

Methods

Name Description
convert Run converter on the provided lines.
process_line Process individual lines with state tracking.
reset Reset the state (except linter).

convert

converter.QmdToPyConverter.convert(qmd_lines)

Run converter on the provided lines.

Parameters

Name Type Description Default
qmd_lines list List containing each line from the Quarto file. required

Returns

Name Type Description
py_lines list List of each line for the output Python file.

process_line

converter.QmdToPyConverter.process_line(original_line)

Process individual lines with state tracking.

Parameters

Name Type Description Default
original_line str Line to process. required

reset

converter.QmdToPyConverter.reset()

Reset the state (except linter).