trishume / syntect

Rust library for syntax highlighting using Sublime Text syntax definitions.
https://docs.rs/syntect
MIT License
1.93k stars 139 forks source link

Missing Support for Python Console Output and Doctests #549

Open mattharrison opened 3 months ago

mattharrison commented 3 months ago

Description: Syntect currently lacks support for highlighting Python console output (characterized by >>> and ... prompts) and doctests. This limitation hinders its ability to accurately represent Python code in various contexts, including code examples, tutorials, and interactive sessions.

Expected Behavior: Syntect should correctly highlight the Python code while ignoring the >>>, ..., and output (stacktrace or stdout).

Steps to Reproduce:

  1. Create a code snippet containing Python console output or a doctest:

    >>> print("Hello, world!")
    Hello, world!

Note this language is commonly called pycon (for python console), and tools like Pygments or Github markdown support this language (as evidenced by highlighting the above code).

(My desire is because I'm exploring Typst and want like to port my books from LaTeX to Typst. See this bug https://github.com/typst/typst/issues/4661 )

keith-hall commented 3 months ago

I don't know of any sublime-syntax files which can currently highlight doctests correctly. Theoretically if we were to create one, it would be a lot easier to extend the base Python sublime-syntax to add support for it, so probably we'd need to wait for https://github.com/trishume/syntect/pull/536 to be merged first

Related: https://github.com/trishume/syntect/issues/168

mattharrison commented 3 months ago

Where do these syntax definitions live? I poked around a little and couldn't find them.

On Fri, Aug 9, 2024, 11:46 PM Keith Hall @.***> wrote:

I don't know of any sublime-syntax files which can currently highlight doctests correctly. Theoretically if we were to create one, it would be a lot easier to extend the base Python sublime-syntax to add support for it, so probably we'd need to wait for #536 https://github.com/trishume/syntect/pull/536 to be merged first

— Reply to this email directly, view it on GitHub https://github.com/trishume/syntect/issues/549#issuecomment-2279477958, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA5E3INQBFYMWSHAMKMU7LZQWSLZAVCNFSM6AAAAABMJIRLXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZZGQ3TOOJVHA . You are receiving this because you authored the thread.Message ID: @.***>

keith-hall commented 3 months ago

Mainly in the Packages folder/submodule of the testdata folder: https://github.com/trishume/syntect/tree/master/testdata