carpentries / sandpaper

User Interface for The Carpentries Workbench
https://carpentries.github.io/sandpaper
Other
42 stars 27 forks source link

Feature request: Some way of highlighting lines of code within a script #615

Open fherreazcue opened 2 weeks ago

fherreazcue commented 2 weeks ago

It is fairly common in lessons in which a script is being developed that the full script is reproduced on every step. Sometimes, this makes it a bit hard to follow which are the line that changed in the last step. It would be useful to be able to highlight one or multiple lines of code within a code block. For example,

import pandas as pd

file_path="/my/file.csv"

def stats():
  with open(file_path) as f:
    df = pd.read_csv(f)
    df = df.iloc[:, 1:]                 <---- make this line bold, or a different background
    stats = df.describe()
    return stats.to_json()

One option is markdown is to use the diff language, but it does not work with sandpaper. Also, you loose the syntax highlighting.

Potentially useful as a substitute, if this is not possible, would be to allow turning on code line-numbers, so that they can be pointed out.

froggleston commented 2 weeks ago

Hey @fherreazcue ! As sandpaper is based on basic markdown syntax, I'm not sure this is possible, at least at the moment. It would be good to see if anyone else has any experience!