jekyll-asciimath 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.adoc +5 -0
- data/LICENSE.txt +21 -0
- data/README.adoc +100 -0
- data/develop/release +41 -0
- data/jekyll-asciimath.gemspec +21 -0
- data/lib/jekyll-asciimath.rb +1 -0
- data/lib/jekyll_asciimath/jekyll_asciimath.rb +38 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3e9b8cf3a6a1d6136d911e0bbd9cc4b9447fd332eae240c82696a52ff4941ee2
|
4
|
+
data.tar.gz: 95b5ffe13981239048b7d323b7897662ee4ddcaa9615e61af460a79714524c11
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8100dcec170c83500d3aeff55322701f637f5ee7f2834ab0799cb4bd56c59f685da415f118420fa69b40d87e7758965f1d93e7854fdc7fb34570db3fda211b47
|
7
|
+
data.tar.gz: bf51be49b8684d3a43a566384f37c55c9bc29ed429d2c3448bac52fe0856385fff6375bbf7930b5782c292dcebf3ef30de6732ed846894576bb4af67f575595b
|
data/CHANGELOG.adoc
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Ribose
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.adoc
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
= AsciiMath plugin for Jekyll
|
2
|
+
|
3
|
+
== `asciimath` filter
|
4
|
+
|
5
|
+
When applied to a variable, replaces AsciiMath markup between specified delimiters
|
6
|
+
with HTML.
|
7
|
+
|
8
|
+
For example, Liquid markup like this:
|
9
|
+
|
10
|
+
[source,liquid]
|
11
|
+
--
|
12
|
+
{% assign some_variable = "$$m$$ out of $$n$$ redundancy" %}
|
13
|
+
{{ some_variable | asciimath }}
|
14
|
+
--
|
15
|
+
|
16
|
+
would be rendered into this
|
17
|
+
(but without whitespace, which is added for legibility):
|
18
|
+
|
19
|
+
[source,html]
|
20
|
+
--
|
21
|
+
<span class="math-inline">
|
22
|
+
<span class="math-row">
|
23
|
+
<span class="math-identifier">m</span>
|
24
|
+
</span>
|
25
|
+
</span>
|
26
|
+
|
27
|
+
out of
|
28
|
+
|
29
|
+
<span class="math-inline">
|
30
|
+
<span class="math-row">
|
31
|
+
<span class="math-identifier">n</span>
|
32
|
+
</span>
|
33
|
+
</span>
|
34
|
+
|
35
|
+
redundancy
|
36
|
+
--
|
37
|
+
|
38
|
+
== How it works
|
39
|
+
|
40
|
+
This plugin uses https://github.com/asciidoctor/asciimath for converting AsciiMath into HTML,
|
41
|
+
and a crude regular expression for extracting AsciiMath markup from a mass of text
|
42
|
+
based on delimiters.
|
43
|
+
|
44
|
+
== Configuration
|
45
|
+
|
46
|
+
The plugin will work without any site configuration keys,
|
47
|
+
but it requires you to include AsciiMath styling CSS in your template
|
48
|
+
and to pay attention to the default delimiter setting (see below).
|
49
|
+
|
50
|
+
=== Delimiter
|
51
|
+
|
52
|
+
Currently, only one delimiter is supported
|
53
|
+
(i.e., opening delimiter must be the same as trailing delimiter).
|
54
|
+
|
55
|
+
Configure the delimiter for use with `asciimath` filters in your site config
|
56
|
+
as follows:
|
57
|
+
|
58
|
+
[source,yaml]
|
59
|
+
--
|
60
|
+
asciimath_delimiter: $$
|
61
|
+
--
|
62
|
+
|
63
|
+
The default delimiter is `$$`.
|
64
|
+
|
65
|
+
NOTE: Delimiter will be passed to Ruby’s `Regexp.quote()`,
|
66
|
+
so there’s no need to quote special characters.
|
67
|
+
|
68
|
+
=== Styling
|
69
|
+
|
70
|
+
For the HTML output of `asciimath` filter to be rendered correctly,
|
71
|
+
you have to include the relevant CSS.
|
72
|
+
|
73
|
+
The plugin automatically copies the CSS file from the `asciimath` gem
|
74
|
+
distribution into the assets directory of your site output.
|
75
|
+
|
76
|
+
To change the path to CSS, specify the `asciimath_css_dir` option:
|
77
|
+
|
78
|
+
[source,yaml]
|
79
|
+
--
|
80
|
+
asciimath_css_path: assets/math.css
|
81
|
+
--
|
82
|
+
|
83
|
+
To disable this behavior, set that variable to empty string.
|
84
|
+
|
85
|
+
The default path is `assets/math.css`.
|
86
|
+
|
87
|
+
[IMPORTANT]
|
88
|
+
====
|
89
|
+
The plugin will only copy the CSS file, but it will not
|
90
|
+
include it your website’s source.
|
91
|
+
Add the relevant `<link>` in your template like this:
|
92
|
+
|
93
|
+
[source,html]
|
94
|
+
--
|
95
|
+
<head>
|
96
|
+
<!-- ...other markup... -->
|
97
|
+
<link href="{{ "/assets/math.css" | relative_url }}" />
|
98
|
+
</head>
|
99
|
+
--
|
100
|
+
====
|
data/develop/release
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Tag and push a release.
|
3
|
+
|
4
|
+
set -e
|
5
|
+
|
6
|
+
# Make sure we're in the project root.
|
7
|
+
|
8
|
+
cd $(dirname "$0")/..
|
9
|
+
|
10
|
+
# Make sure the darn thing works? Meh.
|
11
|
+
# bundle update
|
12
|
+
|
13
|
+
# Build a new gem archive.
|
14
|
+
|
15
|
+
rm -rf jekyll-asciimath-*.gem
|
16
|
+
gem build -q jekyll-asciimath.gemspec
|
17
|
+
|
18
|
+
# Make sure we're on the master branch.
|
19
|
+
|
20
|
+
(git branch | grep -q 'master') || {
|
21
|
+
echo "Only release from the master branch."
|
22
|
+
exit 1
|
23
|
+
}
|
24
|
+
|
25
|
+
# Figure out what version we're releasing.
|
26
|
+
|
27
|
+
tag=v`ls jekyll-asciimath-*.gem | sed 's/^jekyll-asciimath-\(.*\)\.gem$/\1/'`
|
28
|
+
|
29
|
+
# Make sure we haven't released this version before.
|
30
|
+
|
31
|
+
git fetch -t origin
|
32
|
+
|
33
|
+
(git tag -l | grep -q "$tag") && {
|
34
|
+
echo "Whoops, there's already a '${tag}' tag."
|
35
|
+
exit 1
|
36
|
+
}
|
37
|
+
|
38
|
+
# Tag it and bag it.
|
39
|
+
|
40
|
+
gem push jekyll-asciimath-*.gem && git tag "$tag" &&
|
41
|
+
git push origin master && git push origin "$tag"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'jekyll-asciimath'
|
5
|
+
s.version = '1.0.0'
|
6
|
+
s.authors = ['Ribose Inc.']
|
7
|
+
s.email = ['open.source@ribose.com']
|
8
|
+
|
9
|
+
s.summary = 'AsciiMath plugin for Jekyll'
|
10
|
+
s.homepage = 'https://github.com/riboseinc/jekyll-asciimath/'
|
11
|
+
s.license = 'MIT'
|
12
|
+
|
13
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
|
14
|
+
|
15
|
+
s.add_runtime_dependency 'jekyll', '~> 4.0'
|
16
|
+
s.add_runtime_dependency 'asciimath', '~> 1.0.9'
|
17
|
+
s.add_development_dependency 'rake', '~> 12.0'
|
18
|
+
s.add_development_dependency 'rubocop', '~> 0.50'
|
19
|
+
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'jekyll_asciimath/jekyll_asciimath'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "asciimath"
|
2
|
+
|
3
|
+
|
4
|
+
$ASCIIMATH_CSS = File.join(Gem::Specification.find_by_name("asciimath").gem_dir, "style", "math.css")
|
5
|
+
|
6
|
+
|
7
|
+
Jekyll::Hooks.register :site, :post_write do |site|
|
8
|
+
site_asciimath_css_path = site.config['asciimath_css_path'] || 'assets/math.css'
|
9
|
+
target = File.join(site.config['destination'] || '_site', site_asciimath_css_path)
|
10
|
+
system("cp #{$ASCIIMATH_CSS} #{target}")
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
module Jekyll::AsciiMathFilter
|
15
|
+
def asciimath(input)
|
16
|
+
delimiter = @context.registers[:site].config['asciimath_delimiter'] || '$$'
|
17
|
+
delim_regex = Regexp.quote(delimiter)
|
18
|
+
asciimath_regex = Regexp.new("(?<=#{delim_regex})[^#{delim_regex}]+(?=#{delim_regex})")
|
19
|
+
|
20
|
+
if input.scan(asciimath_regex).size > 0
|
21
|
+
pieces = "#{delimiter} #{input} #{delimiter}".scan(asciimath_regex)
|
22
|
+
parsed_pieces = []
|
23
|
+
|
24
|
+
pieces.each_with_index { |piece, idx|
|
25
|
+
if idx.odd?
|
26
|
+
parsed_pieces << AsciiMath.parse(piece).to_html
|
27
|
+
elsif piece != ' '
|
28
|
+
parsed_pieces << piece
|
29
|
+
end
|
30
|
+
}
|
31
|
+
return parsed_pieces.join('')
|
32
|
+
else
|
33
|
+
return input
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Liquid::Template.register_filter(Jekyll::AsciiMathFilter)
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-asciimath
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ribose Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: asciimath
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.9
|
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.9
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.50'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.50'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- open.source@ribose.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- CHANGELOG.adoc
|
77
|
+
- LICENSE.txt
|
78
|
+
- README.adoc
|
79
|
+
- develop/release
|
80
|
+
- jekyll-asciimath.gemspec
|
81
|
+
- lib/jekyll-asciimath.rb
|
82
|
+
- lib/jekyll_asciimath/jekyll_asciimath.rb
|
83
|
+
homepage: https://github.com/riboseinc/jekyll-asciimath/
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubygems_version: 3.0.3
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: AsciiMath plugin for Jekyll
|
106
|
+
test_files: []
|