I'm using Hydrogen to execute code in Julia files and also wanted to try out Weave.jl. It has it's own Atom language file that suggests using language mappings to get Hydrogen to execute the code: https://github.com/mpastell/language-weave
The issue is, if I set up custom mapping to enable Julia code execution in "weave.jl markdown" files, then I lose that ability in regular "julia" files. It would be great if language mappings would allow to either specify a list of types for the mapping or just the mapping was reversed.
I think the language mappings suggested in https://github.com/mpastell/language-weave are meant for a very old version of Hydrogen.
If I understand correctly, the grammar name is "weave.jl markdown" and the kernel name is "julia". If so, the correct language mapppings are these:
{ "weave.jl markdown": "julia", "pweave markdown": "python" }
If this doesn't work, please, could you post the error message?
@n-riesco I think the language mappings from weave are correct.
The problem is that if a language mapping is present, Hydrogen doesn't recognize the original language. For example it only works with weave.jl markdow files and not with julia files anymore.
For the specific case of weave, instead of using a language mapping the best way would be if they could integrate with our new multi language feature (which should be very easy).
I think the language mappings from weave are correct.
Oh! I keep confusing that the languageMappings setting maps kernel language names into atom grammar names.
@lgeiger I think a solution to this issue would be to replace these lines with
if (mappedLanguage) {
return mappedLanguage === language || kernelLanguage.toLowerCase() === language;
}
In this way, Hydrogen would still consider the julia kernel for julia files despite the languageMappings setting.
@maximsch2 Alternatively, you could create a custom kernel spec by adding something like this to the KernelSpec setting:
{
"kernelspecs": {
"weave.jl markdown": {
"spec": {
"argv": [
"julia",
"-i",
"-F",
"/home/user/.julia/v0.5/IJulia/src/kernel.jl",
"{connection_file}"
],
"display_name": "Weave.jl markdown",
"language": "weave.jl markdown"
}
}
}
}
I think a solution to this issue would be to replace these lines with
That's probably part of the solution. I think we also need to change our grammarToLanguage function, since the running kernels are stored by the atom grammar name and not by their language from the kernelspec.
Alternatively, you could create a custom kernel spec by adding something like this to the KernelSpec setting
That's a valid workaround, though I wouldn't recommend editing the kernelspecs setting as a long term solution since this will likely fail if the julia kernel is updated to a new version.
That's probably part of the solution. I think we also need to change our grammarToLanguage function, since the running kernels are stored by the atom grammar name and not by their language from the kernelspec.
Yes, it makes a lot of sense.
@maximsch2 Would you be interested in implementing multi language support for weave as a first class citizen in Hydrogen?
As an example here's what we did to support the knitr language:
https://github.com/christophergandrud/language-knitr/pull/4
@lgeiger I have a version that seems to be working, let me make a PR.
Thanks for a pointer!