atom / language-gfm

GitHub Flavored Markdown in Atom
MIT License
101 stars 114 forks source link

Better Fence Highlighting #32

Open dwendt opened 10 years ago

dwendt commented 10 years ago

Shouldn't fences be able to understand any arbitrary grammar highlighting available to atom? At the bare minimum, they should understand those understood by GFM.

https://github.com/github/linguist/blob/master/lib/linguist/languages.yml

As far as implementation goes, I'm sure there must be some option other than building a ton of regexes for gfm.cson using this YML file. That's probably really inefficient? Is there some way to use a callback with a capture group in the regex?

edit: Solving this issue would solve #33, and any future requests for syntax support. If someone more familiar with atom could describe a better method than parsing that YML, I'd write the PR.

kevinsawicki commented 10 years ago

Yeah, you are right, maintaining all these patterns isn't really sustainable, but there isn't any callback support yet for extending grammars as rules are matched.

Just an idea, this could be baked this into the parser perhaps, like have a codeFences array in each grammar that they register for, and then the parser refers to that when it starts to parse a triple backtick block that has a language name.

burodepeper commented 8 years ago

I've "solved" this in language-markdown in the following way: https://github.com/burodepeper/language-markdown/blob/dev/grammars/fixtures/fenced-code.cson The corresponding grammar file is automatically compiled by the package in dev-mode. Maintaining the list is still a manual thing, but on an acceptable level. Anything missing from this list?

On a side note, all languages that only need the pattern to be specified can automatically be added when compiling I realize now. Is there an easy way to get a list of default languages from within Atom?