middleman-syntax 3.4.0 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e10bda9e80f47020802183bad3a3849929d927afd99d2da43f0bf67547213028
4
- data.tar.gz: f930e8d69b461e426ae8e3ad63b3111d6b2607df9b66cee73fcd7f88e5d9fda8
3
+ metadata.gz: c41f2663b48aae350425db1c725c5e879f8c2bf70eeee2daa85011a7975f99ba
4
+ data.tar.gz: c6e893e03faa6f466783e26fc95a44df915aa435c8c87ca7c83253b0ef44b0aa
5
5
  SHA512:
6
- metadata.gz: b7d960fc8adae60a7f21b67ba7ebbfd7c103121ac000ff94361fee9fcdb64e2df6c8a57161f125103c296c4c242943d5b5593e7f9b29b621d2a0b2c223ecaa52
7
- data.tar.gz: 141ea649e0a810ecfde705d7072290a85377bc2d73194fed063da2adb5bd03e85a74b09c35f87fb9fef7aab40f74e5af501ae1c581b3063ae8e0f8108a3b76af
6
+ metadata.gz: 8c812e2f320378a9b8e64344974e0277d0904f7834358b1878f93e5305f98bd2a3d7cc90b62bab720d2cfadea0d25ac27ef45709e4a1be58b9f4cae401d88338
7
+ data.tar.gz: b5e220fb0f0fee8c712779619e9cda036b2438e9f8bd571e9f65e24aad5e1bd10fe1f134db4e7140818cc574381d67d05a924171e7aaef5a8b5627cf54413a8e
@@ -1,6 +1,10 @@
1
1
  name: CI
2
2
 
3
- on: [push, pull_request]
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
4
8
 
5
9
  jobs:
6
10
  test:
@@ -9,7 +13,7 @@ jobs:
9
13
  strategy:
10
14
  fail-fast: false
11
15
  matrix:
12
- ruby-version: ["3.3", "3.2", "3.1", "3.0", "2.7", "2.6", "2.5"]
16
+ ruby-version: ["3.4", "3.3", "3.2", "3.1", "3.0", "2.7"]
13
17
  steps:
14
18
  - uses: actions/checkout@v4
15
19
  - name: Set up Ruby
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ # 3.5.0
6
+
7
+ - Remove official support for Ruby 2.5 and 2.6 (#89).
8
+ - Add ability to add other classes to the :syntax plugin (#90).
9
+
5
10
  # 3.4.0
6
11
 
7
12
  - Haml 6 support (#82, #84).
data/Gemfile CHANGED
@@ -10,15 +10,13 @@ gem 'rake', '~> 13.1', require: false
10
10
  gem 'yard', '~> 0.9', require: false
11
11
 
12
12
  # Test tools
13
- gem 'pry', '~> 0.10', group: :development
14
- gem 'aruba', '~> 1.0.0'
15
- gem 'rspec', '~> 3.0'
16
- gem 'cucumber', '~> 2.0'
17
- gem 'capybara', '~> 2.5.0'
13
+ gem 'aruba'
14
+ gem 'cucumber'
15
+ gem 'capybara'
16
+
17
+ # Optional dependencies, included for tests
18
18
  gem 'haml', RUBY_VERSION > '3.0' ? '< 7' : '< 6'
19
- gem 'slim', '>= 3', '< 5'
19
+ gem 'slim'
20
20
  gem 'kramdown'
21
- gem "redcarpet"
22
-
23
- # For old Rubies
24
- gem 'nokogiri', '~> 1.12.0'
21
+ gem 'redcarpet'
22
+ gem 'rack'
data/README.md CHANGED
@@ -29,6 +29,18 @@ You can also pass options to Rouge:
29
29
  activate :syntax, :line_numbers => true
30
30
  ```
31
31
 
32
+ You can add extra css classes to the pre tag elements:
33
+
34
+ ```ruby
35
+ activate :syntax, :extra_css_classes => ["custom-class", "another-class"]
36
+ ```
37
+
38
+ This will add the extra css classes to the `<pre>` element in the generated HTML:
39
+
40
+ ```html
41
+ <div class="highlight"><pre class="highlight language-name custom-class another-class"><code>...</code></pre></div>
42
+ ```
43
+
32
44
  The full set of options can be seen on your preview server's `/__middleman/config/` page.
33
45
 
34
46
  ## Helper
@@ -70,6 +82,7 @@ The `code` helper supports [Rouge](https://github.com/jayferd/rouge) instance fo
70
82
  * `start_line`
71
83
  * `css_class`
72
84
  * `wrap`
85
+ * `extra_css_classes`
73
86
 
74
87
  To use these formatter options per code block, include them in a hash as the second argument. e.g.
75
88
 
@@ -81,19 +94,40 @@ end
81
94
  <% end %>
82
95
  ```
83
96
 
97
+ You can also add extra css classes to specific code blocks:
98
+
99
+ ```erb
100
+ <% code("ruby", :extra_css_classes => ["custom-class", "special"]) do %>
101
+ def my_cool_method(message)
102
+ puts message
103
+ end
104
+ <% end %>
105
+ ```
106
+
107
+ This will produce HTML like:
108
+ ```html
109
+ <div class="highlight"><pre class="highlight ruby custom-class special"><code>...</code></pre></div>
110
+ ```
111
+
84
112
  ## CSS
85
113
 
86
114
  On a default (i.e. unstyled) Middleman project, it will appear as if `middleman-syntax` isn't working, since obviously no CSS has been applied to color your code. You can use any Pygments-compatible stylesheet to style your code.
87
115
 
88
- You can also let Rouge generate some CSS for you by creating a new stylesheet with a `.css.erb` extension in your Middleman project (at a path like `source/stylesheets/highlighting.css.erb` with the contents:
116
+ You can also let Rouge generate some CSS for you by creating a new stylesheet with a `.css.erb` extension in your Middleman project (at a path like `source/stylesheets/highlighting.css.erb`) with the contents:
89
117
 
90
118
  ```erb
91
119
  <%= Rouge::Themes::ThankfulEyes.render(:scope => '.highlight') %>
92
120
  ```
93
121
 
94
- If you want to include this in a larger Sass stylesheet, name it with an underscore (`source/stylesheets/_highlighting.css.erb`) and include it in your main stylesheet with `@import 'highlighting'`).
122
+ And then include it in your layout or specific page by:
123
+
124
+ ```erb
125
+ <%= stylesheet_link_tag "highlighting" %>
126
+ ```
127
+
128
+ If you want to include this in a larger Sass stylesheet, include it in your main stylesheet with `@import 'highlighting.css'`).
95
129
 
96
- Rouge has `ThankfulEyes`, `Colorful`, `Github`, `Base16`, `Base16::Solarized` (like Octopress), `Base16::Monokai`, and `Monokai` themes.
130
+ Rouge has `ThankfulEyes`, `Colorful`, `Github`, `Base16`, `Base16::Solarized`, `Base16::Monokai`, and `Monokai` themes.
97
131
 
98
132
  ## Markdown
99
133
 
@@ -108,7 +142,7 @@ set :markdown, :fenced_code_blocks => true, :smartypants => true
108
142
  set :markdown_engine, :kramdown
109
143
  ```
110
144
 
111
- Now your Markdown will work just like it does [on GitHub](http://github.github.com/github-flavored-markdown/) - you can write something like this with Redcarpet:
145
+ Now your Markdown will work just like it does [on GitHub](https://docs.github.com/en/get-started/writing-on-github) - you can write something like this with Redcarpet:
112
146
 
113
147
  <pre>
114
148
  ```ruby
data/Rakefile CHANGED
@@ -2,9 +2,9 @@ require 'bundler/gem_tasks'
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
5
- exempt_tags = ""
6
- exempt_tags << "--tags ~@nojava " if RUBY_PLATFORM == "java"
7
- t.cucumber_opts = "--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
5
+ exempt_tags = ["--tags 'not @wip'"]
6
+ exempt_tags << "--tags 'not @nojava'" if RUBY_PLATFORM == "java"
7
+ t.cucumber_opts = "--require features --color #{exempt_tags.join(' ')} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
8
8
  end
9
9
 
10
10
  task :test => ["cucumber"]
@@ -0,0 +1,55 @@
1
+ Feature: Extra css classes for the pre tag
2
+
3
+ Scenario: Extra css classes from configuration
4
+ Given a fixture app "test-app-extra-css-classes"
5
+ And a file named "config.rb" with:
6
+ """
7
+ activate :syntax, :extra_css_classes => ["custom-class", "another-class"]
8
+ """
9
+ And a file named "source/index.html.erb" with:
10
+ """
11
+ <% code("ruby") do %>
12
+ def my_method
13
+ puts "Hello"
14
+ end
15
+ <% end %>
16
+ """
17
+ And the Server is running
18
+ When I go to "/index.html"
19
+ Then I should see '<pre class="highlight ruby custom-class another-class"><code>'
20
+
21
+ Scenario: Extra css classes as a string
22
+ Given a fixture app "test-app-extra-css-classes"
23
+ And a file named "config.rb" with:
24
+ """
25
+ activate :syntax, :extra_css_classes => "custom-class another-class"
26
+ """
27
+ And a file named "source/index.html.erb" with:
28
+ """
29
+ <% code("ruby") do %>
30
+ def my_method
31
+ puts "Hello"
32
+ end
33
+ <% end %>
34
+ """
35
+ And the Server is running
36
+ When I go to "/index.html"
37
+ Then I should see '<pre class="highlight ruby custom-class another-class"><code>'
38
+
39
+ Scenario: Extra css classes via helper options
40
+ Given a fixture app "test-app-extra-css-classes"
41
+ And a file named "config.rb" with:
42
+ """
43
+ activate :syntax
44
+ """
45
+ And a file named "source/index.html.erb" with:
46
+ """
47
+ <% code("ruby", :extra_css_classes => ["helper-class", "another-helper-class"]) do %>
48
+ def my_method
49
+ puts "Hello"
50
+ end
51
+ <% end %>
52
+ """
53
+ And the Server is running
54
+ When I go to "/index.html"
55
+ Then I should see '<pre class="highlight ruby helper-class another-helper-class"><code>'
@@ -3,4 +3,3 @@ ENV['TEST'] = 'true'
3
3
  require "middleman-core"
4
4
  require "middleman-core/step_definitions"
5
5
  require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-syntax')
6
-
@@ -0,0 +1 @@
1
+ activate :syntax, :extra_css_classes => ["custom-class", "another-class"]
@@ -0,0 +1,5 @@
1
+ <% code("ruby") do %>
2
+ def my_method
3
+ puts "Hello"
4
+ end
5
+ <% end %>
@@ -14,6 +14,7 @@ module Middleman
14
14
  option :inline_theme, nil, 'A Rouge::CSSTheme that will be used to highlight the output with inline styles instead of using CSS classes.'
15
15
  option :wrap, true, 'Wrap the highlighted content in a container (<pre> or <div>, depending on whether :line_numbers is on).'
16
16
  option :lexer_options, {}, 'Options for the Rouge lexers.'
17
+ option :extra_css_classes, [], 'Additional CSS classes to add to the pre tag.'
17
18
 
18
19
  def after_configuration
19
20
  Middleman::Syntax::Highlighter.options = options
@@ -16,7 +16,16 @@ module Middleman
16
16
  @formatter = Rouge::Formatters::HTMLLinewise.new(@formatter, class:'line-%i') if opts[:line_numbers_div]
17
17
 
18
18
  if opts.fetch(:wrap, true)
19
- @formatter = Rouge::Formatters::HTMLPygments.new(@formatter, opts.fetch(:css_class, 'codehilite'))
19
+ css_class = opts.fetch(:css_class, 'codehilite')
20
+
21
+ # Add custom classes to the pre element
22
+ if opts[:extra_css_classes] && !opts[:extra_css_classes].empty?
23
+ extra_css_classes = opts[:extra_css_classes].is_a?(Array) ? opts[:extra_css_classes] : opts[:extra_css_classes].to_s.split
24
+ # Include the custom classes in the css_class parameter
25
+ css_class = [css_class].concat(extra_css_classes).join(' ')
26
+ end
27
+
28
+ @formatter = Rouge::Formatters::HTMLPygments.new(@formatter, css_class)
20
29
  end
21
30
  end
22
31
 
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Syntax
3
- VERSION = "3.4.0"
3
+ VERSION = "3.5.0"
4
4
  end
5
5
  end
@@ -12,12 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.license = "MIT"
13
13
  s.files = `git ls-files -z`.split("\0")
14
14
  s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
15
- s.require_paths = ["lib"]
16
15
  s.add_runtime_dependency("middleman-core", [">= 3.2"])
17
16
  s.add_runtime_dependency("rouge", ["~> 3.2"])
18
- s.add_development_dependency("aruba")
19
- s.add_development_dependency("cucumber")
20
- s.add_development_dependency("haml")
21
- s.add_development_dependency("kramdown")
22
- s.add_development_dependency("slim")
23
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-syntax
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Hollis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-19 00:00:00.000000000 Z
11
+ date: 2025-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -38,76 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
- - !ruby/object:Gem::Dependency
42
- name: aruba
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: cucumber
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: haml
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: kramdown
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: slim
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
41
  description: Code syntax highlighting plugin via rouge for Middleman
112
42
  email:
113
43
  - ben@benhollis.net
@@ -115,8 +45,6 @@ executables: []
115
45
  extensions: []
116
46
  extra_rdoc_files: []
117
47
  files:
118
- - ".devcontainer/Dockerfile"
119
- - ".devcontainer/devcontainer.json"
120
48
  - ".github/workflows/ci.yml"
121
49
  - ".gitignore"
122
50
  - CHANGELOG.md
@@ -125,6 +53,7 @@ files:
125
53
  - LICENSE.md
126
54
  - README.md
127
55
  - Rakefile
56
+ - features/extra_css_classes.feature
128
57
  - features/haml_filter.feature
129
58
  - features/helper.feature
130
59
  - features/markdown.feature
@@ -132,6 +61,8 @@ files:
132
61
  - features/markdown_line_numbers_enabled.feature
133
62
  - features/support/env.rb
134
63
  - features/support/step_definitions.rb
64
+ - fixtures/test-app-extra-css-classes/config.rb
65
+ - fixtures/test-app-extra-css-classes/source/index.html.erb
135
66
  - fixtures/test-app/config.rb
136
67
  - fixtures/test-app/source/code.html.markdown
137
68
  - fixtures/test-app/source/code_haml.html.haml
@@ -174,6 +105,7 @@ signing_key:
174
105
  specification_version: 4
175
106
  summary: Code syntax highlighting plugin via rouge for Middleman
176
107
  test_files:
108
+ - features/extra_css_classes.feature
177
109
  - features/haml_filter.feature
178
110
  - features/helper.feature
179
111
  - features/markdown.feature
@@ -181,6 +113,8 @@ test_files:
181
113
  - features/markdown_line_numbers_enabled.feature
182
114
  - features/support/env.rb
183
115
  - features/support/step_definitions.rb
116
+ - fixtures/test-app-extra-css-classes/config.rb
117
+ - fixtures/test-app-extra-css-classes/source/index.html.erb
184
118
  - fixtures/test-app/config.rb
185
119
  - fixtures/test-app/source/code.html.markdown
186
120
  - fixtures/test-app/source/code_haml.html.haml
@@ -1,19 +0,0 @@
1
- # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/ruby/.devcontainer/base.Dockerfile
2
-
3
- # [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.1, 3.0, 2, 2.7, 3-bullseye, 3.1-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 3-buster, 3.1-buster, 3.0-buster, 2-buster, 2.7-buster
4
- ARG VARIANT="3.1-bullseye"
5
- FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
6
-
7
- # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8
- ARG NODE_VERSION="none"
9
- RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10
-
11
- # [Optional] Uncomment this section to install additional OS packages.
12
- # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
13
- # && apt-get -y install --no-install-recommends <your-package-list-here>
14
-
15
- # [Optional] Uncomment this line to install additional gems.
16
- # RUN gem install <your-gem-names-here>
17
-
18
- # [Optional] Uncomment this line to install global node packages.
19
- # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -1,37 +0,0 @@
1
- // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
- // https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/ruby
3
- {
4
- "name": "Ruby",
5
- "build": {
6
- "dockerfile": "Dockerfile",
7
- "args": {
8
- // Update 'VARIANT' to pick a Ruby version: 3, 3.1, 3.0, 2, 2.7
9
- // Append -bullseye or -buster to pin to an OS version.
10
- // Use -bullseye variants on local on arm64/Apple Silicon.
11
- "VARIANT": "2.7",
12
- // Options
13
- "NODE_VERSION": "lts/*"
14
- }
15
- },
16
-
17
- // Configure tool-specific properties.
18
- "customizations": {
19
- // Configure properties specific to VS Code.
20
- "vscode": {
21
- // Add the IDs of extensions you want installed when the container is created.
22
- "extensions": [
23
- "rebornix.Ruby"
24
- ]
25
- }
26
- },
27
-
28
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
29
- // "forwardPorts": [],
30
-
31
- // Use 'postCreateCommand' to run commands after the container is created.
32
- // "postCreateCommand": "ruby --version",
33
-
34
- // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
35
- "remoteUser": "vscode"
36
-
37
- }