Closed bcoe closed 9 years ago
@kevinsawicki pull request updated, thanks for the quick code-review I'm giving a demo of highlights to everyone at npm today this will add a lot of razzmatazz.
@kevinsawicki hold off on merging this, I found something that needs to be patched related to where modules are included from.
The problem is that require.resolve()
always resolves to highlights' node_modules
folder, perhaps instead use `path.resolve(__dirname, '../', 'node_modules', moduleName). I'll ask @isaacs if there's a better approach.
Based on a in-the-air conversation with @isaacs regarding trusting __dirname
, i.e., you should not, I think this is a good fix:
highlighter.requireGrammarsSync({
modulePath: require.resolve('atom-language-dart')
})
I'd say this is ready to go.
@kevinsawicki okay I think this is actually close to ready to go now, to summarize:
requireGrammarsSync()
, which based on the advice of my coworkers now recommends using:highlighter.requireGrammarsSync({
modulePath: require.resolve('atom-language-dart/package.json')
})
The nice thing about this is that the existing atom language modules have package.json files, so existing grammars can be published to npm with no modifications.
@registry.loadGrammarSync
based on your suggestion.season
to version to v5.1.2
based on your request, I've also moved season
into dependencies
from devDependencies
, as it is required by requireGrammarsSync
.Thanks for your patience.
Thanks for this, published in 1.1.0
I've added the method
requireGrammarsSync()
, for loading a grammar into the registry from an npm module. This is super useful when using highlights as a stand-alone library, and allows grammars to be published to npm for just this purpose.FYI, we recently switched to highlights as our syntax highlighter for npm. awesome work!