diff --git a/config.rb b/config.rb index 41553c5..b7df358 100644 --- a/config.rb +++ b/config.rb @@ -17,6 +17,9 @@ set :fonts_dir, 'fonts' # Activate the syntax highlighter activate :syntax +ready do + require './lib/multilang.rb' +end activate :sprockets diff --git a/lib/multilang.rb b/lib/multilang.rb new file mode 100644 index 0000000..624c6e4 --- /dev/null +++ b/lib/multilang.rb @@ -0,0 +1,12 @@ +module Multilang + def block_code(code, full_lang_name) + parts = full_lang_name.split('--') + rouge_lang_name = parts[0] || "" + super(code, rouge_lang_name).sub("highlight #{rouge_lang_name}") do |match| + match + " tab-" + full_lang_name + end + end +end + +require 'middleman-core/renderers/redcarpet' +Middleman::Renderers::MiddlemanRedcarpetHTML.send :include, Multilang diff --git a/source/index.html.md b/source/index.html.md index fc26b19..215c048 100644 --- a/source/index.html.md +++ b/source/index.html.md @@ -5,7 +5,8 @@ language_tabs: - shell - ruby - python - - javascript + - javascript--browser: Browser! + - javascript--node: Node! toc_footers: - Sign Up for a Developer Key @@ -47,12 +48,16 @@ curl "api_endpoint_here" -H "Authorization: meowmeowmeow" ``` -```javascript +```javascript--browser const kittn = require('kittn'); let api = kittn.authorize('meowmeowmeow'); ``` +```javascript--node +// node code here! +``` + > Make sure to replace `meowmeowmeow` with your API key. Kittn uses API keys to allow access to the API. You can register a new Kittn API key at our [developer portal](http://example.com/developers). @@ -88,13 +93,17 @@ curl "http://example.com/api/kittens" -H "Authorization: meowmeowmeow" ``` -```javascript +```javascript--browser const kittn = require('kittn'); let api = kittn.authorize('meowmeowmeow'); let kittens = api.kittens.get(); ``` +```javascript--node +// node code here! +``` + > The above command returns JSON structured like this: ```json @@ -154,13 +163,17 @@ curl "http://example.com/api/kittens/2" -H "Authorization: meowmeowmeow" ``` -```javascript +```javascript--browser const kittn = require('kittn'); let api = kittn.authorize('meowmeowmeow'); let max = api.kittens.get(2); ``` +```javascript--node +// node code here! +``` + > The above command returns JSON structured like this: ```json diff --git a/source/javascripts/app/_lang.js b/source/javascripts/app/_lang.js index 4c73da6..992180b 100644 --- a/source/javascripts/app/_lang.js +++ b/source/javascripts/app/_lang.js @@ -30,10 +30,10 @@ under the License. $(".lang-selector a").removeClass('active'); $(".lang-selector a[data-language-name='" + language + "']").addClass('active'); for (var i=0; i < languages.length; i++) { - $(".highlight." + languages[i]).hide(); + $(".highlight.tab-" + languages[i]).hide(); $(".lang-specific." + languages[i]).hide(); } - $(".highlight." + language).show(); + $(".highlight.tab-" + language).show(); $(".lang-specific." + language).show(); global.toc.calculateHeights();