octopress-tex2img 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/octopress-tex2img.rb +19 -0
- data/lib/octopress-tex2img/tags.rb +43 -0
- data/lib/octopress-tex2img/version.rb +3 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 806258a82f4f85512aa7017e8ee68d772c777625
|
4
|
+
data.tar.gz: 8c0dcd7e490e2e4cd80ba295cc47ef9d45714292
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ebd8381f9f598ad08c57b507f07c96f74208cc849de55ce2c26c3d189adf0e45e8a67632a1eea96b31324da62ce58ed3109f14dfa8a62f3874cef3333c58d78
|
7
|
+
data.tar.gz: d1c5bd04f126aaaf72b48bed130691afe23e0aeb84812112aaa1c31875b846647bfc3e1b03efd5ad0b1dd61d865f20c309599b98aff62da2bcb8a0d858c8866a
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Wang Jian
|
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.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# OctopressTex2img
|
2
|
+
|
3
|
+
An octopress ink plugin generating png img from tex source and insert it into markdown posts.
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/wantee/octopress-tex2img.svg)](https://travis-ci.org/wantee/octopress-tex2img)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/octopress-tex2img.svg)](http://badge.fury.io/rb/octopress-tex2img)
|
7
|
+
[![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/wantee/octopress-tex2img/blob/master/LICENSE.txt)
|
8
|
+
|
9
|
+
## Prerequisites
|
10
|
+
* TeX Live 2013
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'octopress-tex2img'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install octopress-tex2img
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
```
|
31
|
+
{% tex2img path_to_tex_file args-to-img-tag %}
|
32
|
+
```
|
33
|
+
|
34
|
+
For example,
|
35
|
+
|
36
|
+
```
|
37
|
+
{% tex2img misc/test.tex center /assets/miscs/test.png "fig:test" title:"Test tex figure" %}
|
38
|
+
```
|
39
|
+
|
40
|
+
`octopress-tex2img` will generate png file from tex file, and replace the `tex2img` tag to an `img` tag at the current position.
|
41
|
+
|
42
|
+
## Development
|
43
|
+
|
44
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
|
+
|
46
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it ( https://github.com/wantee/octopress-tex2img/fork )
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create a new Pull Request
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "octopress_tex2img"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'octopress-tex2img/version'
|
2
|
+
require 'octopress-ink'
|
3
|
+
|
4
|
+
module OctopressTex2img
|
5
|
+
autoload :Tags, 'octopress-tex2img/tags'
|
6
|
+
end
|
7
|
+
|
8
|
+
Liquid::Template.register_tag('tex2img', OctopressTex2img::Tags)
|
9
|
+
|
10
|
+
Octopress::Ink.add_plugin({
|
11
|
+
name: "Octopress Tex2img",
|
12
|
+
slug: "octopress-tex2img",
|
13
|
+
gem: "octopress-tex2img",
|
14
|
+
path: File.expand_path(File.join(File.dirname(__FILE__), "..")),
|
15
|
+
version: OctopressTex2img::VERSION,
|
16
|
+
description: "Generate image from tex source file and insert into markdown",
|
17
|
+
source_url: "https://github.com/wantee/octopress-tex2img",
|
18
|
+
website: "https://github.com/wantee/octopress-tex2img"
|
19
|
+
})
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# tex2img
|
2
|
+
#
|
3
|
+
# usage {% tex2img path_to_tex args-to-img-tag %}
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'octopress-image-tag'
|
7
|
+
|
8
|
+
module OctopressTex2img
|
9
|
+
class Tags < Liquid::Tag
|
10
|
+
def initialize(tag_name, markup, tokens)
|
11
|
+
super
|
12
|
+
@texpath, *params = markup.strip.split(/\s/)
|
13
|
+
if !File.exists?(@texpath)
|
14
|
+
raise ArgumentError.new("texfile[#{@texpath}] does not exist!")
|
15
|
+
end
|
16
|
+
@imgtag = Octopress::Tags::ImageTag::Tag.new(tag_name, params.join(" "), tokens)
|
17
|
+
end
|
18
|
+
|
19
|
+
def render(context)
|
20
|
+
attributes = @imgtag.image(context)
|
21
|
+
site = context.registers[:site]
|
22
|
+
pngpath = File.join(site.source, attributes['src'])
|
23
|
+
@texpath = File.join(site.source, @texpath)
|
24
|
+
|
25
|
+
if !File.exists?(pngpath) || File.stat(@texpath).mtime > File.stat(pngpath).mtime
|
26
|
+
puts "Generating #{pngpath} from #{@texpath}"
|
27
|
+
texdir = File.dirname(@texpath)
|
28
|
+
pngdir = File.dirname(pngpath)
|
29
|
+
FileUtils.mkdir_p(pngdir)
|
30
|
+
base = @texpath.sub(/.tex$/, '')
|
31
|
+
pdf = @texpath.sub(/.tex$/, '.pdf')
|
32
|
+
system "xelatex -output-directory=#{texdir} --interaction=nonstopmode #{base} >/dev/null"
|
33
|
+
system "convert -density 300 #{pdf} -quality 90 #{pngpath}"
|
34
|
+
|
35
|
+
FileUtils.rm_f("#{base}.aux")
|
36
|
+
FileUtils.rm_f("#{base}.log")
|
37
|
+
FileUtils.rm_f("#{base}.pdf")
|
38
|
+
end
|
39
|
+
@imgtag.render(context)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: octopress-tex2img
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wang Jian
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: clash
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: octopress-ink
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: octopress-image-tag
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.1.0
|
83
|
+
description: Generate image from tex source file and insert into markdown.
|
84
|
+
email:
|
85
|
+
- wantee.wang@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- CHANGELOG.md
|
91
|
+
- LICENSE.txt
|
92
|
+
- README.md
|
93
|
+
- bin/console
|
94
|
+
- bin/setup
|
95
|
+
- lib/octopress-tex2img.rb
|
96
|
+
- lib/octopress-tex2img/tags.rb
|
97
|
+
- lib/octopress-tex2img/version.rb
|
98
|
+
homepage: https://github.com/wantee/octopress-tex2img
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.4.5
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: Generate image from tex source file and insert into markdown.
|
122
|
+
test_files: []
|