Closed joekain closed 8 years ago
Hi, thanks for creating include-codeblock. I've found it incredibly useful for a book I'm writing on the Elixir language. The only problem that I've had is that Elixir files have extensions .ex or .exs so they need some massaging in order to get the right language name for the syntax highlighting. I've made this quick change to handle this.
I've written a test, which passes. But, I haven't been able to test this change within my gitbook build. Is there a way to install my local package and test this completely?
Thanks, Joseph Kain
@joekain Thanks for pull request.
Is there a way to install my local package and test this completely?
https://github.com/GitbookIO/gitbook/issues/393
cd your_book
npm install /your/local/path/to/gitbook-plugin-include-codeblock
# or npm link
gitbook serve
It seem to work.
I think that we should use following module insteadof translation
map.
https://github.com/Elixirdoc/ext-map-lang/ https://github.com/blakeembrey/language-map
@azu, I've been able to test with my book. Thanks for helping me with that!
I'll try out those modules and will update the pull request.
@azu, I ended up using the language-map package but not the ext-map-lang package. Actually, I recreated most of the ext-map-lang package in the function lookupLanguageByExtension
but fixed a bug in the process. Let me know if you would prefer that I make a pull-request to ext-map-lang and then use that package.
Oh, also I should note that this changes the behavior of the plugin slightly. For javascript it now generates "javascript" instead of "js" in the code block. Both highlight correctly.
I recreated most of the ext-map-lang package in the function lookupLanguageByExtension but fixed a bug in the process.
OK. It looks good! I will merge this after wait for response to above comment :)
@azu, yes you are right about path.extname(). I'm still learning Javascript, thanks for your help with that. I've updated the pull-request.
Great, thanks!
Some language's names don't exactly match their filename extensions. One example is Elixir. This change adds a translation function that maps extensions to language names using an associative array. Currently, the array only translate Elixir extensions. Languages not included in the array use the extension as the language name as they did before this change.