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
filters:
  - output-line-highlight.lua
---

## Regression Table 

In R:

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

## Regression Table

In Python:

```{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()
LM.summary2()
```

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

Related Questions