Linked Questions

Popular Questions

Python output highlighting in Quarto

Asked by At

Continuing on this question about code output highlighting in Quarto: Is it also possible to make this work with Python output?

A minimal working example:

title: "Output line highlighting"
format: revealjs
editor: visual
  - output-line-highlight.lua

## Regression Table 

In R:

#| class-output: highlight
#| output-line-numbers: "9,10,11,12"
LM <- lm(Sepal.Length ~ Sepal.Width, data = iris)

## Regression Table

In Python:

#| class-output: highlight
#| output-line-numbers: "12,13,14,15,16,17"
import pandas as pd
import statsmodels.api as sm

iris = sm.datasets.get_rdataset('iris').data
LM = sm.OLS(iris['Sepal.Length'], sm.add_constant(iris['Sepal.Width'])).fit()

Rendering this file shows the Lua filter works for the R output, but not for Python.

Related Questions