octopress-codefence 1.4.5 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84ab098c4bfba9bc82e0bdc02c408d2350ae9711
4
- data.tar.gz: e2fc79f3d55123928bd62a7ee16f71e2bce429be
3
+ metadata.gz: a0ba8ecc86de09e4e10e8d4a9c6a64afb0fe57d2
4
+ data.tar.gz: e43a0b12467ba1110b74556b52f0ce00cb7a524a
5
5
  SHA512:
6
- metadata.gz: cb66c4cab358b692179b2363652a1f1c5548a35c47946ea8b3b0b1ae7fba9910e8ee16bc029d0edef8ee3a7c9e8d363bd94c9c381a124f707ac2ea70e044bc9f
7
- data.tar.gz: 23f80f28938129b9d0ce07752b0378b75777fc5e597e301418ddab395f32e8e094bff10dc5db4f13e4e18016c19b313c46c9147521c73c5bd7ce9cfc6e735538
6
+ metadata.gz: 3bc3ed627cdac2ae68259777c04adb3cdca7694098c4682a148e38158381e4f195b68c2a96a374e0f401ba676884021053070cfa7557bfcb8ac0ca3c1ff7264b
7
+ data.tar.gz: cb5d5ab9ebd36b1d78aa71c8a8d9c2c74d4ec1fac5b41e17b65770f11bfe9a1842ce66e3af48cd3535a366bce40027518cdd4fa6ac54a5f7fa106014a7fc5eb8
data/.travis.yml CHANGED
@@ -2,4 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 1.9.3
5
- script: cd test && bundle exec clash
5
+ script: bundle exec clash test
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.0 - 2015-01-03
4
+ - Now html comments can be used for setting code options.
5
+ - Added usage documentation.
6
+
3
7
  ## 1.4.5 - 2014-12-19
4
8
  - Fix to readme
5
9
  - Integrated octopress-docs support
data/README.md CHANGED
@@ -7,33 +7,56 @@ Write beautiful fenced code snippets within any template.
7
7
 
8
8
  ## Installation
9
9
 
10
- Add this line to your application's Gemfile:
10
+ ### Using Bundler
11
11
 
12
- gem 'octopress-codefence'
12
+ Add this line to your application's Gemfile (optionally in the `:jekyll_plugins` group:
13
13
 
14
- And then execute:
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
- Or install it yourself as:
24
+ ### Manual Installation
19
25
 
20
26
  $ gem install octopress-codefence
21
27
 
22
- ## Usage
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
- Next, add the Octopress stlyesheets tag to your site layout this will inject stylesheet tags for all Octopress Ink plugins.
35
+ ## Usage
32
36
 
33
- ```html
34
- <!--Somewhere in your site's head-->
35
- {% css_asset_tag %}
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
- Here's a sample:
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
 
@@ -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)
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Codefence
3
- VERSION = "1.4.5"
3
+ VERSION = "1.5.0"
4
4
  end
5
5
  end
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.5
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: 2014-12-19 00:00:00.000000000 Z
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