kramdown-math-itex2mml 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2c0defb82e360ccc1fae276cb3549a8f9c50236460d0fb03408d375dd9e3b4e1
4
+ data.tar.gz: 25393f17f7dd1c75351c687bbd9df0bbd9ffa109b300f41444b200121b62376d
5
+ SHA512:
6
+ metadata.gz: 92fae054d7a5e215d7ed47d71c2b770ff738b1e74c0850784434cfe077999d6a767c5d6420733cc4e26eaa742e49c5ab593ba66b9f52a869649b465112120da4
7
+ data.tar.gz: fa027999e398115c91938ccae78ab0c67ef13e0241fbe36f600d3cdcb7f434bc2c1d8ce584411453caaa6a1151173c3f0000c630327cedd1efb538d3e194242f
@@ -0,0 +1,3 @@
1
+ Count Name
2
+ ======= ====
3
+ 2 Thomas Leitner <t_leitner@gmx.at>
data/COPYING ADDED
@@ -0,0 +1,21 @@
1
+ kramdown-math-itex2mml
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-itex2mml which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'kramdown/converter/math_engine/itex2mml'
@@ -0,0 +1,40 @@
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-itex2mml which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'kramdown/converter'
11
+ require 'itextomml'
12
+
13
+ module Kramdown::Converter #:nodoc:
14
+ module MathEngine #:nodoc
15
+
16
+ # Uses the Itex2MML library for converting math formulas to MathML.
17
+ module Itex2MML
18
+
19
+ VERSION = '1.0.0'
20
+
21
+ def self.call(converter, el, opts)
22
+ type = el.options[:category]
23
+ parser = ::Itex2MML::Parser.new
24
+ result = (type == :block ? parser.block_filter(el.value) : parser.inline_filter(el.value))
25
+
26
+ attr = el.attr.dup
27
+ attr.delete('xmlns')
28
+ attr.delete('display')
29
+ result.insert("<math".length, converter.html_attributes(attr))
30
+
31
+ (type == :block ? "#{' ' * opts[:indent]}#{result}\n" : result)
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+ add_math_engine(:itex2mml, MathEngine::Itex2MML)
39
+
40
+ 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-parser-gfm which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'minitest/autorun'
11
+ require 'kramdown'
12
+ require 'kramdown-math-itex2mml'
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'><semantics><mrow><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>cx</mi><mo>+</mo><mi>d</mi></mrow><annotation encoding='application/x-tex'>f(x) = a{x^3} + b{x^2} + cx + d</annotation></semantics></math> something!</p>
@@ -0,0 +1 @@
1
+ :math_engine: itex2mml
@@ -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'><semantics><mrow><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>cx</mi><mo>+</mo><mi>d</mi></mrow><annotation encoding='application/x-tex'>f(x) = a{x^3} + b{x^2} + cx + d</annotation></semantics></math>
@@ -0,0 +1 @@
1
+ :math_engine: itex2mml
@@ -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-itex2mml
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: itextomml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
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-itex2mml.rb
51
+ - lib/kramdown/converter/math_engine/itex2mml.rb
52
+ - test/test_files.rb
53
+ - test/testcases/itex2mml-span.html
54
+ - test/testcases/itex2mml-span.options
55
+ - test/testcases/itex2mml-span.text
56
+ - test/testcases/itex2mml.html
57
+ - test/testcases/itex2mml.options
58
+ - test/testcases/itex2mml.text
59
+ homepage: https://github.com/kramdown/math-itex2mml
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-itex2mml uses itex2mml to convert math elements to MathML
83
+ test_files: []