asciidoctor-katex 0.3.2 → 0.4.1
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 +7 -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 +3 -1
- 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: edf8e588557af7e6168cb1155cfd50d831fd6021dc195bd4807ce13be05e7116
|
4
|
+
data.tar.gz: 378f6b5fd67bf47b37ddbc4f4f0ef8117f4d0284e89c0b2e12edbd2225af55b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99040f43b387cd6ef6fb0f4a80cfa391157b585b6f9179ad75bd0857cc00c34aa869337aa6b06dd1101c23b43a10984617ed50c5ec235cc3ad476b0b4fba32eb
|
7
|
+
data.tar.gz: c28da09148ba8258131769037d3afa4e665d8c184f66faf2d88d90fbe1d9cedb9cac51e580a9c8280189505ffe065fd912be4432e3abd647012b70b170686104
|
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}"]
|
@@ -15,6 +15,11 @@ image:https://img.shields.io/npm/v/{gem-name}.svg?style=flat[npm Version, link="
|
|
15
15
|
image:https://img.shields.io/badge/yard-docs-blue.svg[Yard Docs, link="http://www.rubydoc.info/github/{gh-name}/{gh-branch}"]
|
16
16
|
endif::env-github[]
|
17
17
|
|
18
|
+
// This is used for testing on CI.
|
19
|
+
ifdef::env-test[]
|
20
|
+
:stem: latexmath
|
21
|
+
stem:[E = mc^2]
|
22
|
+
endif::env-test[]
|
18
23
|
|
19
24
|
This project provides an http://asciidoctor.org/[Asciidoctor] extension for converting block and inline https://asciidoctor.org/docs/user-manual/#activating-stem-support[STEM] in TeX notation (latexmath) to HTML using https://khan.github.io/KaTeX[KaTeX] library right during document conversion (instead of in browser on client-side).
|
20
25
|
|
@@ -26,7 +31,7 @@ ifndef::npm-readme[]
|
|
26
31
|
|
27
32
|
* https://www.ruby-lang.org/[Ruby] 2.3+ or http://jruby.org/[JRuby] 9.1+
|
28
33
|
* https://rubygems.org/gems/asciidoctor/[Asciidoctor] 1.5.6+
|
29
|
-
* https://rubygems.org/gems/katex[katex (gem)] 0.
|
34
|
+
* https://rubygems.org/gems/katex[katex (gem)] ~> 0.8.0
|
30
35
|
* JavaScript engine supported by https://github.com/rails/execjs#execjs[ExecJS]
|
31
36
|
* https://rubygems.org/gems/thread_safe/[thread_safe] (not required, but recommended for Ruby MRI)
|
32
37
|
|
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.9.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
|
-
treeprocessor Asciidoctor::Katex::Treeprocessor
|
11
|
+
treeprocessor Asciidoctor::Katex::Treeprocessor.new
|
12
|
+
postprocessor Asciidoctor::Katex::Postprocessor.new
|
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.1
|
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: 2023-02-08 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.9.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.9.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
|