You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there's a simple bash lexer in #551 and ongoing discussion about said lexer in the open issue #137, which uses a regex to find a few prompt options based on content included directly in the code block.
the issues i see:
this only supports a hard-coded list of prompts specifically for bash sessions, and not other shells/REPLs
this requires the prompts to be inline mixed with the console commands
this has copy/paste issues: it allows the resulting .gp styled span to be copied and pasted, and the command following the prompt contains a preceding space
What feature do you propose?
it'd be nice to have a way to specify a custom prompt that displays on specified lines and isn't selectable.
use cases
for example, this could display user@host:~/path/to/dir for ssh connections, >>> for the python repl, or databaseName=# for psql.
i'm coming at this from a hugo perspective, so what i'd love to be able to do is add an info string to a code fence like this:
and have the resulting code block display the prompt, unselectable, on the specified lines.
implementation?
i'm not terribly familiar with chroma itself, so i'm not sure if the following implementation would make sense, but is there a plausible approach for this with a new formatter constructor option (akin to HighlightLines())?
the same way highlighting lines adds the .hl class to each line specified, prompts could add a data attribute each line specified, and styles could use something like:
Unfortunately that would be quite difficult in Chroma. Lexing and rendering are separate steps, so by the time the renderer receives the tokens it doesn't really know what language it is, so there is no way to do something custom.
@alecthomas, hmm, the thought i had about custom prompts wouldn't be based off of parsing in the lexer or anything language specific. it would be a constructor option for the formatter that applies a style to each line (not token), similar to the way HighlightLines() seems to work.
Is there an existing issue for this?
What problem does this feature solve?
there's a simple bash lexer in #551 and ongoing discussion about said lexer in the open issue #137, which uses a regex to find a few prompt options based on content included directly in the code block.
the issues i see:
this only supports a hard-coded list of prompts specifically for bash sessions, and not other shells/REPLs
this requires the prompts to be inline mixed with the console commands
this has copy/paste issues: it allows the resulting
.gp
styledspan
to be copied and pasted, and the command following the prompt contains a preceding spaceWhat feature do you propose?
it'd be nice to have a way to specify a custom prompt that displays on specified lines and isn't selectable.
use cases
for example, this could display
user@host:~/path/to/dir
for ssh connections,>>>
for the python repl, ordatabaseName=#
forpsql
.i'm coming at this from a hugo perspective, so what i'd love to be able to do is add an info string to a code fence like this:
and have the resulting code block display the prompt, unselectable, on the specified lines.
implementation?
i'm not terribly familiar with chroma itself, so i'm not sure if the following implementation would make sense, but is there a plausible approach for this with a new formatter constructor option (akin to
HighlightLines()
)?the same way highlighting lines adds the
.hl
class to each line specified, prompts could add a data attribute each line specified, and styles could use something like:to style them. using a before pseudoelement would also make the prompt unselectable.
The text was updated successfully, but these errors were encountered: