Skip to content

Custom action on code fences but keep the normal behavior #1291

Answered by facelessuser
oprypin asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah, you can use custom fences and call into the default formatter. I basically do that in this project: https://github.com/facelessuser/coloraide/blob/master/tools/colors.py#L210.

Basically, the above code is allowing me to parse raw Python code and get it's results, then I format it as a pycon input/output, send it through the highlighter and also about color previews:

```color
Color("rebeccapurple").interpolate(
    "lch(85% 100 85)",
    space='lch'
)
```

Generally, it is assumed that if someone is overriding this, they don't want to do pygments parsing, or they are going to implement their own; otherwise, they would normally just use the default highlighter. But yeah, I ran into a …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@oprypin
Comment options

@facelessuser
Comment options

@oprypin
Comment options

@facelessuser
Comment options

Answer selected by facelessuser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants