thredded-markdown_katex 0.2.0 → 0.3.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
- SHA1:
3
- metadata.gz: 4049c976b9da68b8a080bcf3ddb6356cb4de8168
4
- data.tar.gz: 7c3d7083093f31e7a56b26175e429c4d41e65a63
2
+ SHA256:
3
+ metadata.gz: 21a7c92e13f578a469ac74e789a5d5dfa11ad69969049a418b5570f33e7618c3
4
+ data.tar.gz: 794c513519dbf70f68a219c785a6bceadf460f8e69751b4a4331acfdfa792461
5
5
  SHA512:
6
- metadata.gz: 2a07a5b670d90505c618a973270a0a1ae57c5f35ae468dc129dd2d65cc3a00232927e13041aa28e7f13022c8c5ff54dd3edeacf17caa86507beb7948d3492e88
7
- data.tar.gz: a4e06c91dad0ba06ff9261dc887ba1dee7ca83ed10d0db2a30db3583a84196597d02b44c5e6370d67fc0e3abe93d6344f9fb80ee812c3ab86d271a70420e59b6
6
+ metadata.gz: 89b6cf98ec81b8eeac25fcc92f5c45d35b19e6d7969db5cf7628c7220f248a85ebaf7703789a1e00be57c6e92abddaab650b53731a4f3a42708a132540b6e252
7
+ data.tar.gz: 00e742742c0be5ee20a79733b645ab16e40d031bb5e2e6af6182c8ae9b63c4453929a138fc45ea6028f8fcce4d98f1186d20f24a75ab49726dc531742f8c5ee6
@@ -22,7 +22,10 @@ module Thredded
22
22
 
23
23
  def setup! # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
24
24
  if pipeline_contains?(KRAMDOWN_FILTER_CLASS_NAME)
25
- require 'thredded/markdown_katex/kramdown/katex_converter'
25
+ # KaTeX engine for versions of Kramdown that do not have it built-in:
26
+ if Gem::Version.new(Kramdown::VERSION) < Gem::Version.new('1.17.0')
27
+ require 'thredded/markdown_katex/kramdown/katex_converter'
28
+ end
26
29
  Thredded::HtmlPipeline::KramdownFilter.options.update(options)
27
30
  else
28
31
  raise "#{self.class.name} requires #{KRAMDOWN_FILTER_CLASS_NAME} " \
@@ -1,25 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # KaTeX support for Kramdown < v1.17.0 (newer versions have built-in support).
4
+
3
5
  module Thredded
4
6
  module MarkdownKatex
5
7
  module Kramdown
6
8
  # The KaTeX converter engine for Kramdown.
7
9
  module KatexConverter
8
- def self.call(_converter, el, _opts)
9
- type = el.options[:category]
10
- Katex.render(
11
- el.value, display_mode: type == :block, throw_on_error: false
10
+ # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
11
+
12
+ def self.call(converter, el, opts)
13
+ display_mode = el.options[:category] == :block
14
+ result = ::Katex.render(
15
+ el.value,
16
+ display_mode: display_mode,
17
+ throw_on_error: false,
18
+ **converter.options[:math_engine_opts]
12
19
  )
20
+ attr = el.attr.dup
21
+ attr.delete('xmlns')
22
+ attr.delete('display')
23
+ result
24
+ .insert(result =~ /[[:space:]>]/, converter.html_attributes(attr))
25
+ result = "#{' ' * opts[:indent]}#{result}\n" if display_mode
26
+ result
13
27
  end
28
+ # rubocop:enable Metrics/AbcSize,Metrics/MethodLength
14
29
  end
15
30
  end
16
31
  end
17
32
  end
18
33
 
19
34
  require 'kramdown/converter'
20
- Kramdown::Converter.module_eval do
21
- add_math_engine :katex do |converter, el, opts|
22
- add_math_engine(:katex, ::Thredded::MarkdownKatex::Kramdown::KatexConverter)
23
- math_engine(:katex).call(converter, el, opts)
24
- end
25
- end
35
+ Kramdown::Converter
36
+ .add_math_engine(:katex, ::Thredded::MarkdownKatex::Kramdown::KatexConverter)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Thredded
4
4
  module MarkdownKatex
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thredded-markdown_katex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Mazovetskiy
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-01 00:00:00.000000000 Z
11
+ date: 2018-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katex
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.1
19
+ version: 0.4.3
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: 0.1.1
27
- - !ruby/object:Gem::Dependency
28
- name: thredded
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 0.11.0
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 0.11.0
26
+ version: 0.4.3
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +94,20 @@ dependencies:
108
94
  - - ">="
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: thredded
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 0.11.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.11.0
111
111
  description: Adds TeX math support to Thredded markup via KaTeX.
112
112
  email:
113
113
  - glex.spb@gmail.com
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  requirements: []
148
148
  rubyforge_project:
149
- rubygems_version: 2.6.12
149
+ rubygems_version: 2.7.6
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: Adds TeX math support to Thredded markup via KaTeX.