jekyll-t4j 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/lib/jekyll-t4j/engine/dvisvgm.rb +27 -23
- data/lib/jekyll-t4j/engine/katex.js +1 -18798
- data/lib/jekyll-t4j/engine/katex.mhchem.js +1 -0
- data/lib/jekyll-t4j/engine/katex.rb +30 -8
- data/lib/jekyll-t4j/engine.rb +83 -81
- data/lib/jekyll-t4j/merger.rb +2 -2
- data/lib/jekyll-t4j/renderer.rb +9 -8
- data/lib/jekyll-t4j/snippet.rb +42 -0
- data/lib/jekyll-t4j/version.rb +1 -1
- data/lib/jekyll-t4j.rb +7 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08b199ca229a735a5862598c3833f1ca8c4643db6458fb24e1575604df8196aa'
|
4
|
+
data.tar.gz: aeb6470ab96afd7e12008946f568804c36fb44d42350cec3d5d3f20728b86401
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eff915fbdffe8b6942226ef1dcfc39068fd89d5fd6fc51469844b7793af7804304f41249a5f02e11d2427fc8b9d5fc44c51bd6641ec449f112daaeb0e3e15a18
|
7
|
+
data.tar.gz: 5e6f3859887cca6604359dcc8341279f18b50d877815f87d7dc14e0310219c70a9b51d572c2ce1df1dc7b83aaad823a0745400859520e9e7ceeb9593d26fda4e
|
data/README.md
CHANGED
@@ -3,13 +3,16 @@
|
|
3
3
|
jekyll-t4j is a Jekyll plugin providing (nearly) full support of LaTeX.
|
4
4
|
|
5
5
|
- **Comprehensive**: support almost all packages, including tikz, chemfig, etc.
|
6
|
-
- **
|
6
|
+
- **Highly optimized**: employ KaTeX to boost speed. Use cache, precompiled preamble, bulk rendering.
|
7
7
|
- **Server side rendering**: all stuffs are done in server.
|
8
8
|
|
9
|
-
T4J integrates Jekyll with your local TeX distribution, so you need to have either [MikTeX](https://miktex.org/) or [
|
9
|
+
T4J integrates Jekyll with your local TeX distribution, so you need to have either [MikTeX](https://miktex.org/) or [TeX Live](https://tug.org/texlive/) installed.
|
10
10
|
|
11
11
|
Feel free to write any LaTeX! 🎉
|
12
12
|
|
13
|
+
> **Warning**
|
14
|
+
> T4J now is in rapid development, it's pretty unstable. So don't forget to check and update frequently.
|
15
|
+
|
13
16
|
## Getting Started
|
14
17
|
|
15
18
|
Let's start by a simple instance, write a post `2023-02-04-hello-latex.md` and fill it with:
|
@@ -44,7 +47,7 @@ You can learn more about T4J [here](https://github.com/crow02531/jekyll-t4j/wiki
|
|
44
47
|
|
45
48
|
## Installation
|
46
49
|
|
47
|
-
First of all, you need to have a TeX distribution. Just download and install [MikTeX](https://miktex.org/) or [
|
50
|
+
First of all, you need to have a TeX distribution. Just download and install [MikTeX](https://miktex.org/) or [TeX Live](https://tug.org/texlive/). Other TeX distirbution is also available.
|
48
51
|
|
49
52
|
Then, install jekyll-t4j like other Jekyll plugins. Add this line to your application's Gemfile:
|
50
53
|
|
@@ -1,48 +1,52 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "tmpdir"
|
4
|
-
require "open3"
|
5
4
|
|
6
5
|
module Jekyll::T4J
|
7
6
|
module Engine
|
8
|
-
@@
|
7
|
+
@@_pwd_fmt_ = nil
|
8
|
+
|
9
|
+
def self.setup_dvisvgm
|
10
|
+
if not @@_pwd_fmt_ then
|
11
|
+
@@_pwd_fmt_ = Dir.mktmpdir
|
12
|
+
at_exit {FileUtils.remove_entry @@_pwd_fmt_}
|
13
|
+
|
14
|
+
# write 'preamble.tex'
|
15
|
+
File.write "#{@@_pwd_fmt_}/preamble.tex", <<~HD
|
16
|
+
\\documentclass{article}
|
17
|
+
#{Jekyll::T4J.cfg_pkgs}
|
18
|
+
\\input{#{File.join(__dir__, "dvisvgm.tex")}}
|
19
|
+
\\pagenumbering{gobble}
|
20
|
+
\\dump
|
21
|
+
HD
|
22
|
+
|
23
|
+
# call 'latex' to precompile
|
24
|
+
shell("latex -ini -halt-on-error -jobname=\"preamble\" \"&latex preamble\"", @@_pwd_fmt_)
|
25
|
+
end
|
26
|
+
end
|
9
27
|
|
10
28
|
def self.dvisvgm_raw(snippet)
|
11
29
|
dvisvgm_raw_bulk([snippet])[0]
|
12
30
|
end
|
13
31
|
|
14
32
|
def self.dvisvgm_raw_bulk(snippets)
|
15
|
-
#
|
33
|
+
# create 'content.tex'
|
16
34
|
pwd = Dir.mktmpdir
|
17
|
-
File.write "#{pwd}/content.tex", <<~
|
18
|
-
\\documentclass{article}
|
19
|
-
#{Jekyll::T4J.cfg_pkgs}
|
20
|
-
\\input{#{@@_dvisvgm_tex_}}
|
35
|
+
File.write "#{pwd}/content.tex", <<~HD
|
21
36
|
\\begin{document}
|
22
|
-
\\pagenumbering{gobble}
|
23
37
|
\\begingroup#{snippets.join("\\endgroup\\newpage\\begingroup")}\\endgroup
|
24
38
|
\\end{document}
|
25
|
-
|
26
|
-
|
27
|
-
shell = ->(cmd) {
|
28
|
-
log, s = Open3.capture2e(cmd, :chdir => pwd)
|
29
|
-
raise log if not s.success?
|
30
|
-
}
|
39
|
+
HD
|
31
40
|
|
32
41
|
# call 'latex' to compile: tex->dvi
|
33
|
-
shell
|
34
|
-
shell.("latex -halt-on-error -quiet content")
|
42
|
+
shell("latex --fmt=\"#{File.join(@@_pwd_fmt_, "preamble.fmt")}\" -halt-on-error content", pwd, 2)
|
35
43
|
# call 'dvisvgm' to convert dvi to svg(s)
|
36
|
-
shell
|
44
|
+
shell("dvisvgm -n -e -p 1- -o %1p content", pwd)
|
37
45
|
|
38
46
|
# fetch results
|
39
47
|
results = []
|
40
|
-
|
41
|
-
results << File.read("#{pwd}
|
42
|
-
else
|
43
|
-
for i in 1..snippets.size
|
44
|
-
results << File.read("#{pwd}/content-#{i.to_s}.svg")
|
45
|
-
end
|
48
|
+
for i in 1..snippets.size
|
49
|
+
results << File.read("#{pwd}/#{i.to_s}.svg")
|
46
50
|
end
|
47
51
|
|
48
52
|
# return
|