mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-11-01 07:45:01 -04:00
added docs for github-style codeblocks
This commit is contained in:
parent
0a0cd14598
commit
52334ed604
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<!--[if IEMobile 7 ]><html class="no-js iem7" manifest="default.appcache?v=1"><![endif]-->
|
<!--[if IEMobile 7 ]><html class="no-js iem7" manifest="default.appcache?v=1"><![endif]-->
|
||||||
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
|
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
|
||||||
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" manifest="default.appcache?v=1" lang="en"><!--<![endif]-->
|
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>{{site.title}}{% if page.title %}: {{page.title}}{% endif %}</title>
|
<title>{{site.title}}{% if page.title %}: {{page.title}}{% endif %}</title>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<nav role=navigation>{% include navigation.html %}</nav>
|
<nav role=navigation>{% include navigation.html %}</nav>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<div id="content">
|
<div id="content">
|
||||||
{{ content | expand_urls: root_url | smart_quotes }}
|
{{ content | expand_urls: root_url | backtick_codeblock | smart_quotes }}
|
||||||
{% unless page.sidebar == false %}
|
{% unless page.sidebar == false %}
|
||||||
<aside role=sidebar>{% include sidebar.html %}</aside>
|
<aside role=sidebar>{% include sidebar.html %}</aside>
|
||||||
{% endunless %}
|
{% endunless %}
|
||||||
|
@ -7,7 +7,7 @@ sidebar: false
|
|||||||
|
|
||||||
{% include_code javascripts/test.js %}
|
{% include_code javascripts/test.js %}
|
||||||
|
|
||||||
{% codeblock Testing html files (test.html) %}
|
``` html
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
<html><head>
|
<html><head>
|
||||||
<title>A Tiny Page</title>
|
<title>A Tiny Page</title>
|
||||||
@ -28,7 +28,7 @@ sidebar: false
|
|||||||
<h2>def</h2>
|
<h2>def</h2>
|
||||||
<p>Testing page</p>
|
<p>Testing page</p>
|
||||||
</body></html>
|
</body></html>
|
||||||
{% endcodeblock %}
|
```
|
||||||
|
|
||||||
{% gist 996818 %}
|
{% gist 996818 %}
|
||||||
|
|
||||||
|
38
source/docs/plugins/github-style-codeblock/index.markdown
Normal file
38
source/docs/plugins/github-style-codeblock/index.markdown
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
layout: page
|
||||||
|
title: "Github Style Codeblock"
|
||||||
|
date: 2011-07-26 23:42
|
||||||
|
sidebar: false
|
||||||
|
footer: false
|
||||||
|
---
|
||||||
|
|
||||||
|
With the `backtick_codeblock` filter you can use Github's lovely back tick syntax highlighting blocks.
|
||||||
|
Simply start a line with three back ticks followed by a space and the language you're using. Tab in four spaces
|
||||||
|
for your code snippets, and then finish your code block with three more back ticks.
|
||||||
|
|
||||||
|
#### Syntax
|
||||||
|
|
||||||
|
``` language
|
||||||
|
code snippet
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
``` ruby
|
||||||
|
class Fixnum
|
||||||
|
def prime?
|
||||||
|
('1' * self) !~ /^1?$|^(11+?)\1+$/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
``` ruby
|
||||||
|
class Fixnum
|
||||||
|
def prime?
|
||||||
|
('1' * self) !~ /^1?$|^(11+?)\1+$/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
This is a nice, lightweight way to add a highlighted code snippet. For features like titles and links you'll want to look
|
||||||
|
at the `codeblock` or `include_code` liquid tags.
|
@ -48,8 +48,7 @@ function testFeatures() {
|
|||||||
|
|
||||||
function addCodeLineNumbers(){
|
function addCodeLineNumbers(){
|
||||||
if (navigator.appName == 'Microsoft Internet Explorer') { return }
|
if (navigator.appName == 'Microsoft Internet Explorer') { return }
|
||||||
$('div.highlight pre code').each(function(el){ addDivLines(el); });
|
$('div.gist-highlight').each(function(code){
|
||||||
$('div.highlight, div.gist-highlight').each(function(code){
|
|
||||||
var tableStart = '<table cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter">';
|
var tableStart = '<table cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter">';
|
||||||
var lineNumbers = '<pre class="line-numbers">';
|
var lineNumbers = '<pre class="line-numbers">';
|
||||||
var tableMiddle = '</pre></td><td class="code" width="100%">';
|
var tableMiddle = '</pre></td><td class="code" width="100%">';
|
||||||
@ -62,16 +61,6 @@ function addCodeLineNumbers(){
|
|||||||
$(code).html(table);
|
$(code).html(table);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function addDivLines(el){
|
|
||||||
var content = $(el).html();
|
|
||||||
var lines = content.replace(/\s*$/g, '').split(/\n/);
|
|
||||||
var count = lines.length;
|
|
||||||
$(lines).each(function(line, index){
|
|
||||||
if(line == '') line = ' ';
|
|
||||||
lines[index] = '<div class="line">' + line + '</div>';
|
|
||||||
});
|
|
||||||
$(el).html(lines.join(''));
|
|
||||||
}
|
|
||||||
|
|
||||||
function flashVideoFallback(){
|
function flashVideoFallback(){
|
||||||
var flashplayerlocation = "/assets/jwplayer/player.swf",
|
var flashplayerlocation = "/assets/jwplayer/player.swf",
|
||||||
|
Loading…
Reference in New Issue
Block a user