Add multiple-tabs-per-language test

This commit is contained in:
Robert Lord
2016-11-30 14:36:04 -08:00
parent 4352bd9f0c
commit 1fd867c2ff
4 changed files with 34 additions and 6 deletions

View File

@@ -17,6 +17,9 @@ set :fonts_dir, 'fonts'
# Activate the syntax highlighter
activate :syntax
ready do
require './lib/multilang.rb'
end
activate :sprockets

12
lib/multilang.rb Normal file
View File

@@ -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

View File

@@ -5,7 +5,8 @@ language_tabs:
- shell
- ruby
- python
- javascript
- javascript--browser: Browser!
- javascript--node: Node!
toc_footers:
- <a href='#'>Sign Up for a Developer Key</a>
@@ -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

View File

@@ -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();