jekyll-latex-converter 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ac357170119e671e09d15eca16818ca26d11cb5b
4
+ data.tar.gz: 3c145da65ac1d9c6904f1071bacc879ec5a54aa3
5
+ SHA512:
6
+ metadata.gz: 0473d33e72115b0b7e36a23998a5eb7a13020ba29d33d08925ed7a386a40cc8a2022ed14084813623bdbfd6b9f6731372e031ccf9f55a3ad7d45fb59b6f53b5f
7
+ data.tar.gz: 932c01e5eecbe6faa8424177a6564ea10a274bf8a9a631ac2e793a5ca65be5879b4bb8821f6aff205811e227dc7f3e3599203c990b7764d36abedb7a7a3607a2
@@ -0,0 +1,6 @@
1
+ -
2
+ title: Simple build
3
+ build: true
4
+ -
5
+ title: Compare build
6
+ compare: _expected _site
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ spec/source/_site
16
+ log/
17
+ .highlight_cache
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ sudo: false
7
+ cache: bundler
8
+ before_script: bundle update
9
+ script: script/cibuild
10
+ notifications:
11
+ email: false
12
+ env:
13
+ - JEKYLL_VERSION=tip
14
+ - JEKYLL_VERSION=3.0
15
+ - JEKYLL_VERSION=2.0
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-latex-converter.gemspec
4
+ gemspec
5
+
6
+ gem "clash", "~> 1.0"
7
+
8
+ if ENV["JEKYLL_VERSION"]
9
+ if ENV["JEKYLL_VERSION"].eql?("tip")
10
+ gem "jekyll", github: "jekyll/jekyll", branch: ENV["JEKYLL_BRANCH"]
11
+ else
12
+ gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}"
13
+ end
14
+ else
15
+ gem "jekyll", ">= 2.0"
16
+ end
@@ -0,0 +1,7 @@
1
+ ## 0.1.0 / 2014-01-17
2
+
3
+ * First working iteration.
4
+
5
+ ## 0.0.1 / 2014-01-17
6
+
7
+ * Birthday!
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Parker Moore, 2017 Michael Hartl
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # Jekyll::Latex::Converter
2
+
3
+ Use LaTeX with Jekyll.
4
+
5
+ Supports all LaTeX syntax supported by [PolyTeXnic](https://github.com/softcover/polytexnic). For Jekyll 3.0 and up.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'jekyll-latex-converter'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install jekyll-latex-converter
22
+
23
+ Lastly, add it to your `_config.yml` file:
24
+
25
+ gems:
26
+ - jekyll-latex-converter
27
+
28
+ ## Usage
29
+
30
+ Create files with the `.tex` extension in the `_posts` directory, as in
31
+
32
+ `_posts/2017-07-12-test-post.tex`:
33
+
34
+ ```
35
+ ---
36
+ layout: post
37
+ title: "Welcome to Jekyll 3"
38
+ categories: jekyll update
39
+ published: true
40
+ ---
41
+
42
+
43
+ This is a \emph{LaTeX} file.
44
+ ```
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll-latex-converter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-latex-converter"
8
+ spec.version = Jekyll::LatexConverter::VERSION
9
+ spec.authors = ["Parker Moore"]
10
+ spec.email = ["parkrmoore@gmail.com"]
11
+ spec.summary = %q{Latex converter for Jekyll.}
12
+ spec.homepage = "https://github.com/jekyll/jekyll-latex-converter"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "RedCloth", "~> 4.0"
21
+ spec.add_runtime_dependency "polytexnic", "~> 1.3"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ end
@@ -0,0 +1,12 @@
1
+ require 'jekyll'
2
+
3
+ root = File.expand_path('jekyll-latex-converter', File.dirname(__FILE__))
4
+ require "#{root}/filters"
5
+ require "#{root}/version"
6
+
7
+ require File.expand_path('jekyll/converters/latex', File.dirname(__FILE__))
8
+
9
+ module Jekyll
10
+ module LatexConverter
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ module Jekyll
2
+ module Filters
3
+ # Convert a Latex string into HTML output.
4
+ #
5
+ # input - The Latex String to convert.
6
+ #
7
+ # Returns the HTML formatted String.
8
+ def latexify(input)
9
+ site = @context.registers[:site]
10
+ converter = if site.respond_to?(:find_converter_instance)
11
+ site.find_converter_instance(Jekyll::Converters::Latex)
12
+ else
13
+ site.getConverterImpl(Jekyll::Converters::Latex)
14
+ end
15
+ converter.convert(input)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module LatexConverter
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,43 @@
1
+ module Jekyll
2
+ module Converters
3
+ class Latex < Converter
4
+ safe true
5
+
6
+ DEFAULT_CONFIGURATION = {
7
+ 'latex_ext' => 'tex',
8
+ }
9
+
10
+ def initialize(config = {})
11
+ @config = Jekyll::Utils.deep_merge_hashes(DEFAULT_CONFIGURATION, config)
12
+ @setup = false
13
+ end
14
+
15
+ def setup
16
+ return if @setup
17
+ require 'polytexnic'
18
+ @setup = true
19
+ rescue LoadError
20
+ STDERR.puts 'You are missing a library required for Latex. Please run:'
21
+ STDERR.puts ' $ [sudo] gem install polytexnic'
22
+ raise Errors::FatalException.new("Missing dependency: polytexnic")
23
+ end
24
+
25
+ def extname_list
26
+ @extname_list ||= @config['latex_ext'].split(',').map { |e| ".#{e}" }
27
+ end
28
+
29
+ def matches(ext)
30
+ extname_list.include? ext.downcase
31
+ end
32
+
33
+ def output_ext(ext)
34
+ ".html"
35
+ end
36
+
37
+ def convert(content)
38
+ setup
39
+ return Polytexnic::Pipeline.new(content, article: true).to_html
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle install -j8 $@
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ script/test $@ && script/clash
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle exec clash spec/source
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle exec rspec --color --require spec_helper $@
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ RSpec.describe(Jekyll::Converters::Latex) do
4
+ let(:converter) { described_class.new }
5
+
6
+ context "minimal example" do
7
+ it "converts LaTeX to HTML" do
8
+ expect(converter.convert("\\emph{yo}").strip).to eq("<p><em>yo</em>\n</p>")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ RSpec.describe(Jekyll::Filters) do
4
+ class JekyllFilter
5
+ include Jekyll::Filters
6
+ attr_accessor :site, :context
7
+
8
+ def initialize(opts = {})
9
+ @site = Jekyll::Site.new(Jekyll::Configuration::DEFAULTS)
10
+ @context = Liquid::Context.new({}, {}, { :site => @site })
11
+ end
12
+ end
13
+
14
+ let(:filter) { JekyllFilter.new }
15
+ let(:latex) { "something \\textbf{really} simple" }
16
+ let(:html) { "<p>something <strong>really</strong> simple\n</p>" }
17
+
18
+ it "should convert latex" do
19
+ expect(filter.latexify(latex)).to eq(html)
20
+ end
21
+ end
@@ -0,0 +1,2 @@
1
+ gems:
2
+ - jekyll-latex-converter
@@ -0,0 +1,3 @@
1
+ <h2>a post about latex</h2>
2
+ <p>line 1<br />
3
+ line 2</p>
@@ -0,0 +1,3 @@
1
+ <h1>Testing the textilize filter</h1>
2
+
3
+ <p>this is a paragraph</p>
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: My latex post
3
+ ---
4
+
5
+ h2. a post about latex
6
+
7
+ p. line 1
8
+ line 2
@@ -0,0 +1,6 @@
1
+ ---
2
+ ---
3
+
4
+ <h1>Testing the textilize filter</h1>
5
+
6
+ {{ "p. this is a paragraph" | latexify }}
@@ -0,0 +1,25 @@
1
+ require 'jekyll'
2
+ require File.expand_path('../../lib/jekyll-latex-converter', __FILE__)
3
+
4
+ RSpec.configure do |config|
5
+ config.expect_with :rspec do |expectations|
6
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+
13
+ config.filter_run :focus
14
+ config.run_all_when_everything_filtered = true
15
+ config.disable_monkey_patching!
16
+
17
+ config.warnings = false
18
+ if config.files_to_run.one?
19
+ config.default_formatter = 'doc'
20
+ end
21
+
22
+ config.profile_examples = 2
23
+ config.order = :random
24
+ Kernel.srand config.seed
25
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-latex-converter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Parker Moore
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: RedCloth
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: polytexnic
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description:
84
+ email:
85
+ - parkrmoore@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".clash.yml"
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - History.markdown
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - jekyll-latex-converter.gemspec
99
+ - lib/jekyll-latex-converter.rb
100
+ - lib/jekyll-latex-converter/filters.rb
101
+ - lib/jekyll-latex-converter/version.rb
102
+ - lib/jekyll/converters/latex.rb
103
+ - script/bootstrap
104
+ - script/cibuild
105
+ - script/clash
106
+ - script/test
107
+ - spec/latex_converter_spec.rb
108
+ - spec/latexify_filter_spec.rb
109
+ - spec/source/_config.yml
110
+ - spec/source/_expected/2015/01/17/my-textile-post.html
111
+ - spec/source/_expected/index.html
112
+ - spec/source/_posts/2015-01-17-my-textile-post.textile
113
+ - spec/source/index.html
114
+ - spec/spec_helper.rb
115
+ homepage: https://github.com/jekyll/jekyll-latex-converter
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.4.5.1
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Latex converter for Jekyll.
139
+ test_files:
140
+ - spec/latex_converter_spec.rb
141
+ - spec/latexify_filter_spec.rb
142
+ - spec/source/_config.yml
143
+ - spec/source/_expected/2015/01/17/my-textile-post.html
144
+ - spec/source/_expected/index.html
145
+ - spec/source/_posts/2015-01-17-my-textile-post.textile
146
+ - spec/source/index.html
147
+ - spec/spec_helper.rb