asciidoctor-katex 0.2.1 → 0.4.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
  SHA256:
3
- metadata.gz: 8b8f1dbaf9e211004f8b2530d5a38eddfc8dbffb79de434ef235b742a024016a
4
- data.tar.gz: 6e6c1f3bf26032b08cd6911d8a533d90c38ae8a6d8b6d75b040d351fd55ea58f
3
+ metadata.gz: 7e8a66f68f47645c11eb6eb48b5b6ac979a147950b9a79ecbc12deba37d5cfc8
4
+ data.tar.gz: cade25d9f35c4b250bf4609c8d27580a54ec2a2c532c85494a22269f0043f374
5
5
  SHA512:
6
- metadata.gz: 34f07c9f37cdd21d7d73736a66638c584fff20e3ed4bb2ecb0413e1bf7a1deb91632d3474bc3776eb7c8d69c2b4bf8fa340dbb2aee5a52e5fa8762988684a7e4
7
- data.tar.gz: 7115b79918e7608087fa1521572cfa3dc5e9805c3f96dda06bc84b733f27f29330205cb67929d0a5c69b73275285f49f3b95c8eef506968eee256c5a81f2d3f2
6
+ metadata.gz: 6631284436120085851ac834e4d261f386f880e2e554ae2b063353a7ca28deb6402b8d816d2e59412f8c4884d9cb49d227ec5d8ed4f8b521e4bece566dfe6981
7
+ data.tar.gz: 37e7751d124af6fe76e8a40d8c7b12bd08d63b45ea5c45fdfb73c97beab4878fbd26c763603db6ed36d84fdcd93aeec3851cee75b879c755fe684e5edae621bc
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright 2018 Jakub Jirutka <jakub@jirutka.cz>.
3
+ Copyright 2018-present Jakub Jirutka <jakub@jirutka.cz>.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.adoc CHANGED
@@ -7,7 +7,7 @@
7
7
  :codacy-id: 58f6aa6e3ef04c8aad1ecd276a8a2c35
8
8
 
9
9
  ifdef::env-github[]
10
- image:https://travis-ci.com/{gh-name}.svg?branch={gh-branch}[Build Status, link="https://travis-ci.com/{gh-name}"]
10
+ image:https://github.com/{gh-name}/workflows/CI/badge.svg[CI Status, link=https://github.com/{gh-name}/actions?query=workflow%3A%22CI%22]
11
11
  image:https://api.codacy.com/project/badge/Coverage/{codacy-id}["Test Coverage", link="https://www.codacy.com/app/{gh-name}"]
12
12
  image:https://api.codacy.com/project/badge/Grade/{codacy-id}["Codacy Code quality", link="https://www.codacy.com/app/{gh-name}"]
13
13
  image:https://img.shields.io/gem/v/{gem-name}.svg?style=flat[Gem Version, link="https://rubygems.org/gems/{gem-name}"]
@@ -21,24 +21,27 @@ This project provides an http://asciidoctor.org/[Asciidoctor] extension for conv
21
21
 
22
22
  == Requirements
23
23
 
24
+ ifndef::npm-readme[]
24
25
  === Ruby
25
26
 
26
27
  * https://www.ruby-lang.org/[Ruby] 2.3+ or http://jruby.org/[JRuby] 9.1+
27
28
  * https://rubygems.org/gems/asciidoctor/[Asciidoctor] 1.5.6+
28
- * https://rubygems.org/gems/katex[katex (gem)] 0.4.3+
29
+ * https://rubygems.org/gems/katex[katex (gem)] ~> 0.8.0
29
30
  * JavaScript engine supported by https://github.com/rails/execjs#execjs[ExecJS]
30
31
  * https://rubygems.org/gems/thread_safe/[thread_safe] (not required, but recommended for Ruby MRI)
31
32
 
32
33
 
33
34
  === Node.js
35
+ endif::npm-readme[]
34
36
 
35
- * https://nodejs.org/[Node.js] 8+
36
- * https://www.npmjs.com/package/asciidoctor.js[asciidoctor.js] 1.5.6
37
- * https://www.npmjs.com/package/katex[katex (module)] 0.9.0+
37
+ * https://nodejs.org/[Node.js] >=8
38
+ * https://www.npmjs.com/package/@asciidoctor/core[@asciidoctor/core] >=2.0.0 <2.2.0
39
+ * https://www.npmjs.com/package/katex[katex (module)] >=0.9.0
38
40
 
39
41
 
40
42
  == Installation
41
43
 
44
+ ifndef::npm-readme[]
42
45
  === Ruby
43
46
 
44
47
  Install {gem-name} from Rubygems:
@@ -53,6 +56,7 @@ gem install {gem-name} --pre
53
56
 
54
57
 
55
58
  === Node.js
59
+ endif::npm-readme[]
56
60
 
57
61
  Install {gem-name} from npmjs.com:
58
62
 
@@ -62,6 +66,7 @@ npm install --save {gem-name}
62
66
 
63
67
  == Usage
64
68
 
69
+ ifndef::npm-readme[]
65
70
  === CLI
66
71
 
67
72
  If you invoke Asciidoctor from command-line, use option `-r` to load the extension:
@@ -81,11 +86,12 @@ IMPORTANT: Bundler automatically _requires_ all the specified gems.
81
86
 
82
87
 
83
88
  === Node.js
89
+ endif::npm-readme[]
84
90
 
85
91
  [source, js, subs="+attributes"]
86
92
  ----
87
93
  // Load asciidoctor.js and {gem-name}.
88
- const asciidoctor = require('asciidoctor.js')()
94
+ const asciidoctor = require('@asciidoctor/core')()
89
95
  const asciidoctorKatex = require('{gem-name}')
90
96
 
91
97
  // See documentation at the end of this section.
@@ -1,4 +1,4 @@
1
- require File.expand_path('../lib/asciidoctor/katex/version', __FILE__)
1
+ require File.expand_path('lib/asciidoctor/katex/version', __dir__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'asciidoctor-katex'
@@ -10,15 +10,16 @@ Gem::Specification.new do |s|
10
10
 
11
11
  s.summary = 'Asciidoctor extension that converts latexmath to HTML using KaTeX at build-time'
12
12
 
13
- s.files = Dir['lib/**/*', '*.gemspec', 'LICENSE*', 'README*']
13
+ s.files = Dir['lib/**/*', '*.gemspec', 'LICENSE*', 'README.adoc']
14
14
 
15
15
  s.required_ruby_version = '>= 2.3'
16
16
 
17
17
  s.add_runtime_dependency 'asciidoctor', '>= 1.5.6', '< 3.0'
18
- s.add_runtime_dependency 'katex', '~> 0.4.3'
18
+ s.add_runtime_dependency 'katex', '~> 0.8.0'
19
19
 
20
- s.add_development_dependency 'kramdown', '~> 1.17'
21
- s.add_development_dependency 'rake', '~> 12.0'
20
+ s.add_development_dependency 'kramdown', '~> 2.3'
21
+ s.add_development_dependency 'pandoc-ruby', '~> 2.0'
22
+ s.add_development_dependency 'rake', '~> 13.0'
22
23
  s.add_development_dependency 'rspec', '~> 3.7'
23
24
  s.add_development_dependency 'rspec-html-matchers', '~> 0.9.1'
24
25
  s.add_development_dependency 'rubocop', '~> 0.51.0'
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ require 'asciidoctor' unless RUBY_PLATFORM == 'opal'
3
+ require 'asciidoctor/extensions' unless RUBY_PLATFORM == 'opal'
4
+
5
+ module Asciidoctor::Katex
6
+ # Asciidoctor processor that removes MathJax `script` tags, produced by the
7
+ # Asciidcotor's built-in HTML converter, from the converted document.
8
+ class Postprocessor < Asciidoctor::Extensions::Postprocessor
9
+
10
+ # @param document [Asciidoctor::Document] the document to process.
11
+ # @param output [String] the converted document.
12
+ # @return [String] a modified *output*`.
13
+ def process(document, output)
14
+ return output if skip? document
15
+
16
+ output
17
+ .sub(%r{<script type="text/x-mathjax-config">.*?</script>}m, '') # FIXME: broken in JS
18
+ .sub(%r{<script src=".*?/MathJax\.js\?config=TeX-MML-AM_HTMLorMML"></script>}, '')
19
+ end
20
+
21
+ protected
22
+
23
+ # @param document [Asciidoctor::Document] the document to process.
24
+ # @return [Boolean] whether to skip processing of the *document*.
25
+ def skip?(document)
26
+ document.backend != 'html5'
27
+ end
28
+ end
29
+ end
@@ -28,7 +28,7 @@ module Asciidoctor::Katex
28
28
  opts[:error_color] = opts[:errorColor] || '#cc0000'
29
29
 
30
30
  begin
31
- ::Katex.render(math, opts)
31
+ ::Katex.render(math, **opts)
32
32
  rescue ::ExecJS::ProgramError => err
33
33
  raise ParseError.new(err, math) if err.to_s.start_with?('ParseError:')
34
34
  raise KatexError.new(err, math)
@@ -3,6 +3,6 @@
3
3
  module Asciidoctor
4
4
  module Katex
5
5
  # Version of the asciidoctor-katex gem.
6
- VERSION = '0.2.1'
6
+ VERSION = '0.4.0'
7
7
  end
8
8
  end
@@ -4,9 +4,11 @@ require 'asciidoctor/extensions' unless RUBY_PLATFORM == 'opal'
4
4
  require 'asciidoctor/katex/version'
5
5
  require 'asciidoctor/katex/errors'
6
6
  require 'asciidoctor/katex/treeprocessor'
7
+ require 'asciidoctor/katex/postprocessor'
7
8
 
8
9
  unless RUBY_PLATFORM == 'opal'
9
10
  Asciidoctor::Extensions.register do
10
11
  treeprocessor Asciidoctor::Katex::Treeprocessor
12
+ postprocessor Asciidoctor::Katex::Postprocessor
11
13
  end
12
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-katex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Jirutka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-02 00:00:00.000000000 Z
11
+ date: 2022-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -36,42 +36,56 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.4.3
39
+ version: 0.8.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.4.3
46
+ version: 0.8.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: kramdown
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '1.17'
53
+ version: '2.3'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '1.17'
60
+ version: '2.3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: pandoc-ruby
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.0'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: rake
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
79
  - - "~>"
66
80
  - !ruby/object:Gem::Version
67
- version: '12.0'
81
+ version: '13.0'
68
82
  type: :development
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
86
  - - "~>"
73
87
  - !ruby/object:Gem::Version
74
- version: '12.0'
88
+ version: '13.0'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: rspec
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -155,6 +169,7 @@ files:
155
169
  - lib/asciidoctor/katex.rb
156
170
  - lib/asciidoctor/katex/errors.rb
157
171
  - lib/asciidoctor/katex/opal_katex_adapter.rb
172
+ - lib/asciidoctor/katex/postprocessor.rb
158
173
  - lib/asciidoctor/katex/ruby_katex_adapter.rb
159
174
  - lib/asciidoctor/katex/stem_converter_decorator.rb
160
175
  - lib/asciidoctor/katex/treeprocessor.rb
@@ -179,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
194
  - !ruby/object:Gem::Version
180
195
  version: '0'
181
196
  requirements: []
182
- rubygems_version: 3.0.3
197
+ rubygems_version: 3.1.6
183
198
  signing_key:
184
199
  specification_version: 4
185
200
  summary: Asciidoctor extension that converts latexmath to HTML using KaTeX at build-time