jekyll-katex 0.1.4 → 0.2.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: 245c842caca588d55ca898b3795be4bb88d18bb363f992232dbf4c6003dac92b
4
- data.tar.gz: 37da7ae6d2de974ef560c703004099536b473d0f02227f1e798593228d1f7147
3
+ metadata.gz: 97204d37eda949470ffafeaedfc8341aabf81615f48f97a8ac0f5d4c0dd4fa7c
4
+ data.tar.gz: bffedf65d7f5fd45b8ed2d19edb1f6da9c33bc2b5efc3782d75edd541797601f
5
5
  SHA512:
6
- metadata.gz: 37ee1e20e43fae43d0c9d08f8552677226409a5b32ebd7bf4fdfaff592fc98384f5c753063077b2998b0bf68b1b24bdb9f0b4ec34f410d38a80fb5435ff9dc8b
7
- data.tar.gz: f32d42946fe223aeb0b3a9f04fc6c65d75dc212bbdd5a2bdf21ec44ab625b20fa1dade256e1b1c4e4b2db71c86b4ab77c0cf5881de4b4dc6aab5f091ac58ecb3
6
+ metadata.gz: 3e86b908ba3bc9695603facd44919aaf8844b58a5554b3577c94b1728364fafd50cc6206c5c870d26c5f4c32fc5cc3dbab27222ab0c34b994dfc4b7c1b188b7a
7
+ data.tar.gz: 39309615a67795675f4dc9e3ab4138d1a9822eeafb9d892a24ee4ff0c072e0b556722c4e4acfbb33197f6b976527550881dea40e09ea65f34f1e04756712ae93
@@ -0,0 +1,6 @@
1
+
2
+ Metrics/LineLength:
3
+ Max: 120
4
+
5
+ Metrics/BlockLength:
6
+ Max: 60
data/README.md CHANGED
@@ -6,35 +6,49 @@ KaTeX is a library for rending math on the web using LaTeX, similar to MathJax.
6
6
  KaTeX differs from MathJax in that it displays faster rendering speed and renders to pure HTML rather than PNGs.
7
7
  There are various resources in benchmarking and comparing their performance, for more info, [start here](https://khan.github.io/KaTeX/).
8
8
 
9
- Comes packaged with KaTeX `^0.8.3` but
9
+ Comes packaged with KaTeX `0.9.0` but you can specify a different version in your Jekyll `_config.yml` (see below).
10
10
 
11
11
  ## Installation
12
12
 
13
13
  ### Bundler (recommended)
14
14
 
15
- In your Jekyll project, add `jekyll-katex` to your `gems.rb`/`Gemfile` plugin block:
15
+ 1. In your Jekyll project, add the plugin to your `_config.yml`, e.g.:
16
16
 
17
- ```ruby
18
- group :jekyll_plugins do
19
- gem 'jekyll-katex'
20
- end
21
- ```
17
+ ```yaml
18
+ plugins:
19
+ - jekyll-katex
20
+ ```
21
+
22
+ 2. Add `jekyll-katex` to your `gems.rb`/`Gemfile` plugin block:
23
+
24
+ ```ruby
25
+ group :jekyll_plugins do
26
+ gem 'jekyll-katex'
27
+ end
28
+ ```
22
29
 
23
- Once done, execute `bundle install`.
30
+ Once done, execute `bundle install`. For more information, see [here](https://jekyllrb.com/docs/plugins/).
24
31
 
25
- For alternative install methods, see [here](https://jekyllrb.com/docs/plugins/).
32
+ 3. Add KaTeX CSS and Fonts. Follow the installation instructions on the [KaTeX README](https://github.com/Khan/KaTeX).
33
+ You can skip including the `.js` file unless you want to do client-side in-browser rendering, as well.
26
34
 
27
- ### Config
35
+ Put the following (adjusting for your version) in your page headers:
28
36
 
29
- Once plugin is included in your project, follow the installation instructions on the [KaTeX](https://github.com/Khan/KaTeX) README for the CSS and font files.
30
- You can skip including the `.js` file unless you want to do client-side in-browser rendering as well.
37
+ ```html
38
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0-alpha/dist/katex.min.css" integrity="sha384-BTL0nVi8DnMrNdMQZG1Ww6yasK9ZGnUxL1ZWukXQ7fygA1py52yPp9W4wrR00VML" crossorigin="anonymous">
39
+ ```
31
40
 
32
- #### tl;dr
41
+ ## Configuration
33
42
 
34
- Put the following in your page headers:
43
+ Supported configuration values, shown with default values:
35
44
 
36
- ```html
37
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.3/katex.min.css">
45
+ ```yml
46
+ katex:
47
+ js_path: "{{ Gem::lib_path }}/assets/js" # Path used to search for katex.min.js
48
+ rendering_options:
49
+ # Default KaTeX rendering options. See https://github.com/Khan/KaTeX#rendering-options
50
+ throw_error: true # throwOnError - set to false if you want rendering to output error as text rather than a build error
51
+ error_color: "#cc0000" # errorColor
38
52
  ```
39
53
 
40
54
  ## Usage
@@ -57,16 +71,11 @@ c = \pm\sqrt{a^2 + b^2}
57
71
 
58
72
  ## Development
59
73
 
60
- ### Getting Started
61
-
62
74
  ```bash
63
- ./bin/setup.sh
75
+ $ bundle install
76
+ $ rake build
64
77
  ```
65
78
 
66
- ### TODOs
67
-
68
- 1. Better stand-alone packaging of KaTeX - specific KaTeX version shouldn't need to depend on this plugin
69
-
70
79
  ## Contributing
71
80
 
72
81
  Feel free to open issues and pull requests.
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
2
4
 
3
5
  task default: :build
4
6
 
@@ -7,10 +9,16 @@ task :js_i do
7
9
  cp 'node_modules/katex/dist/katex.min.js', 'lib/assets/js/katex.min.js'
8
10
  end
9
11
 
10
- task build: [:js_i] do
12
+ task build: %i[js_i] do
11
13
  sh 'gem', 'build', 'jekyll-katex.gemspec'
12
14
  end
13
15
 
14
- task push: [:build] do
15
- sh 'gem', 'push', "jekyll-katex-#{Jekyll::Katex::VERSION}.gem"
16
+ task clobber: [:clean] do
17
+ rm_rf Rake::FileList.new('*.gem')
18
+ end
19
+
20
+ task :stylecheck do
21
+ sh 'bundle', 'exec', 'rubocop', '--auto-correct'
16
22
  end
23
+
24
+ task release: :stylecheck
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "jekyll/katex"
4
+ require 'bundler/setup'
5
+ require 'jekyll-katex'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "jekyll/katex"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-katex (0.1.4)
4
+ jekyll-katex (0.2.0)
5
5
  execjs (~> 2.7)
6
6
  jekyll (~> 3.8)
7
7
 
@@ -14,17 +14,18 @@ GEM
14
14
  colorator (1.1.0)
15
15
  concurrent-ruby (1.0.5)
16
16
  diff-lcs (1.3)
17
+ docile (1.3.1)
17
18
  em-websocket (0.5.1)
18
19
  eventmachine (>= 0.12.9)
19
20
  http_parser.rb (~> 0.6.0)
20
21
  eventmachine (1.2.7)
21
22
  execjs (2.7.0)
22
- ffi (1.9.23)
23
+ ffi (1.9.25)
23
24
  forwardable-extended (2.6.0)
24
25
  http_parser.rb (0.6.0)
25
26
  i18n (0.9.5)
26
27
  concurrent-ruby (~> 1.0)
27
- jekyll (3.8.2)
28
+ jekyll (3.8.3)
28
29
  addressable (~> 2.4)
29
30
  colorator (~> 1.0)
30
31
  em-websocket (~> 0.5)
@@ -41,6 +42,7 @@ GEM
41
42
  sass (~> 3.4)
42
43
  jekyll-watch (2.0.0)
43
44
  listen (~> 3.0)
45
+ json (2.1.0)
44
46
  kramdown (1.17.0)
45
47
  liquid (4.0.0)
46
48
  listen (3.1.5)
@@ -55,9 +57,8 @@ GEM
55
57
  forwardable-extended (~> 2.6)
56
58
  powerpack (0.1.1)
57
59
  public_suffix (3.0.2)
58
- rainbow (2.2.2)
59
- rake
60
- rake (10.5.0)
60
+ rainbow (3.0.0)
61
+ rake (12.3.1)
61
62
  rb-fsevent (0.10.3)
62
63
  rb-inotify (0.9.10)
63
64
  ffi (>= 0.5.0, < 2)
@@ -75,11 +76,11 @@ GEM
75
76
  diff-lcs (>= 1.2.0, < 2.0)
76
77
  rspec-support (~> 3.7.0)
77
78
  rspec-support (3.7.1)
78
- rubocop (0.50.0)
79
+ rubocop (0.56.0)
79
80
  parallel (~> 1.10)
80
- parser (>= 2.3.3.1, < 3.0)
81
+ parser (>= 2.5)
81
82
  powerpack (~> 0.1)
82
- rainbow (>= 2.2.2, < 3.0)
83
+ rainbow (>= 2.2.2, < 4.0)
83
84
  ruby-progressbar (~> 1.7)
84
85
  unicode-display_width (~> 1.0, >= 1.0.1)
85
86
  ruby-progressbar (1.9.0)
@@ -90,7 +91,12 @@ GEM
90
91
  sass-listen (4.0.0)
91
92
  rb-fsevent (~> 0.9, >= 0.9.4)
92
93
  rb-inotify (~> 0.9, >= 0.9.7)
93
- unicode-display_width (1.3.3)
94
+ simplecov (0.16.1)
95
+ docile (~> 1.1)
96
+ json (>= 1.8, < 3)
97
+ simplecov-html (~> 0.10.0)
98
+ simplecov-html (0.10.2)
99
+ unicode-display_width (1.4.0)
94
100
 
95
101
  PLATFORMS
96
102
  ruby
@@ -98,9 +104,10 @@ PLATFORMS
98
104
  DEPENDENCIES
99
105
  bundler (~> 1.16)
100
106
  jekyll-katex!
101
- rake (~> 10.5)
107
+ rake (~> 12.3)
102
108
  rspec (~> 3.7)
103
- rubocop (~> 0.50.0)
109
+ rubocop (~> 0.56.0)
110
+ simplecov (~> 0.16)
104
111
 
105
112
  BUNDLED WITH
106
113
  1.16.2
data/gems.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in jekyll-katex.gemspec
@@ -1,8 +1,10 @@
1
- # encoding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path('lib', __dir__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
 
5
- require 'jekyll/katex/version'
7
+ require 'jekyll-katex/version'
6
8
 
7
9
  Gem::Specification.new do |spec|
8
10
  spec.name = 'jekyll-katex'
@@ -10,8 +12,8 @@ Gem::Specification.new do |spec|
10
12
  spec.authors = ['Jerry Lin']
11
13
  spec.email = 'linjer@gmail.com'
12
14
 
13
- spec.summary = %q{Jekyll plugin for easy KaTeX math server-side rendering.}
14
- spec.description = %q{Adds a liquid tag you can use to do server-side rendering of latex math using KaTeX}
15
+ spec.summary = 'Jekyll plugin for easy KaTeX math server-side rendering.'
16
+ spec.description = 'Adds a liquid tag you can use to do server-side rendering of latex math using KaTeX'
15
17
  spec.homepage = 'https://github.com/linjer/jekyll-katex'
16
18
  spec.license = 'MIT'
17
19
 
@@ -24,17 +26,18 @@ Gem::Specification.new do |spec|
24
26
  # end
25
27
 
26
28
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } <<
27
- spec.bindir = 'bin'
29
+ spec.bindir = 'bin'
28
30
  spec.executables = []
29
31
  spec.require_paths = ['lib']
30
32
 
31
- spec.required_ruby_version = '>= 2.3.5'
33
+ spec.required_ruby_version = '>= 2.5.1'
32
34
 
33
- spec.add_runtime_dependency 'jekyll', '~> 3.8'
34
35
  spec.add_runtime_dependency 'execjs', '~> 2.7'
36
+ spec.add_runtime_dependency 'jekyll', '~> 3.8'
35
37
 
36
38
  spec.add_development_dependency 'bundler', '~> 1.16'
37
39
  spec.add_development_dependency 'rake', '~> 12.3'
38
40
  spec.add_development_dependency 'rspec', '~> 3.7'
39
41
  spec.add_development_dependency 'rubocop', '~> 0.56.0'
42
+ spec.add_development_dependency 'simplecov', '~> 0.16'
40
43
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'jekyll'
2
4
 
3
- require 'jekyll/katex/version'
4
- require 'jekyll/katex/lib_root'
5
+ require 'jekyll-katex/version'
6
+ require 'jekyll-katex/lib_root'
5
7
  require 'jekyll/tags/katex'
6
8
 
7
9
  Liquid::Template.register_tag('katex', Jekyll::Tags::Katex)
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+
5
+ module Jekyll
6
+ module Katex
7
+ # For holding configuration values specific to the jekyll-katex plugin
8
+ class Configuration
9
+ LOG_TOPIC = 'Katex Configuration:'
10
+ CONFIG_DEFAULTS = {
11
+ js_filename: 'katex.min.js',
12
+ js_path: File.join(Jekyll::Katex::LIB_ROOT, 'assets/js/'),
13
+ rendering_options: {
14
+ throw_error: true,
15
+ error_color: '#cc0000'
16
+ }
17
+ }.freeze
18
+
19
+ JEKYLL_CONFIG = Jekyll.configuration['katex']
20
+
21
+ def self.js_path
22
+ js_filename = JEKYLL_CONFIG['js_filename'] || CONFIG_DEFAULTS[:js_filename]
23
+ js_path = JEKYLL_CONFIG['js_path'] || CONFIG_DEFAULTS[:js_path]
24
+
25
+ katex_js = Dir.glob("#{js_path}/**/#{js_filename}").first
26
+ if katex_js.nil?
27
+ raise RuntimeError, 'Could not find KaTeX javascript file using provided configuration.'
28
+ end
29
+ Jekyll.logger.info LOG_TOPIC, "Found KaTeX js at: #{katex_js}"
30
+ katex_js
31
+ end
32
+
33
+ def self.global_rendering_options
34
+ {
35
+ throwOnError: JEKYLL_CONFIG['throw_error'] || CONFIG_DEFAULTS[:throw_error],
36
+ errorColor: JEKYLL_CONFIG['error_color'] || CONFIG_DEFAULTS[:error_color]
37
+ }
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Katex
5
+ LIB_ROOT = (File.expand_path '..', __dir__).freeze
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Katex
5
+ VERSION = '0.2.0'
6
+ end
7
+ end
@@ -1,25 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'execjs'
4
+ require 'jekyll-katex/configuration'
2
5
 
3
6
  module Jekyll
4
7
  module Tags
8
+ # Defines the custom Liquid tag for compile-time rendering of KaTeX math
9
+ # {% katex %}
10
+ # <latex math>
11
+ # {% endkatex %}
5
12
  class Katex < Liquid::Block
6
-
7
- KATEX_JS_PATH = File.join(Jekyll::Katex::LIB_ROOT, 'assets/js/katex.min.js')
13
+ LOG_TOPIC = 'Katex Block:'
14
+ KATEX ||= ExecJS.compile(File.open(Jekyll::Katex::Configuration.js_path).read)
8
15
 
9
16
  def initialize(tag_name, markup, tokens)
10
17
  super
11
- @tokens = tokens
12
18
  @markup = markup
13
-
19
+ @tokens = tokens
14
20
  @display = markup.include? 'display'
15
- @katex = ExecJS.compile(open(KATEX_JS_PATH).read)
16
21
  end
17
22
 
18
23
  def render(context)
19
24
  latex_source = super
20
- @katex.call("katex.renderToString", latex_source, displayMode: @display)
25
+ rendering_options = Jekyll::Katex::Configuration.global_rendering_options.merge({ displayMode: @display })
26
+ KATEX.call('katex.renderToString', latex_source, rendering_options)
21
27
  end
22
28
  end
23
29
  end
24
30
  end
25
- 2
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-katex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerry Lin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-01 00:00:00.000000000 Z
11
+ date: 2018-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: jekyll
14
+ name: execjs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.8'
19
+ version: '2.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.8'
26
+ version: '2.7'
27
27
  - !ruby/object:Gem::Dependency
28
- name: execjs
28
+ name: jekyll
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.7'
33
+ version: '3.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.7'
40
+ version: '3.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.56.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.16'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.16'
97
111
  description: Adds a liquid tag you can use to do server-side rendering of latex math
98
112
  using KaTeX
99
113
  email: linjer@gmail.com
@@ -102,20 +116,21 @@ extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
104
118
  - ".gitignore"
119
+ - ".rubocop.yml"
105
120
  - ".ruby-version"
106
121
  - ".travis.yml"
107
122
  - LICENSE.txt
108
123
  - README.md
109
124
  - Rakefile
110
125
  - bin/console
111
- - bin/setup.sh
112
126
  - gems.locked
113
127
  - gems.rb
114
128
  - jekyll-katex.gemspec
115
129
  - lib/assets/js/katex.min.js
116
- - lib/jekyll/katex.rb
117
- - lib/jekyll/katex/lib_root.rb
118
- - lib/jekyll/katex/version.rb
130
+ - lib/jekyll-katex.rb
131
+ - lib/jekyll-katex/configuration.rb
132
+ - lib/jekyll-katex/lib_root.rb
133
+ - lib/jekyll-katex/version.rb
119
134
  - lib/jekyll/tags/katex.rb
120
135
  - package.json
121
136
  - yarn.lock
@@ -131,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
146
  requirements:
132
147
  - - ">="
133
148
  - !ruby/object:Gem::Version
134
- version: 2.3.5
149
+ version: 2.5.1
135
150
  required_rubygems_version: !ruby/object:Gem::Requirement
136
151
  requirements:
137
152
  - - ">="
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
- rake katex_npm_i
@@ -1,5 +0,0 @@
1
- module Jekyll
2
- module Katex
3
- LIB_ROOT = (File.expand_path '../../../', __FILE__).freeze
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- module Jekyll
2
- module Katex
3
- VERSION = '0.1.4'.freeze
4
- end
5
- end