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 +4 -4
- data/LICENSE +1 -1
- data/README.adoc +2 -2
- data/asciidoctor-katex.gemspec +4 -4
- data/lib/asciidoctor/katex/postprocessor.rb +29 -0
- data/lib/asciidoctor/katex/ruby_katex_adapter.rb +1 -1
- data/lib/asciidoctor/katex/version.rb +1 -1
- data/lib/asciidoctor/katex.rb +2 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e8a66f68f47645c11eb6eb48b5b6ac979a147950b9a79ecbc12deba37d5cfc8
|
4
|
+
data.tar.gz: cade25d9f35c4b250bf4609c8d27580a54ec2a2c532c85494a22269f0043f374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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-
|
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://
|
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.
|
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
|
|
data/asciidoctor-katex.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
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.
|
18
|
+
s.add_runtime_dependency 'katex', '~> 0.8.0'
|
19
19
|
|
20
|
-
s.add_development_dependency 'kramdown', '~>
|
20
|
+
s.add_development_dependency 'kramdown', '~> 2.3'
|
21
21
|
s.add_development_dependency 'pandoc-ruby', '~> 2.0'
|
22
|
-
s.add_development_dependency 'rake', '~>
|
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)
|
data/lib/asciidoctor/katex.rb
CHANGED
@@ -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.
|
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:
|
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.
|
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.
|
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: '
|
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: '
|
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: '
|
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: '
|
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
|
-
|
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
|