joshdholtz / DeckUI

Swift DSL for writing slide decks in Xcode
MIT License
601 stars 27 forks source link

Syntax highlighting support for Python code #17

Open yonomitt opened 1 year ago

yonomitt commented 1 year ago

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.

zachlucas commented 1 year ago

@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?

yonomitt commented 1 year ago

@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.

zachlucas commented 1 year ago

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

yonomitt commented 1 year ago

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 commented 1 year ago

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

yonomitt commented 1 year ago

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

yonomitt commented 1 year ago

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 commented 1 year ago

@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.