middleman-syntax 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +15 -0
- data/README.md +15 -2
- data/lib/middleman-syntax/extension.rb +13 -2
- data/lib/middleman-syntax/version.rb +1 -1
- metadata +6 -5
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -17,6 +17,17 @@ Add `middleman-syntax` to your `Gemfile`, run `bundle install`, then open your `
|
|
17
17
|
activate :syntax
|
18
18
|
```
|
19
19
|
|
20
|
+
You can also pass options to pygments:
|
21
|
+
|
22
|
+
```
|
23
|
+
activate :syntax,
|
24
|
+
:linenos => 'inline',
|
25
|
+
:anchorlinenos => true,
|
26
|
+
:linenostart => 2
|
27
|
+
```
|
28
|
+
|
29
|
+
See the [pygments documentation](http://pygments.org/docs/formatters/) for a full list of possible options.
|
30
|
+
|
20
31
|
# Usage
|
21
32
|
|
22
33
|
The extension adds a new `code` helper to Middleman that you can use from your templates:
|
@@ -29,7 +40,9 @@ end
|
|
29
40
|
<% end %>
|
30
41
|
```
|
31
42
|
|
32
|
-
That'll produce syntax-highlighted HTML wrapped in a `<pre>` tag, wrapped in `<div class="hightlight">`. You can style this with any CSS that works on Pygments output.
|
43
|
+
That'll produce syntax-highlighted HTML wrapped in a `<pre>` tag, wrapped in `<div class="hightlight">`. You can style this with any CSS that works on Pygments output.
|
44
|
+
|
45
|
+
**Note** that on a default (i.e. unstyled) Middleman project, it will appear as if `middleman-syntax` isn't working, since none of the Pygments styles have any CSS applied! Open the browser Developer Tools to verify the code is being syntax highlighted.
|
33
46
|
|
34
47
|
The extension also makes code blocks in Markdown highlight code. Make sure you're using RedCarpet as your Markdown engine (in `config.rb`):
|
35
48
|
|
@@ -54,4 +67,4 @@ GitHub Issues are used for managing bug reports and feature requests. If you run
|
|
54
67
|
|
55
68
|
https://github.com/middleman/middleman-syntax/issues
|
56
69
|
|
57
|
-
The best way to get quick responses to your issues and swift fixes to your bugs is to submit detailed bug reports, include test cases and respond to developer questions in a timely manner. Even better, if you know Ruby, you can submit Pull Requests containing Cucumber Features which describe how your feature should work or exploit the bug you are submitting.
|
70
|
+
The best way to get quick responses to your issues and swift fixes to your bugs is to submit detailed bug reports, include test cases and respond to developer questions in a timely manner. Even better, if you know Ruby, you can submit Pull Requests containing Cucumber Features which describe how your feature should work or exploit the bug you are submitting.
|
@@ -1,9 +1,17 @@
|
|
1
1
|
module Middleman
|
2
2
|
module Syntax
|
3
3
|
class << self
|
4
|
+
|
5
|
+
def options
|
6
|
+
@@options
|
7
|
+
end
|
8
|
+
|
4
9
|
def registered(app, options_hash={})
|
5
10
|
require 'pygments'
|
6
11
|
|
12
|
+
@@options = options_hash
|
13
|
+
yield @@options if block_given?
|
14
|
+
|
7
15
|
app.send :include, Helper
|
8
16
|
|
9
17
|
require 'middleman-core/renderers/redcarpet'
|
@@ -43,13 +51,16 @@ module Middleman
|
|
43
51
|
@_out_buf = _buf_was
|
44
52
|
end
|
45
53
|
|
46
|
-
|
54
|
+
options = ::Middleman::Syntax.options.merge :lexer => language
|
55
|
+
concat_content Pygments.highlight(code, :options => options)
|
47
56
|
end
|
48
57
|
end
|
49
58
|
|
50
59
|
module MarkdownCodeRenderer
|
51
60
|
def block_code(code, language)
|
52
|
-
|
61
|
+
options = ::Middleman::Syntax.options
|
62
|
+
options.merge :lexer => language if language
|
63
|
+
Pygments.highlight(code, :options => options)
|
53
64
|
end
|
54
65
|
end
|
55
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-syntax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: middleman-core
|
@@ -52,6 +52,7 @@ extra_rdoc_files: []
|
|
52
52
|
files:
|
53
53
|
- .gitignore
|
54
54
|
- .travis.yml
|
55
|
+
- CHANGELOG.md
|
55
56
|
- Gemfile
|
56
57
|
- README.md
|
57
58
|
- Rakefile
|
@@ -75,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
76
|
version: '0'
|
76
77
|
segments:
|
77
78
|
- 0
|
78
|
-
hash:
|
79
|
+
hash: -1397287943190469667
|
79
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
81
|
none: false
|
81
82
|
requirements:
|
@@ -84,10 +85,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
85
|
version: '0'
|
85
86
|
segments:
|
86
87
|
- 0
|
87
|
-
hash:
|
88
|
+
hash: -1397287943190469667
|
88
89
|
requirements: []
|
89
90
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.8.
|
91
|
+
rubygems_version: 1.8.25
|
91
92
|
signing_key:
|
92
93
|
specification_version: 3
|
93
94
|
summary: Syntax-highlighting helpers for Middleman
|