octopress-printable 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91fb6d106d970a5a5590f95ba6329f6c9849c830
4
- data.tar.gz: 11ea287af9b0d96a2f1bda2b01ad93a360fa72d3
3
+ metadata.gz: dabc42f1f81dc131009d8dda9e5e1deac6d849f8
4
+ data.tar.gz: 05667df60b06ef89ff8d4139d40189a45f85861f
5
5
  SHA512:
6
- metadata.gz: 154bd8b518bd0a8716b107ceb8e8f33a6c6cefbd5483fe6be608c17cbe0af858a36e1690da5c294ec319eb50ff880ead30dfb4a592201f88dd5615f7a089ff88
7
- data.tar.gz: 8254fc3bda5acd4e14e3fc2714719f1d6aa8112318974fd624e23cfa1a5f693dbb0b66ab39abbcd6d6b9bc42713bbe727de43138c17d983e2dcc7f9e9ac1a62a
6
+ metadata.gz: 65e5649dbd86fd3507bc245ccacaab7a2db8bfee4a35f1ac452af53cb504bbe7900c994b82e345f6e0da4e9cb4e689fa6c830bfd41c422b62cbd09758cbbe2d4
7
+ data.tar.gz: 40454e9b7907db985cf607df3109c16b6c076900be4d780dd1026a255660737c244dfb9fc5129217e1e18e2c09964d6d7ac74cf55739dd948104c621414cc1ca
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.3 - 2015-07-29
4
+ - Add 'tex2img' support
5
+
3
6
  ## 0.1.2 - 2015-05-30
4
7
  - Add 'noprintable' config to yaml front matter
5
8
 
@@ -16,7 +16,7 @@ module Octopress
16
16
  if /{% img (?<markup>.*) %}/ =~ str
17
17
  @match = true
18
18
 
19
- img = get_img_label(markup)
19
+ img = ImgConverter.get_img_label(markup)
20
20
  str="\\begin{figure}[h]\\centering\\includegraphics[width=\\textwidth]{#{@source_dir}/#{img['src']}}\\caption{#{img['title']}}\\label{#{img['alt']}}\\end{figure}"
21
21
  end
22
22
 
@@ -24,7 +24,7 @@ module Octopress
24
24
  end
25
25
 
26
26
  # from octopress-image-tag plugin
27
- def get_img_label(markup)
27
+ def self.get_img_label(markup)
28
28
  title = markup.scan(TITLE_REGEX).flatten.compact.last
29
29
  markup.gsub!(TITLE_REGEX, '')
30
30
 
@@ -8,6 +8,7 @@ module Octopress
8
8
  autoload :GistConverter, 'octopress-printable/gist'
9
9
  autoload :PostLinkConverter, 'octopress-printable/post_link'
10
10
  autoload :LatexConverter, 'octopress-printable/latex'
11
+ autoload :Tex2imgConverter, 'octopress-printable/tex2img'
11
12
 
12
13
  class Plugin < Ink::Plugin
13
14
 
@@ -74,6 +75,8 @@ module Octopress
74
75
  converters << math
75
76
  img = ImgConverter.new(source_dir)
76
77
  converters << img
78
+ tex2img = Tex2imgConverter.new(source_dir)
79
+ converters << tex2img
77
80
  bib = BibConverter.new("#{source_dir}/#{bib_dir}/#{bib_file}",
78
81
  "#{pdfdir}/#{bib_file}")
79
82
  converters << bib
@@ -0,0 +1,46 @@
1
+ require 'octopress-printable/img'
2
+
3
+ module Octopress
4
+ module Printable
5
+ class Tex2imgConverter < Converter
6
+
7
+ TITLE_REGEX = /title:['|"](.+?)['|"]/
8
+
9
+ def initialize(source_dir)
10
+ super()
11
+
12
+ @source_dir = source_dir
13
+ @headers = []
14
+ end
15
+
16
+ def convert(line)
17
+ str = line
18
+
19
+ if /{% tex2img (?<markup>.*) %}/ =~ str
20
+ @match = true
21
+
22
+ @texpath, *params = markup.strip.split(/\s/)
23
+ @texpath = File.join(@source_dir, @texpath)
24
+ if !File.exists?(@texpath)
25
+ raise ArgumentError.new("texfile[#{@texpath}] does not exist!")
26
+ end
27
+
28
+ img = Octopress::Printable::ImgConverter.get_img_label(params.join(" "))
29
+ str="\\begin{figure}[h]\\centering\\input{#{@texpath}}\\caption{#{img['title']}}\\label{#{img['alt']}}\\end{figure}"
30
+
31
+ @headers += open(@texpath) { |f| f.grep(/\\usepackage/) }
32
+ end
33
+
34
+ str
35
+ end
36
+
37
+ def header
38
+ @headers << '\\usepackage{standalone}'
39
+ @headers << '\\usepackage{tikz}'
40
+ @headers.each {|a| a.strip!if a.respond_to? :strip! }
41
+ @headers.uniq!
42
+ end
43
+ end
44
+ end
45
+ end
46
+
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Printable
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-printable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wang Jian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-30 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: octopress-ink
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.1.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.1.2
69
69
  - !ruby/object:Gem::Dependency
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: octopress-tex2img
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: jekyll-gist
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -147,6 +161,7 @@ files:
147
161
  - lib/octopress-printable/plugin.rb
148
162
  - lib/octopress-printable/post_link.rb
149
163
  - lib/octopress-printable/tags.rb
164
+ - lib/octopress-printable/tex2img.rb
150
165
  - lib/octopress-printable/version.rb
151
166
  homepage: https://github.com/wantee/octopress-printable
152
167
  licenses: