Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom grammars #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

TheNightmanCodeth
Copy link

This PR adds an argument to .installPlugin that takes a set of custom Grammars to use while highlighting code in markdown.

Let's say we've created a custom Grammar called YamlGrammar. We can use it with this PR like so:

.installPlugin(.splash(withClassPrefix: "", withGrammars: [(YamlGrammar(), "yaml"), (SwiftGrammar(), "swift")])

This will apply the grammar to any code blocks in markdown prepended with "yaml", like so:

```yaml
...

I wrote a unit test but I did struggle getting Xcode to recognize the string to compare with. I had to escape some quotes and add newlines to get it working even though I noticed this wasn't done in the first unit test. Hope that's okay!

I also took the liberty of adding brief instructions to the README. Hopefully it reads well 馃槀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant