texd 0.2.0 → 0.2.1
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 +4 -4
- data/Gemfile.lock +1 -1
- data/gemfiles/rails-6.0.lock +1 -1
- data/gemfiles/rails-6.1.lock +1 -1
- data/gemfiles/rails-7.0.lock +1 -1
- data/lib/texd/document.rb +6 -6
- data/lib/texd/helpers.rb +3 -2
- data/lib/texd/version.rb +1 -1
- data/lib/texd.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c54956eeb977294ed946d8f961d16c15e41eff3eca556d31787174c07852de97
|
4
|
+
data.tar.gz: cd603c3d2e9af5b04c43a8c0f9e542fddd18b815a5a01c3d8483f3729b8dd9f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 979a9503f9e4c38817d0c54b42c0ae288592819a65d0db1bd9ccf0dcaad81005d27842f35b49fc9b7869bfbb8563817e5e447413a865499d93993b95e0749081
|
7
|
+
data.tar.gz: a9d55ce2394c5bf940360ef4f11c7524c50149a0989da9a4c62ee186ecf6fddfcdba695a753ae9f20db20d55720179acecb4e9f5d6f08cc4dab4ec1f8850a81d
|
data/Gemfile.lock
CHANGED
data/gemfiles/rails-6.0.lock
CHANGED
data/gemfiles/rails-6.1.lock
CHANGED
data/gemfiles/rails-7.0.lock
CHANGED
data/lib/texd/document.rb
CHANGED
@@ -18,16 +18,16 @@ module Texd
|
|
18
18
|
# Compile converts templates into TeX sources and collects file
|
19
19
|
# references (created with `texd_attach` and `texd_reference` helpers).
|
20
20
|
#
|
21
|
-
# @param
|
22
|
-
#
|
21
|
+
# @param [String] template name of template file in ActionView's lookup
|
22
|
+
# context.
|
23
|
+
# @param [Hash, nil] locals will be made available as getter methods in
|
24
|
+
# the template.
|
23
25
|
# @return [Compilation]
|
24
|
-
def compile(
|
25
|
-
locals = args.last.delete(:locals) if args.last.is_a?(Hash)
|
26
|
+
def compile(template:, locals: {})
|
26
27
|
helper_mod = ::Texd.helpers(attachments, locals)
|
27
|
-
|
28
28
|
tex_source = Class.new(ApplicationController) {
|
29
29
|
helper helper_mod
|
30
|
-
}.render(
|
30
|
+
}.render(template: template, format: :tex)
|
31
31
|
|
32
32
|
main = attachments.main_input(tex_source)
|
33
33
|
Compilation.new(main.name, attachments)
|
data/lib/texd/helpers.rb
CHANGED
@@ -28,8 +28,9 @@ module Texd
|
|
28
28
|
|
29
29
|
# Escapes the given text, making it safe for use in TeX documents.
|
30
30
|
def escape(text, line_break = "\\\\\\", typographic: true)
|
31
|
-
|
32
|
-
|
31
|
+
return "" if text.blank?
|
32
|
+
|
33
|
+
text.to_s.dup.tap do |str|
|
33
34
|
str.gsub!(ESCAPE_RE) do |m|
|
34
35
|
if Regexp.last_match(1)
|
35
36
|
"\\#{m}"
|
data/lib/texd/version.rb
CHANGED
data/lib/texd.rb
CHANGED
@@ -94,8 +94,8 @@ module Texd
|
|
94
94
|
# Render compiles a template, uploads the files to the texd instance,
|
95
95
|
# and returns the PDF.
|
96
96
|
#
|
97
|
-
# The arguments are directly forwarded to
|
98
|
-
#
|
97
|
+
# The arguments are directly forwarded to Texd::Document (and end up in
|
98
|
+
# ActionView::Renderer#render).
|
99
99
|
#
|
100
100
|
# @example Render app/views/document/document.tex.erb
|
101
101
|
# begin
|
@@ -114,12 +114,16 @@ module Texd
|
|
114
114
|
# # something went wrong before we even got to sent data to the server
|
115
115
|
# end
|
116
116
|
#
|
117
|
+
# @param [String] template name of template file in ActionView's lookup
|
118
|
+
# context.
|
119
|
+
# @param [Hash, nil] locals will be made available as getter methods in
|
120
|
+
# the template.
|
117
121
|
# @raise [Texd::Client::ResponseError] on input and queue errors. Also on
|
118
122
|
# compilation errors, if Texd.config.error_format is set to JSON.
|
119
123
|
# @raise [Texd::Error] on other Texd related errors.
|
120
124
|
# @return [String] the PDF object
|
121
|
-
def render(
|
122
|
-
doc = Document.compile(
|
125
|
+
def render(template:, locals: {})
|
126
|
+
doc = Document.compile(template: template, locals: locals)
|
123
127
|
|
124
128
|
client.render doc.to_upload_ios,
|
125
129
|
input: doc.main_input_name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: texd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Menke
|
@@ -140,7 +140,7 @@ metadata:
|
|
140
140
|
rubygems_mfa_required: 'true'
|
141
141
|
homepage_uri: https://github.com/digineo/texd-ruby
|
142
142
|
source_code_uri: https://github.com/digineo/texd-ruby
|
143
|
-
changelog_uri: https://github.com/digineo/texd-ruby/blob/v0.2.
|
143
|
+
changelog_uri: https://github.com/digineo/texd-ruby/blob/v0.2.1/CHANGELOG.md
|
144
144
|
post_install_message:
|
145
145
|
rdoc_options: []
|
146
146
|
require_paths:
|