kramdown-math-ritex 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 45d4bea0ecf12e9a4b50a5b7be1de16e08affa90173ac9b895cf7ae34817fdd8
4
+ data.tar.gz: bb5202f2214e2fb6b5e50b84ee821249a579cc6df5460cb4a834c54a9e1b6bc3
5
+ SHA512:
6
+ metadata.gz: 87af4d9c98215365beb88da4ff82947111e7a698e182f61d58fc30b6a4bb945e3df523003d92381062f9d7e3199cd9ca87b735642dda2e8b8d4f1843affebc88
7
+ data.tar.gz: cc809c3b9ab7553ae66f8e16f34870c59573d6b139ca71f93a8593a44206b0f03cdae4572d38b385f3a038b368845d6bae359492bf016045d92944598f115999
@@ -0,0 +1,3 @@
1
+ Count Name
2
+ ======= ====
3
+ 1 Thomas Leitner <t_leitner@gmx.at>
data/COPYING ADDED
@@ -0,0 +1,21 @@
1
+ kramdown-math-ritex
2
+ Copyright (C) 2019 Thomas Leitner <t_leitner@gmx.at>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a
5
+ copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included
13
+ in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,10 @@
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown-math-ritex which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'kramdown/converter/math_engine/ritex'
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown-math-ritex which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'kramdown/converter'
11
+ require 'ritex'
12
+
13
+ module Kramdown::Converter #:nodoc:
14
+ module MathEngine #:nodoc
15
+
16
+ # Uses the Ritex library for converting math formulas to MathML.
17
+ module Ritex
18
+
19
+ VERSION = '1.0.0'
20
+
21
+ def self.call(converter, el, opts)
22
+ type = el.options[:category]
23
+ result = ::Ritex::Parser.new.parse(el.value, display: (type == :block))
24
+
25
+ attr = el.attr.dup
26
+ attr.delete('xmlns')
27
+ attr.delete('display')
28
+ result.insert("<math".length, converter.html_attributes(attr))
29
+
30
+ (type == :block ? "#{' ' * opts[:indent]}#{result}\n" : result)
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
37
+ add_math_engine(:ritex, MathEngine::Ritex)
38
+
39
+ end
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown-math-ritex which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'minitest/autorun'
11
+ require 'kramdown'
12
+ require 'kramdown-math-ritex'
13
+ require 'yaml'
14
+ require 'tmpdir'
15
+
16
+ Encoding.default_external = 'utf-8'
17
+
18
+ class TestFiles < Minitest::Test
19
+
20
+ Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
21
+ basename = text_file.sub(/\.text$/, '')
22
+
23
+ html_file = basename + '.html'
24
+ define_method('test_' + text_file.tr('.', '_') + "_to_html") do
25
+ opts_file = basename + '.options'
26
+ opts_file = File.join(File.dirname(html_file), 'options') if !File.exist?(opts_file)
27
+ options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1}
28
+ doc = Kramdown::Document.new(File.read(text_file), options)
29
+ assert_equal(File.read(html_file), doc.to_html)
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1 @@
1
+ <p>This is <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mi>f</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo><mo>=</mo><mi>a</mi><mrow><msup><mi>x</mi><mn>3</mn></msup></mrow><mo>+</mo><mi>b</mi><mrow><msup><mi>x</mi><mn>2</mn></msup></mrow><mo>+</mo><mi>c</mi><mi>x</mi><mo>+</mo><mi>d</mi></math> something!</p>
@@ -0,0 +1 @@
1
+ :math_engine: ritex
@@ -0,0 +1 @@
1
+ This is $$f(x) = a{x^3} + b{x^2} + cx + d$$ something!
@@ -0,0 +1 @@
1
+ <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>f</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo><mo>=</mo><mi>a</mi><mrow><msup><mi>x</mi><mn>3</mn></msup></mrow><mo>+</mo><mi>b</mi><mrow><msup><mi>x</mi><mn>2</mn></msup></mrow><mo>+</mo><mi>c</mi><mi>x</mi><mo>+</mo><mi>d</mi></math>
@@ -0,0 +1 @@
1
+ :math_engine: ritex
@@ -0,0 +1 @@
1
+ $$f(x) = a{x^3} + b{x^2} + cx + d$$
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kramdown-math-ritex
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Leitner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kramdown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ritex
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description:
42
+ email: t_leitner@gmx.at
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - CONTRIBUTERS
48
+ - COPYING
49
+ - VERSION
50
+ - lib/kramdown-math-ritex.rb
51
+ - lib/kramdown/converter/math_engine/ritex.rb
52
+ - test/test_files.rb
53
+ - test/testcases/ritex-span.html
54
+ - test/testcases/ritex-span.options
55
+ - test/testcases/ritex-span.text
56
+ - test/testcases/ritex.html
57
+ - test/testcases/ritex.options
58
+ - test/testcases/ritex.text
59
+ homepage: https://github.com/kramdown/math-ritex
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '2.3'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.7.3
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: kramdown-math-ritex uses ritex to convert math elements to MathML
83
+ test_files: []