jekyll-latex 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c51ba008fc363dfda516e407905588cfc7b1c4af
4
+ data.tar.gz: 13db30468bfee12f145cd1d85645c4e2e3aa5ca4
5
+ SHA512:
6
+ metadata.gz: 9df7617563c7dd1991e9045680dfb0ab8c814b20920eb51deccf767314c43f709abbe5a7b16f2ffefc9bff17db7cd7f1b17b375184f961c03585170fa96b875a
7
+ data.tar.gz: c4a87adaab3706d57b8c66cea0c1e38d5f579fcd7d945ddcc93c0adf24c4896ab428bd225da6535461d5bd6e37d225ac34359a52c70f65fb5d9fb36761a92475
data/.clash.yml ADDED
@@ -0,0 +1,6 @@
1
+ -
2
+ title: Simple build
3
+ build: true
4
+ -
5
+ title: Compare build
6
+ compare: _expected _site
data/.gitignore ADDED
@@ -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
data/.travis.yml ADDED
@@ -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.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
data/History.markdown ADDED
@@ -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!
data/LICENSE.txt ADDED
@@ -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.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Jekyll::Latex
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'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install jekyll-latex
22
+
23
+ Lastly, add it to your `_config.yml` file:
24
+
25
+ gems:
26
+ - jekyll-latex
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
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,25 @@
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/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-latex"
8
+ spec.version = Jekyll::Latex::VERSION
9
+ spec.authors = ["Michael Hartl"]
10
+ spec.email = ["michael@michaelhartl.com"]
11
+ spec.summary = %q{Latex converter for Jekyll.}
12
+ spec.homepage = "https://github.com/mhartl/jekyll-latex"
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 "polytexnic", "~> 1.3"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
@@ -0,0 +1,12 @@
1
+ require 'jekyll'
2
+
3
+ root = File.expand_path('jekyll-latex', 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 Latex
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
data/script/bootstrap ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle install -j8 $@
data/script/cibuild ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ script/test $@ && script/clash
data/script/clash ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle exec clash spec/source
data/script/test ADDED
@@ -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
@@ -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', __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,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-latex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Hartl
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: polytexnic
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description:
70
+ email:
71
+ - michael@michaelhartl.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".clash.yml"
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - History.markdown
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - jekyll-latex.gemspec
85
+ - lib/jekyll-latex.rb
86
+ - lib/jekyll-latex/filters.rb
87
+ - lib/jekyll-latex/version.rb
88
+ - lib/jekyll/converters/latex.rb
89
+ - script/bootstrap
90
+ - script/cibuild
91
+ - script/clash
92
+ - script/test
93
+ - spec/latex_converter_spec.rb
94
+ - spec/latexify_filter_spec.rb
95
+ - spec/source/_config.yml
96
+ - spec/source/_expected/2015/01/17/my-textile-post.html
97
+ - spec/source/_expected/index.html
98
+ - spec/source/_posts/2015-01-17-my-textile-post.textile
99
+ - spec/source/index.html
100
+ - spec/spec_helper.rb
101
+ homepage: https://github.com/mhartl/jekyll-latex
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.5.1
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Latex converter for Jekyll.
125
+ test_files:
126
+ - spec/latex_converter_spec.rb
127
+ - spec/latexify_filter_spec.rb
128
+ - spec/source/_config.yml
129
+ - spec/source/_expected/2015/01/17/my-textile-post.html
130
+ - spec/source/_expected/index.html
131
+ - spec/source/_posts/2015-01-17-my-textile-post.textile
132
+ - spec/source/index.html
133
+ - spec/spec_helper.rb