mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-12-25 00:48:53 -05:00
updated docs with description of new code start, end and range options
This commit is contained in:
parent
b673641d4f
commit
8bf5b8a25c
@ -5,34 +5,34 @@ footer: false
|
|||||||
sidebar: false
|
sidebar: false
|
||||||
---
|
---
|
||||||
|
|
||||||
{% include_code javascripts/test.js %}
|
{% include_code test.js range:5,10 %}
|
||||||
|
|
||||||
``` 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>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
<!--
|
<!--
|
||||||
p { font-size:15pt; color:#000 }
|
p { font-size:15pt; color:#000 }
|
||||||
-->
|
-->
|
||||||
</style></head><!-- real comment -->
|
</style></head><!-- real comment -->
|
||||||
<body bgcolor="#FFFFFF" text="#000000" link="#0000CC">
|
<body bgcolor="#FFFFFF" text="#000000" link="#0000CC">
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
function changeHeight(h) {
|
function changeHeight(h) {
|
||||||
var tds = document.getElementsByTagName("td");
|
var tds = document.getElementsByTagName("td");
|
||||||
for(var i = 0; i < tds.length; i++) {
|
for(var i = 0; i < tds.length; i++) {
|
||||||
tds[i].setAttribute("height", h + "px");
|
tds[i].setAttribute("height", h + "px");
|
||||||
}}
|
}}
|
||||||
</script>
|
</script>
|
||||||
<h1>abc</h1>
|
<h1>abc</h1>
|
||||||
<h2>def</h2>
|
<h2>def</h2>
|
||||||
<p>Testing page</p>
|
<p>Testing page</p>
|
||||||
</body></html>
|
</body></html>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% gist 996818 %}
|
{% gist 996818 %}
|
||||||
|
|
||||||
{% codeblock Testing PHP (syntax_test.php) %}
|
{% codeblock Testing PHP (syntax_test.php) lang:php %}
|
||||||
<?php
|
<?php
|
||||||
require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/country/common.php");
|
require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/country/common.php");
|
||||||
require_once($GLOBALS['g_campsiteDir']. "/classes/SimplePager.php");
|
require_once($GLOBALS['g_campsiteDir']. "/classes/SimplePager.php");
|
||||||
|
@ -12,7 +12,7 @@ Simply start a line with three back ticks followed by a space and the language y
|
|||||||
#### Syntax
|
#### Syntax
|
||||||
|
|
||||||
|
|
||||||
``` [language] [title] [url] [link text]
|
``` [language] [title] [url] [link text] [start:#]
|
||||||
code snippet
|
code snippet
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -44,3 +44,21 @@ class Fixnum
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Example with a custom starting line number
|
||||||
|
|
||||||
|
``` coffeescript Coffeescript Tricks start:51
|
||||||
|
# Given an alphabet:
|
||||||
|
alphabet = 'abcdefghijklmnopqrstuvwxyz'
|
||||||
|
|
||||||
|
# Iterate over part of the alphabet:
|
||||||
|
console.log letter for letter in alphabet[4..8]
|
||||||
|
```
|
||||||
|
|
||||||
|
``` coffeescript Coffeescript Tricks start:51
|
||||||
|
# Given an alphabet:
|
||||||
|
alphabet = 'abcdefghijklmnopqrstuvwxyz'
|
||||||
|
|
||||||
|
# Iterate over part of the alphabet:
|
||||||
|
console.log letter for letter in alphabet[4..8]
|
||||||
|
```
|
||||||
|
@ -10,7 +10,7 @@ With this plugin you can write blocks of code directly in your posts and optiona
|
|||||||
|
|
||||||
#### Syntax
|
#### Syntax
|
||||||
|
|
||||||
{{ "{% codeblock [title] [lang:language] [url] [link text]" }} %}
|
{{ "{% codeblock [title] [lang:language] [start:#] [url] [link text]" }} %}
|
||||||
code snippet
|
code snippet
|
||||||
{{ "{% endcodeblock" }} %}
|
{{ "{% endcodeblock" }} %}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ With this plugin you can write blocks of code directly in your posts and optiona
|
|||||||
Awesome code snippet
|
Awesome code snippet
|
||||||
{% endcodeblock %}
|
{% endcodeblock %}
|
||||||
|
|
||||||
#### Example 2
|
#### Syntax highlighting
|
||||||
|
|
||||||
You can also add syntax highlighting like this.
|
You can also add syntax highlighting like this.
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ You can also add syntax highlighting like this.
|
|||||||
[rectangle setX: 10 y: 10 width: 20 height: 20];
|
[rectangle setX: 10 y: 10 width: 20 height: 20];
|
||||||
{% endcodeblock %}
|
{% endcodeblock %}
|
||||||
|
|
||||||
#### Example 3
|
#### Syntax highlighting, alternate method
|
||||||
|
|
||||||
Including a file extension in the title enables highlighting
|
Including a file extension in the title enables highlighting
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ Including a file extension in the title enables highlighting
|
|||||||
puts "Awesome!" unless lame
|
puts "Awesome!" unless lame
|
||||||
{% endcodeblock %}
|
{% endcodeblock %}
|
||||||
|
|
||||||
#### Example 4 (Force Highlighting)
|
#### Force highlighting
|
||||||
|
|
||||||
Pygments supports many languages, but doesn't recognize some file extensions.
|
Pygments supports many languages, but doesn't recognize some file extensions.
|
||||||
Add `lang:your_language` to force highlighting if the filename doesn't work.
|
Add `lang:your_language` to force highlighting if the filename doesn't work.
|
||||||
@ -61,7 +61,7 @@ Add `lang:your_language` to force highlighting if the filename doesn't work.
|
|||||||
rvm ruby-1.8.6 # ZOMG, seriously? We still use this version?
|
rvm ruby-1.8.6 # ZOMG, seriously? We still use this version?
|
||||||
{% endcodeblock %}
|
{% endcodeblock %}
|
||||||
|
|
||||||
#### Example 5
|
#### Add a URL
|
||||||
|
|
||||||
Add an optional URL to enable downloading or linking to source.
|
Add an optional URL to enable downloading or linking to source.
|
||||||
|
|
||||||
@ -76,3 +76,22 @@ var arr2 = new Array(element0, element1, ..., elementN);
|
|||||||
{% endcodeblock %}
|
{% endcodeblock %}
|
||||||
|
|
||||||
The last argument `link_text` is optional. You may want to link to a source for download file, or documentation on some other site.
|
The last argument `link_text` is optional. You may want to link to a source for download file, or documentation on some other site.
|
||||||
|
|
||||||
|
|
||||||
|
#### Start on a custom line number
|
||||||
|
|
||||||
|
{% raw %}{% codeblock Coffeescript Tricks lang:coffeescript start:51 %}
|
||||||
|
# Given an alphabet:
|
||||||
|
alphabet = 'abcdefghijklmnopqrstuvwxyz'
|
||||||
|
|
||||||
|
# Iterate over part of the alphabet:
|
||||||
|
console.log letter for letter in alphabet[4..8]
|
||||||
|
{% endcodeblock %}{% endraw %}
|
||||||
|
|
||||||
|
{% codeblock lang:coffeescript Coffeescript Tricks start:51 %}
|
||||||
|
# Given an alphabet:
|
||||||
|
alphabet = 'abcdefghijklmnopqrstuvwxyz'
|
||||||
|
|
||||||
|
# Iterate over part of the alphabet:
|
||||||
|
console.log letter for letter in alphabet[4..8]
|
||||||
|
{% endcodeblock %}
|
||||||
|
@ -11,18 +11,18 @@ Import files on your filesystem into any blog post as embedded code snippets wit
|
|||||||
In the `_config.yml` you can set your `code_dir` but the default is `source/downloads/code`. Simply put a file anywhere under that directory and
|
In the `_config.yml` you can set your `code_dir` but the default is `source/downloads/code`. Simply put a file anywhere under that directory and
|
||||||
use the following tag to embed it in a post.
|
use the following tag to embed it in a post.
|
||||||
|
|
||||||
#### Syntax
|
### Syntax
|
||||||
|
|
||||||
{{ "{% include_code [title] [lang:language] path/to/file" }} %}
|
{{ "{% include_code [title] [lang:language] path/to/file [start:#] [end:#] [range:#,#]" }} %}
|
||||||
|
|
||||||
#### Example 1
|
### Basic
|
||||||
This includes a file from `source/downloads/code/test.js`.
|
This includes a file from `source/downloads/code/test.js`.
|
||||||
|
|
||||||
{{ "{% include_code test.js" }} %}
|
{{ "{% include_code test.js" }} %}
|
||||||
|
|
||||||
{% include_code test.js %}
|
{% include_code test.js %}
|
||||||
|
|
||||||
#### Example 2
|
### Custom title
|
||||||
By default the `<figcaption>` will be the filename, but you can add a title before the filepath if you like.
|
By default the `<figcaption>` will be the filename, but you can add a title before the filepath if you like.
|
||||||
|
|
||||||
{{ "{% include_code Add to_fraction for floats ruby/test.rb" }} %}
|
{{ "{% include_code Add to_fraction for floats ruby/test.rb" }} %}
|
||||||
@ -31,7 +31,27 @@ This includes a file from `source/downloads/code/ruby/test.rb`.
|
|||||||
|
|
||||||
{% include_code Add to_fraction for floats ruby/test.rb %}
|
{% include_code Add to_fraction for floats ruby/test.rb %}
|
||||||
|
|
||||||
#### Example 3 (Force Highlighting)
|
### Include part of a file
|
||||||
|
|
||||||
|
Start on line a specific line.
|
||||||
|
|
||||||
|
{% raw %}{% include_code test.js start:10 %}{% endraw %}
|
||||||
|
|
||||||
|
{% include_code test.js start:10 %}
|
||||||
|
|
||||||
|
End on line a specific line.
|
||||||
|
|
||||||
|
{% raw %}{% include_code test.js end:10 %}{% endraw %}
|
||||||
|
|
||||||
|
{% include_code test.js end:10 %}
|
||||||
|
|
||||||
|
Choose a custom range of lines to include.
|
||||||
|
|
||||||
|
{% raw %}{% include_code test.js range:10,15 %}{% endraw %}
|
||||||
|
|
||||||
|
{% include_code test.js range:10,15 %}
|
||||||
|
|
||||||
|
### Force highlighting
|
||||||
|
|
||||||
Pygments supports many languages, but doesn't recognize some file extensions.
|
Pygments supports many languages, but doesn't recognize some file extensions.
|
||||||
Add `lang:your_language` to force highlighting if the filename doesn't work.
|
Add `lang:your_language` to force highlighting if the filename doesn't work.
|
||||||
@ -39,3 +59,4 @@ Add `lang:your_language` to force highlighting if the filename doesn't work.
|
|||||||
{{ "{% include_code test.coffee lang:coffeescript" }} %}
|
{{ "{% include_code test.coffee lang:coffeescript" }} %}
|
||||||
|
|
||||||
{% include_code test.coffee lang:coffeescript %}
|
{% include_code test.coffee lang:coffeescript %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user