octopress-codefence 1.4.5 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +64 -13
- data/lib/octopress-codefence.rb +20 -0
- data/lib/octopress-codefence/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0ba8ecc86de09e4e10e8d4a9c6a64afb0fe57d2
|
4
|
+
data.tar.gz: e43a0b12467ba1110b74556b52f0ce00cb7a524a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bc3ed627cdac2ae68259777c04adb3cdca7694098c4682a148e38158381e4f195b68c2a96a374e0f401ba676884021053070cfa7557bfcb8ac0ca3c1ff7264b
|
7
|
+
data.tar.gz: cb5d5ab9ebd36b1d78aa71c8a8d9c2c74d4ec1fac5b41e17b65770f11bfe9a1842ce66e3af48cd3535a366bce40027518cdd4fa6ac54a5f7fa106014a7fc5eb8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -7,33 +7,56 @@ Write beautiful fenced code snippets within any template.
|
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
10
|
-
|
10
|
+
### Using Bundler
|
11
11
|
|
12
|
-
|
12
|
+
Add this line to your application's Gemfile (optionally in the `:jekyll_plugins` group:
|
13
13
|
|
14
|
-
|
14
|
+
```ruby
|
15
|
+
group :jekyll_plugins do
|
16
|
+
gem 'octopress-codefence'
|
17
|
+
end
|
18
|
+
```
|
19
|
+
|
20
|
+
Then install the gem with Bundler
|
15
21
|
|
16
22
|
$ bundle
|
17
23
|
|
18
|
-
|
24
|
+
### Manual Installation
|
19
25
|
|
20
26
|
$ gem install octopress-codefence
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
First, add the gem to your Jekyll configuration.
|
28
|
+
Then add the gem to your Jekyll configuration.
|
25
29
|
|
26
30
|
```yaml
|
27
31
|
gems:
|
28
32
|
- octopress-codefence
|
29
33
|
```
|
30
34
|
|
31
|
-
|
35
|
+
## Usage
|
32
36
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
The Octopress codefence has some
|
38
|
+
|
39
|
+
### Syntax
|
40
|
+
|
41
|
+
```lang [options]
|
42
|
+
[code]
|
43
|
+
```
|
44
|
+
|
45
|
+
### Options
|
46
|
+
|
47
|
+
Note that order does not matter.
|
48
|
+
|
49
|
+
| Options | Example | Description |
|
50
|
+
|:-------------|:-----------------------|:----------------------------------------------------------------------|
|
51
|
+
|`lang` | `ruby` | Used by the syntax highlighter. Passing 'plain' disables highlighting.|
|
52
|
+
|`title` | `title:"Figure 1.A"` | Add a figcaption title to your code block. |
|
53
|
+
|`link_text` | `link_text:"Download"` | Text for the link, default: `"link"`. |
|
54
|
+
|`linenos` | `lineos:false` | Disable line numbering. |
|
55
|
+
|`start` | `start:5` | Start the line numbering at the given value. |
|
56
|
+
|`mark` | `mark:1-4,8` | Highlight lines of code. This example marks lines 1,2,3,4 and 8 |
|
57
|
+
|`class` | `class:"css example"` | Add CSS class names to the code `<figure>` element |
|
58
|
+
|
59
|
+
### Examples
|
37
60
|
|
38
61
|
Finally, give it a try. Here's an code snippet sample.
|
39
62
|
|
@@ -63,7 +86,35 @@ Finally, give it a try. Here's an code snippet sample.
|
|
63
86
|
end
|
64
87
|
```
|
65
88
|
|
66
|
-
|
89
|
+
Which renders like this:
|
90
|
+
|
91
|
+
<!-- mark:2-4 title:"Testing codefence" url:"https://github.com/octopress/codefence" link_text:"plugin link" -->
|
92
|
+
```ruby
|
93
|
+
class Float
|
94
|
+
def number_decimal_places
|
95
|
+
self.to_s.length-2
|
96
|
+
end
|
97
|
+
|
98
|
+
def to_fraction
|
99
|
+
higher = 10**self.number_decimal_places
|
100
|
+
lower = self*higher
|
101
|
+
|
102
|
+
gcden = greatest_common_divisor(higher, lower)
|
103
|
+
|
104
|
+
return (lower/gcden).round, (higher/gcden).round
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def greatest_common_divisor(a, b)
|
110
|
+
while a%b != 0
|
111
|
+
a,b = b.round,(a%b).round
|
112
|
+
end
|
113
|
+
return b
|
114
|
+
end
|
115
|
+
end
|
116
|
+
```
|
117
|
+
Here's a themed sample:
|
67
118
|
|
68
119
|
<img src="http://cl.ly/TFCm/content.png" alt='sample screenshot of the code snippet above renderd with the light theme' width="816px">
|
69
120
|
|
data/lib/octopress-codefence.rb
CHANGED
@@ -28,6 +28,7 @@ module Octopress
|
|
28
28
|
|
29
29
|
def render
|
30
30
|
@input.encode!("UTF-8")
|
31
|
+
@input = sub_option_comment(@input)
|
31
32
|
@input.gsub /^`{3}(.+?)`{3}/m do
|
32
33
|
str = $1.to_s
|
33
34
|
str.gsub /([^\n]+)?\n(.+?)\Z/m do
|
@@ -43,6 +44,25 @@ module Octopress
|
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
47
|
+
# Allow html comments to set rendering options
|
48
|
+
#
|
49
|
+
# Example:
|
50
|
+
# <!-- title:"Example 1" -->
|
51
|
+
# ```ruby
|
52
|
+
#
|
53
|
+
# This becomes:
|
54
|
+
#
|
55
|
+
# ```ruby title:"Example 1"
|
56
|
+
#
|
57
|
+
# This allows Readme files to be rendered by GitHub and other markdown codefences
|
58
|
+
# But when processed by Octopress Codefence, the code examples are rendered with options
|
59
|
+
#
|
60
|
+
def sub_option_comment(input)
|
61
|
+
input.gsub /<!--(.+?)-->\n`{3}([^\n]+)/ do
|
62
|
+
"```#{$2} #{$1}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
46
66
|
def get_options(markup)
|
47
67
|
defaults = { escape: true }
|
48
68
|
clean_markup = CodeHighlighter.clean_markup(markup)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopress-codefence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octopress-code-highlighter
|