asciidoctor-katex 0.3.2 → 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: 0712356d82cd1a308b34068e72692d5b57d532b56c27df233e45448acbf573cc
4
- data.tar.gz: e08abc136e85cad86c6a3846a1bdab5402fdf3f4dd42c766ddbff997d0036819
3
+ metadata.gz: 7e8a66f68f47645c11eb6eb48b5b6ac979a147950b9a79ecbc12deba37d5cfc8
4
+ data.tar.gz: cade25d9f35c4b250bf4609c8d27580a54ec2a2c532c85494a22269f0043f374
5
5
  SHA512:
6
- metadata.gz: 8052a51a2f042de03d2e0b8af6e2c40779d6d77528a7fd065f286c36df92def5db6b594d38225a25ef8c5f7d0e9fa3d914ccd303aa4ed47b35e5e2a8ffcac7fd
7
- data.tar.gz: ea699ab2d2bbb09ae433ead3cb626ed5b797edc996e35317265c88d3899af6b00f4b246bbe7de0a00824889f87442d20874a4f346cdd7b705a683416da51d9de
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-2020 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}"]
@@ -26,7 +26,7 @@ ifndef::npm-readme[]
26
26
 
27
27
  * https://www.ruby-lang.org/[Ruby] 2.3+ or http://jruby.org/[JRuby] 9.1+
28
28
  * https://rubygems.org/gems/asciidoctor/[Asciidoctor] 1.5.6+
29
- * https://rubygems.org/gems/katex[katex (gem)] 0.4.3+
29
+ * https://rubygems.org/gems/katex[katex (gem)] ~> 0.8.0
30
30
  * JavaScript engine supported by https://github.com/rails/execjs#execjs[ExecJS]
31
31
  * https://rubygems.org/gems/thread_safe/[thread_safe] (not required, but recommended for Ruby MRI)
32
32
 
@@ -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'
@@ -15,11 +15,11 @@ Gem::Specification.new do |s|
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'
20
+ s.add_development_dependency 'kramdown', '~> 2.3'
21
21
  s.add_development_dependency 'pandoc-ruby', '~> 2.0'
22
- s.add_development_dependency 'rake', '~> 12.0'
22
+ s.add_development_dependency 'rake', '~> 13.0'
23
23
  s.add_development_dependency 'rspec', '~> 3.7'
24
24
  s.add_development_dependency 'rspec-html-matchers', '~> 0.9.1'
25
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.3.2'
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.3.2
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: 2020-03-07 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,28 +36,28 @@ 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
61
  - !ruby/object:Gem::Dependency
62
62
  name: pandoc-ruby
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '12.0'
81
+ version: '13.0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '12.0'
88
+ version: '13.0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: rspec
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -169,6 +169,7 @@ files:
169
169
  - lib/asciidoctor/katex.rb
170
170
  - lib/asciidoctor/katex/errors.rb
171
171
  - lib/asciidoctor/katex/opal_katex_adapter.rb
172
+ - lib/asciidoctor/katex/postprocessor.rb
172
173
  - lib/asciidoctor/katex/ruby_katex_adapter.rb
173
174
  - lib/asciidoctor/katex/stem_converter_decorator.rb
174
175
  - lib/asciidoctor/katex/treeprocessor.rb
@@ -193,8 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
194
  - !ruby/object:Gem::Version
194
195
  version: '0'
195
196
  requirements: []
196
- rubyforge_project:
197
- rubygems_version: 2.7.7
197
+ rubygems_version: 3.1.6
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: Asciidoctor extension that converts latexmath to HTML using KaTeX at build-time