katex_on_rails 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3872cf936c63cb11367add5f9ad324663ed9bc83d023e55e342af3859658faa5
4
+ data.tar.gz: 9fd09a1fa1aea8f3ccad7aca1c2ef3dc6e97040a877979caaaf45d733af3a04b
5
+ SHA512:
6
+ metadata.gz: cdeb03ab1ee3ce3dc1f5a7d7a5fac02a75068877092e43e148d5e3fb27705fccf58e2a935c68810487e151f10937b8f6cc510f4178cf274f9e1781281ac61735
7
+ data.tar.gz: 7582d254885462db762459c9d4bbda3635b1a35dd699d250fb2e00c28dd37b9e409ed29f7d5d238e271173c7d889a094ddfac84fe4933c42b06e130431739a23
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2025-06-28)
4
+
5
+ - Add `render_to_string` method.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Juraj Kostolanský
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # KaTeX on Rails
2
+
3
+ Convert LaTeX math formulas to HTML using KaTeX in Rails.
4
+
5
+ KaTeX on Rails uses [Nodo](https://github.com/mtgrosser/nodo)
6
+ to call the [KaTex](https://katex.org) Node.js package.
7
+
8
+ ## Installation
9
+
10
+ Add the KaTeX on Rails gem:
11
+
12
+ ```sh
13
+ bundle add katex_on_rails
14
+ ```
15
+
16
+ Or add this line to your Gemfile manually:
17
+
18
+ ```ruby
19
+ gem 'katex_on_rails'
20
+ ```
21
+
22
+ Install the `katex` package with `npm`:
23
+
24
+ ```sh
25
+ npm install katex
26
+ ```
27
+
28
+ Or with `yarn`:
29
+ ```sh
30
+ yarn add katex
31
+ ```
32
+
33
+ To render any HTML generated by this gem, you will need to link the CSS file
34
+ from the `katex` Node.js package, make the KaTeX font files available to the client,
35
+ and use the HTML5 doctype. See [browser usage](https://katex.org/docs/browser).
36
+ Note, however, that you do not need to include `katex.js` on the client.
37
+
38
+ ## Usage
39
+
40
+ ```ruby
41
+ katex = KatexOnRails.new
42
+
43
+ katex.render_to_string('x', { output: 'html' })
44
+ #=> "<span class=\"katex\">..."
45
+ ```
46
+
47
+ The last argument to `render_to_string` can contain a [variety of rendering options](https://katex.org/docs/options).
48
+
49
+ ## License
50
+
51
+ The KaTeX on Rails gem is is released under the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/katex_on_rails/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'katex_on_rails'
7
+ spec.version = KatexOnRails::VERSION
8
+ spec.authors = ['Juraj Kostolansky']
9
+ spec.email = ['juraj@kostolansky.sk']
10
+
11
+ spec.summary = 'Convert LaTeX math formulas to HTML using KaTeX in Rails.'
12
+ spec.homepage = 'https://github.com/jkostolansky/katex_on_rails'
13
+ spec.license = 'MIT'
14
+
15
+ spec.metadata = {
16
+ 'homepage_uri' => 'https://github.com/jkostolansky/katex_on_rails',
17
+ 'source_code_uri' => 'https://github.com/jkostolansky/katex_on_rails',
18
+ 'changelog_uri' => 'https://github.com/jkostolansky/katex_on_rails/blob/main/CHANGELOG.md',
19
+ 'rubygems_mfa_required' => 'true'
20
+ }
21
+
22
+ spec.files = Dir['README.md', 'LICENSE.txt', 'CHANGELOG.md', 'katex_on_rails.gemspec', 'lib/**/*.rb']
23
+
24
+ spec.required_ruby_version = '>= 3.2.0'
25
+ spec.add_dependency 'nodo', '>= 1.8.0'
26
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'nodo'
4
+
5
+ class KatexOnRails
6
+ class Package < ::Nodo::Core
7
+ require :katex
8
+
9
+ function :render_to_string, code: <<~JS
10
+ (text, options) => {
11
+ return katex.renderToString(text, options);
12
+ }
13
+ JS
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class KatexOnRails
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'katex_on_rails/version'
4
+ require 'katex_on_rails/package'
5
+
6
+ class KatexOnRails
7
+ def render_to_string(text, options = {})
8
+ katex_package.render_to_string(text, options)
9
+ end
10
+
11
+ private
12
+
13
+ def katex_package
14
+ @katex_package ||= Package.new
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: katex_on_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Juraj Kostolansky
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-06-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nodo
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.0
27
+ description:
28
+ email:
29
+ - juraj@kostolansky.sk
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - CHANGELOG.md
35
+ - LICENSE.txt
36
+ - README.md
37
+ - katex_on_rails.gemspec
38
+ - lib/katex_on_rails.rb
39
+ - lib/katex_on_rails/package.rb
40
+ - lib/katex_on_rails/version.rb
41
+ homepage: https://github.com/jkostolansky/katex_on_rails
42
+ licenses:
43
+ - MIT
44
+ metadata:
45
+ homepage_uri: https://github.com/jkostolansky/katex_on_rails
46
+ source_code_uri: https://github.com/jkostolansky/katex_on_rails
47
+ changelog_uri: https://github.com/jkostolansky/katex_on_rails/blob/main/CHANGELOG.md
48
+ rubygems_mfa_required: 'true'
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 3.2.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.4.19
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Convert LaTeX math formulas to HTML using KaTeX in Rails.
68
+ test_files: []