DeckUI icon indicating copy to clipboard operation
DeckUI copied to clipboard

Syntax highlighting support for Python code

Open yonomitt opened this issue 3 years ago • 8 comments

After Swift support is added, I would be interested in having support for Python syntax highlighting.

I'm also working on a PythonGrammar for my website, which would plug right into the syntax highlight support added in PR #16... so we could use that, once I finish it.

yonomitt avatar Sep 12 '22 17:09 yonomitt

@yonomitt I'm also hitting a use case for Python syntax highlighting! Any chance you've happened to push a WIP branch? We could collaborate if so! I was thinking maybe this Swift Pygments wrapper could be helpful?

zachlucas avatar Oct 27 '22 20:10 zachlucas

@zachlucas I think I have something for this, but just got distracted by other work. Let me see if I can get a PR set up this weekend.

yonomitt avatar Oct 28 '22 07:10 yonomitt

Are you planning to use the Swift Pygments wrapper? I figure that would be great to use so we don't have to roll our own formatting. We'd have to get a bridge from that to DeckUI though

zachlucas avatar Nov 07 '22 15:11 zachlucas

Sorry I haven't gotten a chance to finish this. I'm not planning on using Swift Pygments. I tried using it a while back when I was working on getting Python syntax highlighting support for my Publish site, and didn't like the results.

Instead, I've been working on a Publish-style Grammar for Python. Since the syntax highlighting I added here for Swift is based on that, too, it should be easy to plug this Python Grammar in.

yonomitt avatar Nov 10 '22 19:11 yonomitt

I've finally pushed my changes to my SplashPython repo. Now all that's left is to integrate it into DeckUI 😄

yonomitt avatar Nov 21 '22 14:11 yonomitt

@zachlucas Check this out: https://github.com/joshdholtz/DeckUI/pull/28

yonomitt avatar Nov 21 '22 15:11 yonomitt

If you notice any issues with syntax highlighting in Python, we may need to add syntax rules to SplashPython. I'm sure I'm missing some.

yonomitt avatar Nov 21 '22 15:11 yonomitt

@zachlucas Just a heads up. I noticed that SplashPython did not properly tokenize multiline strings. I've fixed this and tagged a new version of SplashPython (1.1.0). If you're using the unmerged DeckUI branch from my PR, you might want to update that package.

yonomitt avatar Nov 24 '22 10:11 yonomitt