erbtex 0.4.3 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da849bbae335cabdeb22f9817d5408660b1d37ed1036eba721ce8bdace2668f2
4
- data.tar.gz: 4e933a21dfa948f00151d1cd695f425dfb17aec6f1ac1d940dd68d32799229d6
3
+ metadata.gz: 3179adcaec913bc339bb060c141e5da4604bb6ada70ccd471caa4527f823ef79
4
+ data.tar.gz: c6b139085386bfdf38fbe914da41b4dded9027711207add89d163e413958bbd2
5
5
  SHA512:
6
- metadata.gz: b1cf7577a154c728e92b44d555e464b62ff714ddcccad23744f1d5dc0b53ddcbc88d43e31698aecc2a1b4494bcf0660e1677c42c70998bcc76da743a5aa893c5
7
- data.tar.gz: '051332985184a47f5515dda043d598bf835488d0d812dd753e9ec05cdaafdeebf51279bfdc1fb7307b97ac8155d3007f8572340175ec1148bc80a13d2fee557c'
6
+ metadata.gz: 103fc70c8f1a6d9ed3672029ca68893765caa5be28353f0319cca22c849f2b347adfc7bddeade3326b38aa4c09c0f5a9440ce18af63dcf6917cb3349cdb8af23
7
+ data.tar.gz: 5d2486e2c2862dbc45f3c880db50dcf4181d9e09a5fb0e3d4e38d2b351007725d8fd4824eee200674e8f5260c42ad0e2848ad9766fa90faba042cac5f166784e
data/.bundle/config CHANGED
@@ -1,2 +1,2 @@
1
1
  ---
2
- BUNDLE_BIN: .bundle/bin
2
+ BUNDLE_BIN: ".bundle/bin"
data/.envrc ADDED
@@ -0,0 +1,2 @@
1
+ PATH_add .bundle/bin
2
+ PATH_add ./scripts
data/.gitignore CHANGED
@@ -8,3 +8,5 @@ auto
8
8
  /.bundle/bin
9
9
  *.fdb_latexmk
10
10
  *.fls
11
+ *.erb
12
+ *.etx
data/.rubocop.yml ADDED
@@ -0,0 +1,41 @@
1
+ inherit_gem:
2
+ rubocop-ddoherty: 'config/default.yml'
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 3.3
6
+ Include:
7
+ - 'lib/**/*'
8
+ - 'bin/**/*'
9
+ - 'spec/**/*'
10
+ - 'features/**/*'
11
+ Exclude:
12
+ - 'spec/tmp/**/*'
13
+ - 'lib/byr/reports/**/*'
14
+ - 'home/**/*'
15
+ - 'db/**/*'
16
+ - 'scripts/**/*'
17
+ - '**/*.erb'
18
+ - '**/*.tex'
19
+ - 'app/**/*'
20
+ - '**/*.txt'
21
+ - '**/*.org'
22
+ - '**/*~'
23
+ - '.simplecov'
24
+ - 'spec/files_fmv/**/*'
25
+ - 'spec/files_compl/**/*'
26
+ - 'spec/files_ofx/**/*'
27
+ - 'features/**/*'
28
+
29
+ RSpec/MultipleMemoizedHelpers:
30
+ Max: 13
31
+
32
+ Style/RaiseArgs:
33
+ AllowedCompactTypes:
34
+ - InventoryError
35
+
36
+ RSpec/SpecFilePathFormat:
37
+ CustomTransform:
38
+ ErbTeX: erbtex
39
+
40
+ RSpec/SpecFilePathFormat:
41
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,55 @@
1
+ - [Changelog](#org4ada267)
2
+ - [0.5.0](#org648c2b1)
3
+ - [Added](#org3f264b0)
4
+ - [Changed](#org85d4411)
5
+ - [Fixed](#org953170b)
6
+ - [Documentation](#orgc5f25f9)
7
+
8
+
9
+ <a id="org4ada267"></a>
10
+
11
+ # Changelog
12
+
13
+
14
+ <a id="org648c2b1"></a>
15
+
16
+ ## 0.5.0
17
+
18
+
19
+ <a id="org3f264b0"></a>
20
+
21
+ ### Added
22
+
23
+ - `--preprocess-only` generates the preprocessed file without invoking TeX.
24
+ - `--no-clobber` refuses to overwrite any existing preprocessed output file.
25
+ - Generated output starts with an identifying TeX comment.
26
+
27
+
28
+ <a id="org85d4411"></a>
29
+
30
+ ### Changed
31
+
32
+ - Existing output is overwritten only when its first line is the erbtex generated-file marker. Otherwise erbtex warns and exits unsuccessfully before executing the template or invoking TeX. Output from earlier versions has no marker and must be inspected before moving, deleting, or marking it for subsequent overwrites.
33
+ - Output is rendered before writing and replaced atomically through a temporary file beside the destination. Failed rendering preserves existing output.
34
+ - Library methods return exit status codes or raise exceptions instead of terminating the calling process. The executable handles process exits.
35
+ - Template syntax errors and runtime backtraces identify the input filename.
36
+
37
+
38
+ <a id="org953170b"></a>
39
+
40
+ ### Fixed
41
+
42
+ - TeX invocation preserves argument boundaries, repeated spaces, empty arguments, and literal shell characters without shell interpretation.
43
+ - Input filenames precede trailing TeX commands, and fileless TeX invocations work.
44
+ - `--invoke=` accepts complete executable names and paths, including spaces and hyphens, and rejects an empty executable name.
45
+ - `--help` and `--version` match exactly and exit successfully after printing.
46
+ - TeX failure exit codes propagate to the executable's caller.
47
+ - Running erbtex without arguments prints usage instead of raising an error.
48
+
49
+
50
+ <a id="orgc5f25f9"></a>
51
+
52
+ ### Documentation
53
+
54
+ - Documented preprocessing options, overwrite protection, and handling of output generated by older versions.
55
+ - Documented that files referenced by `\input` and `\include` are not preprocessed automatically, with a `--preprocess-only` workaround.
data/CHANGELOG.org ADDED
@@ -0,0 +1,37 @@
1
+ * Changelog
2
+ ** 0.5.0
3
+ *** Added
4
+
5
+ - ~--preprocess-only~ generates the preprocessed file without invoking TeX.
6
+ - ~--no-clobber~ refuses to overwrite any existing preprocessed output file.
7
+ - Generated output starts with an identifying TeX comment.
8
+
9
+ *** Changed
10
+ - Existing output is overwritten only when its first line is the erbtex
11
+ generated-file marker. Otherwise erbtex warns and exits unsuccessfully
12
+ before executing the template or invoking TeX. Output from earlier
13
+ versions has no marker and must be inspected before moving, deleting,
14
+ or marking it for subsequent overwrites.
15
+ - Output is rendered before writing and replaced atomically through a
16
+ temporary file beside the destination. Failed rendering preserves
17
+ existing output.
18
+ - Library methods return exit status codes or raise exceptions instead of
19
+ terminating the calling process. The executable handles process exits.
20
+ - Template syntax errors and runtime backtraces identify the input filename.
21
+
22
+ *** Fixed
23
+ - TeX invocation preserves argument boundaries, repeated spaces, empty
24
+ arguments, and literal shell characters without shell interpretation.
25
+ - Input filenames precede trailing TeX commands, and fileless TeX
26
+ invocations work.
27
+ - ~--invoke=~ accepts complete executable names and paths, including spaces
28
+ and hyphens, and rejects an empty executable name.
29
+ - ~--help~ and ~--version~ match exactly and exit successfully after printing.
30
+ - TeX failure exit codes propagate to the executable's caller.
31
+ - Running erbtex without arguments prints usage instead of raising an error.
32
+
33
+ *** Documentation
34
+ - Documented preprocessing options, overwrite protection, and handling of
35
+ output generated by older versions.
36
+ - Documented that files referenced by ~\input~ and ~\include~ are not
37
+ preprocessed automatically, with a ~--preprocess-only~ workaround.
data/Gemfile CHANGED
@@ -1,3 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
6
+
7
+ gem 'debug'
8
+ gem 'gem_docs', '~> 0.3.1', require: false
9
+ gem 'rake', '~> 13.0'
10
+ gem 'rspec', '~> 3.0'
11
+ gem 'rubocop-ddoherty', git: 'https://github.com/ddoherty03/rubocop-ddoherty.git', branch: 'master', require: false
data/Gemfile.lock CHANGED
@@ -1,71 +1,159 @@
1
+ GIT
2
+ remote: https://github.com/ddoherty03/rubocop-ddoherty.git
3
+ revision: 6b28e9614f18f94b684179c488acca8ac6cabdc6
4
+ branch: master
5
+ specs:
6
+ rubocop-ddoherty (0.1.2)
7
+ rubocop-performance (~> 1.0)
8
+ rubocop-rake (>= 0.7)
9
+ rubocop-rspec (~> 3.0)
10
+ rubocop-shopify (~> 2.0)
11
+
1
12
  PATH
2
13
  remote: .
3
14
  specs:
4
- erbtex (0.4.3)
15
+ erbtex (0.5.0)
5
16
  erubis
6
17
  fat_core
7
18
 
8
19
  GEM
9
20
  remote: https://rubygems.org/
10
21
  specs:
11
- activesupport (5.2.3)
12
- concurrent-ruby (~> 1.0, >= 1.0.2)
13
- i18n (>= 0.7, < 2)
14
- minitest (~> 5.1)
15
- tzinfo (~> 1.1)
16
- byebug (11.0.1)
17
- coderay (1.1.2)
18
- concurrent-ruby (1.1.5)
19
- damerau-levenshtein (1.3.1)
20
- diff-lcs (1.3)
22
+ activesupport (8.1.4)
23
+ base64
24
+ bigdecimal
25
+ concurrent-ruby (~> 1.0, >= 1.3.1)
26
+ connection_pool (>= 2.2.5)
27
+ drb
28
+ i18n (>= 1.6, < 2)
29
+ json
30
+ logger (>= 1.4.2)
31
+ minitest (>= 5.1)
32
+ securerandom (>= 0.3)
33
+ tzinfo (~> 2.0, >= 2.0.5)
34
+ uri (>= 0.13.1)
35
+ ast (2.4.3)
36
+ base64 (0.3.0)
37
+ bigdecimal (4.1.3)
38
+ byebug (11.1.3)
39
+ coderay (1.1.3)
40
+ concurrent-ruby (1.3.8)
41
+ connection_pool (3.0.2)
42
+ damerau-levenshtein (1.3.3)
43
+ debug (1.9.2)
44
+ irb (~> 1.10)
45
+ reline (>= 0.3.8)
46
+ diff-lcs (1.4.4)
47
+ drb (2.2.3)
21
48
  erubis (2.7.0)
22
- fat_core (4.6.0)
49
+ fat_core (5.4.0)
23
50
  activesupport
24
51
  damerau-levenshtein
25
- i18n (1.6.0)
52
+ gem_docs (0.3.1)
53
+ rake
54
+ yard
55
+ i18n (1.15.2)
26
56
  concurrent-ruby (~> 1.0)
27
- method_source (0.9.2)
28
- minitest (5.11.3)
29
- pry (0.12.2)
30
- coderay (~> 1.1.0)
31
- method_source (~> 0.9.0)
32
- pry-byebug (3.7.0)
57
+ io-console (0.7.2)
58
+ irb (1.14.0)
59
+ rdoc (>= 4.0.0)
60
+ reline (>= 0.4.2)
61
+ json (3.1.0)
62
+ language_server-protocol (3.17.0.6)
63
+ lint_roller (1.1.0)
64
+ logger (1.7.0)
65
+ method_source (1.0.0)
66
+ minitest (5.14.3)
67
+ parallel (2.3.0)
68
+ parser (3.3.12.0)
69
+ ast (~> 2.4.1)
70
+ racc
71
+ prism (1.9.0)
72
+ pry (0.13.1)
73
+ coderay (~> 1.1)
74
+ method_source (~> 1.0)
75
+ pry-byebug (3.9.0)
33
76
  byebug (~> 11.0)
34
- pry (~> 0.10)
35
- pry-doc (1.0.0)
77
+ pry (~> 0.13.0)
78
+ pry-doc (1.1.0)
36
79
  pry (~> 0.11)
37
80
  yard (~> 0.9.11)
38
- rake (12.3.2)
39
- rspec (3.8.0)
40
- rspec-core (~> 3.8.0)
41
- rspec-expectations (~> 3.8.0)
42
- rspec-mocks (~> 3.8.0)
43
- rspec-core (3.8.0)
44
- rspec-support (~> 3.8.0)
45
- rspec-expectations (3.8.3)
81
+ psych (5.1.2)
82
+ stringio
83
+ racc (1.8.1)
84
+ rainbow (3.1.1)
85
+ rake (13.0.3)
86
+ rdoc (6.7.0)
87
+ psych (>= 4.0.0)
88
+ regexp_parser (2.13.1)
89
+ reline (0.5.10)
90
+ io-console (~> 0.5)
91
+ rspec (3.10.0)
92
+ rspec-core (~> 3.10.0)
93
+ rspec-expectations (~> 3.10.0)
94
+ rspec-mocks (~> 3.10.0)
95
+ rspec-core (3.10.1)
96
+ rspec-support (~> 3.10.0)
97
+ rspec-expectations (3.10.1)
46
98
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.8.0)
48
- rspec-mocks (3.8.0)
99
+ rspec-support (~> 3.10.0)
100
+ rspec-mocks (3.10.1)
49
101
  diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.8.0)
51
- rspec-support (3.8.0)
52
- thread_safe (0.3.6)
53
- tzinfo (1.2.5)
54
- thread_safe (~> 0.1)
55
- yard (0.9.19)
102
+ rspec-support (~> 3.10.0)
103
+ rspec-support (3.10.1)
104
+ rubocop (1.92.0)
105
+ json (>= 2.3)
106
+ language_server-protocol (~> 3.17.0.2)
107
+ lint_roller (~> 1.1.0)
108
+ parallel (>= 1.10)
109
+ parser (>= 3.3.0.2)
110
+ rainbow (>= 2.2.2, < 4.0)
111
+ regexp_parser (>= 2.11.3, < 3.0)
112
+ rubocop-ast (>= 1.49.0, < 2.0)
113
+ ruby-progressbar (~> 1.7)
114
+ unicode-display_width (>= 2.4.0, < 4.0)
115
+ rubocop-ast (1.50.0)
116
+ parser (>= 3.3.7.2)
117
+ prism (~> 1.7)
118
+ rubocop-performance (1.27.0)
119
+ lint_roller (~> 1.1)
120
+ rubocop (>= 1.89.0, < 2.0)
121
+ rubocop-ast (>= 1.47.1, < 2.0)
122
+ rubocop-rake (0.7.1)
123
+ lint_roller (~> 1.1)
124
+ rubocop (>= 1.72.1)
125
+ rubocop-rspec (3.10.2)
126
+ lint_roller (~> 1.1)
127
+ regexp_parser (>= 2.0)
128
+ rubocop (~> 1.86, >= 1.86.2)
129
+ rubocop-shopify (2.18.0)
130
+ rubocop (~> 1.62)
131
+ ruby-progressbar (1.13.0)
132
+ securerandom (0.4.1)
133
+ stringio (3.1.1)
134
+ tzinfo (2.0.6)
135
+ concurrent-ruby (~> 1.0)
136
+ unicode-display_width (3.3.0)
137
+ unicode-emoji (~> 4.3)
138
+ unicode-emoji (4.3.0)
139
+ uri (1.1.2)
140
+ yard (0.9.26)
56
141
 
57
142
  PLATFORMS
58
143
  ruby
59
144
 
60
145
  DEPENDENCIES
61
146
  bundler
147
+ debug
62
148
  erbtex!
149
+ gem_docs (~> 0.3.1)
63
150
  minitest
64
151
  pry
65
152
  pry-byebug
66
153
  pry-doc
67
- rake
68
- rspec
154
+ rake (~> 13.0)
155
+ rspec (~> 3.0)
156
+ rubocop-ddoherty!
69
157
 
70
158
  BUNDLED WITH
71
- 1.17.3
159
+ 2.3.3
data/README.md ADDED
@@ -0,0 +1,161 @@
1
+ - [ErbTeX: Ruby pre-processing for TeX and LaTeX Documents](#org9ef47b3)
2
+ - [Description](#orgade1297)
3
+ - [Installation](#orgc054edb)
4
+ - [Usage](#orgda2b59e)
5
+ - [Examples](#org052edee)
6
+ - [Square Roots](#orgba48a0a)
7
+ - [Trigonometry Table](#org180011c)
8
+
9
+
10
+
11
+ <a id="org9ef47b3"></a>
12
+
13
+ # ErbTeX: Ruby pre-processing for TeX and LaTeX Documents
14
+
15
+
16
+ <a id="orgade1297"></a>
17
+
18
+ ## Description
19
+
20
+ `erbtex` is a ruby gem that provides the `erbtex` command line program that pre-processes TeX and LaTeX source files with ruby's [erubis](http://www.kuwata-lab.com/erubis) and then passes the resulting file along to a real TeX program.
21
+
22
+
23
+ <a id="orgc054edb"></a>
24
+
25
+ ## Installation
26
+
27
+ Install `erbtex` with:
28
+
29
+ ```sh
30
+ gem install erbtex
31
+ ```
32
+
33
+
34
+ <a id="orgda2b59e"></a>
35
+
36
+ ## Usage
37
+
38
+ After the gem is installed, `erbtex` is placed in your PATH. `erbtex` recognizes only one command-line option, `--invoke=<tex_program>`, which specifies what TeX variant will process the TeX file after erubis has pre-proceesed the input file. By default, `erbtex` uses `pdflatex` if no &ndash;invoke option is given.
39
+
40
+ `Erbtex` reads the input file and executes any ruby code between the special delimiters `{:` and `:}`. This brace-colon form of delimiters is less disruptive of LaTeX syntax highlighting than `erubis`'s default delimiters `<%` and `%>` delimiters, which often get confused by syntax-enabled editors with TeX and LaTeX comments.
41
+
42
+ If the opening delimiter is instead `{:=`, the delimited ruby expression is converted into a string (with ruby's `.to_s` method) and inserted in-place into the TeX manuscript at that point. For example, the text `{:= "Hello, world".reverse :}` places the string `dlrow ,olleH` at that point in the TeX file.
43
+
44
+ Any text *not* enclosed in these delimiters is passed through untouched to the TeX program.
45
+
46
+ Without the \`=\` the ruby code is simply executed. You can use these, for example, to `require` ruby libraries or to embed loops into the file. Loops started in one delimited ruby fragment can be continued or terminated in a later fragment, and variables defined in one fragment are accessible in later fragments according to Ruby's usual scoping rules. The result is that you can use the ruby programming language to greatly increase the computational capabilities of a normal TeX or LaTeX.
47
+
48
+ You can get the version with the &ndash;version flag and help with &ndash;help.
49
+
50
+ To generate the preprocessed file without invoking TeX, use `erbtex --preprocess-only roots.tex`. This writes `roots.etx` and exits; an input named `roots.tex.erb` produces `roots.tex` instead. The option requires an input file.
51
+
52
+ Generated output begins with this exact first-line comment:
53
+
54
+ ```latex
55
+ % Generated by erbtex. Changes may be overwritten.
56
+ ```
57
+
58
+ Erbtex automatically replaces an existing output file only when it starts with that marker. Otherwise it prints a warning and exits unsuccessfully, before executing the template or invoking TeX. Use `--no-clobber` to protect all existing output files, including marked ones. This applies to both `.tex` and `.etx` output, including `--preprocess-only` mode.
59
+
60
+ Output generated by older erbtex versions has no marker and is protected. Inspect it before moving or deleting it, or add the marker as its first line if you want erbtex to overwrite it on subsequent runs.
61
+
62
+ Erbtex preprocesses only the input file given on the command line. Files referenced by LaTeX's `\input` or `\include` commands are read directly by TeX; Ruby fragments in those files are not evaluated by erbtex. Recursive pre-processing of included files is not currently supported. If an included file needs preprocessing, run erbtex on it separately with `--preprocess-only` and reference the generated output from the main document.
63
+
64
+
65
+ <a id="org052edee"></a>
66
+
67
+ ## Examples
68
+
69
+
70
+ <a id="orgba48a0a"></a>
71
+
72
+ ### Square Roots
73
+
74
+ For example, the following LaTeX file will produce a table of square roots when run through erbtex. It uses a ruby iterator to supply the rows of the table, a feat that would tedious at best with bare TeX or LaTeX.
75
+
76
+ ```latex
77
+ \documentclass{article}
78
+ \usepackage[mathbf]{euler}
79
+ \usepackage{longtable}
80
+
81
+ \begin{document}
82
+ \begin{longtable}[c]{r|r}
83
+ \hline\hline
84
+ \multicolumn{1}{c|}{\mathversion{bold}$x$}&
85
+ \multicolumn{1}{c}{\mathversion{bold}\rule{0pt}{12pt}$\sqrt{x}$}\\
86
+ \hline\hline
87
+ \endhead
88
+ \hline\hline
89
+ \endfoot
90
+ % The following line starts a ruby enumerator loop but does not
91
+ % produce any output, since the delimiters are {: :}.
92
+ {: 0.upto(100).each do |x| :}
93
+
94
+ % But the following two lines produce output since the opening delimiter is
95
+ % '{:='. Both call the sprintf method in ruby via the percent operator, and the
96
+ % second line calls ruby's Math module to compute the square root. Notice that
97
+ % the '%' inside the delimiters does not have the effect of commenting out
98
+ % the following text. It is interpreted as a ruby '%' operator.
99
+
100
+ {:= "\\mathversion{bold}$%0.4f$" % x :}&
101
+ {:= "$%0.8f$" % Math.sqrt(x) :}\\
102
+
103
+ % End of the loop started above.
104
+ {: end :}
105
+ \end{longtable}
106
+ \end{document}
107
+ ```
108
+
109
+ With the above in file `roots.tex`, running `$ erbtex roots.tex` at the command line will generate a \`PDF\` file with a nicely typeset table of square roots. The generated pdf file can be seen [here](examples/roots.pdf). As a by-product, the pre-processed file `roots.etx` is left in the same directory, so you can see what the effect of the erbtex fragments were. This is often very handy when you are trying to debug the document; otherwise, feel free to delete it. Here, for example is a portion of the \`roots.etx\` file generated by the foregoing:
110
+
111
+ ```latex
112
+ \begin{document}
113
+ \begin{longtable}[c]{r|r}
114
+ \hline\hline
115
+ \multicolumn{1}{c|}{\mathversion{bold}$x$}&
116
+ \multicolumn{1}{c}{\mathversion{bold}\rule{0pt}{12pt}$\sqrt{x}$}\\
117
+ \hline\hline
118
+ \endhead
119
+ \hline\hline
120
+ \endfoot
121
+ \mathversion{bold}$0.0000$&
122
+ $0.00000000$\\
123
+ \mathversion{bold}$1.0000$&
124
+ $1.00000000$\\
125
+ \mathversion{bold}$2.0000$&
126
+ $1.41421356$\\
127
+ \mathversion{bold}$3.0000$&
128
+ $1.73205081$\\
129
+ \mathversion{bold}$4.0000$&
130
+ $2.00000000$\\
131
+ \mathversion{bold}$5.0000$&
132
+ $2.23606798$\\
133
+ \mathversion{bold}$6.0000$&
134
+ $2.44948974$\\
135
+ \mathversion{bold}$7.0000$&
136
+ $2.64575131$\\
137
+ \mathversion{bold}$8.0000$&
138
+ $2.82842712$\\
139
+ \mathversion{bold}$9.0000$&
140
+ $3.00000000$\\
141
+ \mathversion{bold}$10.0000$&
142
+ $3.16227766$\\
143
+ \mathversion{bold}$11.0000$&
144
+ $3.31662479$\\
145
+ \mathversion{bold}$12.0000$&
146
+ $3.46410162$\\
147
+ \mathversion{bold}$13.0000$&
148
+ $3.60555128$\\
149
+ \mathversion{bold}$14.0000$&
150
+ ```
151
+
152
+ And many more lines like it.
153
+
154
+
155
+ <a id="org180011c"></a>
156
+
157
+ ### Trigonometry Table
158
+
159
+ The examples directory installed with the erbtex gem has a few more examples, including a [large trigonometry table](examples/TrigTable2.pdf) generated from a relatively small [input file](examples/TrigTable2.tex).
160
+
161
+ It makes good use of ruby to define a Dms class that handles angles expressed as degrees, minutes, and seconds&mdash;a feat that would be very difficult to achieve with LaTeX also.
data/README.org CHANGED
@@ -1,13 +1,18 @@
1
- * ErbTeX: Ruby pre-processing for TeX and LaTeX Documents
1
+ #+PROPERTY: header-args:ruby :results value :colnames no :hlines yes :exports both :dir "./"
2
+ #+PROPERTY: header-args:ruby+ :wrap example :session erbtex_session :eval yes
3
+ #+PROPERTY: header-args:ruby+ :prologue "$:.unshift('./lib') unless $:.first == './lib'; require 'erbtex'"
4
+ #+PROPERTY: header-args:ruby+ :ruby "bundle exec irb"
5
+ #+PROPERTY: header-args:sh :exports code :eval no
6
+ #+PROPERTY: header-args:bash :exports code :eval no
7
+ #+PROPERTY: header-args:latex :exports code :eval no
2
8
 
9
+ * ErbTeX: Ruby pre-processing for TeX and LaTeX Documents
3
10
  ** Description
4
-
5
11
  ~erbtex~ is a ruby gem that provides the ~erbtex~ command line program that
6
12
  pre-processes TeX and LaTeX source files with ruby's [[http://www.kuwata-lab.com/erubis][erubis]] and then passes
7
13
  the resulting file along to a real TeX program.
8
14
 
9
15
  ** Installation
10
-
11
16
  Install ~erbtex~ with:
12
17
 
13
18
  #+BEGIN_SRC sh
@@ -15,18 +20,17 @@ Install ~erbtex~ with:
15
20
  #+END_SRC
16
21
 
17
22
  ** Usage
18
-
19
23
  After the gem is installed, ~erbtex~ is placed in your PATH. ~erbtex~
20
24
  recognizes only one command-line option, ~--invoke=<tex_program>~, which
21
25
  specifies what TeX variant will process the TeX file after erubis has
22
26
  pre-proceesed the input file. By default, ~erbtex~ uses ~pdflatex~ if no
23
27
  --invoke option is given.
24
28
 
25
- ~Erbtex~ reads the input file and executes any ruby code between the special
26
- delimiters ~{:~ and ~:}~. This brace-colon form of delimiters is less
27
- disruptive of syntax highlighting than ~erubis~'s default delimiters ~<%~ and
28
- ~%>~ delimiters, which often get confused by syntax-enabled editors with TeX
29
- and LaTeX comments.
29
+ ~Erbtex~ reads the input file and executes any ruby code between the
30
+ special delimiters ~{:~ and ~:}~. This brace-colon form of delimiters
31
+ is less disruptive of LaTeX syntax highlighting than ~erubis~'s default
32
+ delimiters ~<%~ and ~%>~ delimiters, which often get confused by
33
+ syntax-enabled editors with TeX and LaTeX comments.
30
34
 
31
35
  If the opening delimiter is instead ~{:=~, the delimited ruby expression is
32
36
  converted into a string (with ruby's ~.to_s~ method) and inserted in-place
@@ -47,10 +51,36 @@ capabilities of a normal TeX or LaTeX.
47
51
 
48
52
  You can get the version with the --version flag and help with --help.
49
53
 
50
- ** Examples
54
+ To generate the preprocessed file without invoking TeX, use
55
+ ~erbtex --preprocess-only roots.tex~. This writes ~roots.etx~ and exits;
56
+ an input named ~roots.tex.erb~ produces ~roots.tex~ instead. The option
57
+ requires an input file.
51
58
 
52
- *** Square Roots
59
+ Generated output begins with this exact first-line comment:
53
60
 
61
+ #+BEGIN_SRC latex
62
+ % Generated by erbtex. Changes may be overwritten.
63
+ #+END_SRC
64
+
65
+ Erbtex automatically replaces an existing output file only when it starts
66
+ with that marker. Otherwise it prints a warning and exits unsuccessfully,
67
+ before executing the template or invoking TeX. Use ~--no-clobber~ to protect
68
+ all existing output files, including marked ones. This applies to both
69
+ ~.tex~ and ~.etx~ output, including ~--preprocess-only~ mode.
70
+
71
+ Output generated by older erbtex versions has no marker and is protected.
72
+ Inspect it before moving or deleting it, or add the marker as its first line
73
+ if you want erbtex to overwrite it on subsequent runs.
74
+
75
+ Erbtex preprocesses only the input file given on the command line. Files
76
+ referenced by LaTeX's ~\input~ or ~\include~ commands are read directly by
77
+ TeX; Ruby fragments in those files are not evaluated by erbtex. Recursive
78
+ pre-processing of included files is not currently supported. If an included
79
+ file needs preprocessing, run erbtex on it separately with ~--preprocess-only~
80
+ and reference the generated output from the main document.
81
+
82
+ ** Examples
83
+ *** Square Roots
54
84
  For example, the following LaTeX file will produce a table of square
55
85
  roots when run through erbtex. It uses a ruby iterator to supply the
56
86
  rows of the table, a feat that would tedious at best with bare TeX or
@@ -141,7 +171,10 @@ for example is a portion of the `roots.etx` file generated by the foregoing:
141
171
  And many more lines like it.
142
172
 
143
173
  *** Trigonometry Table
144
-
145
174
  The examples directory installed with the erbtex gem has a few more
146
175
  examples, including a [[file:examples/TrigTable2.pdf][large trigonometry table]] generated from a relatively
147
176
  small [[file:examples/TrigTable2.tex][input file]].
177
+
178
+ It makes good use of ruby to define a Dms class that handles angles
179
+ expressed as degrees, minutes, and seconds---a feat that would be very
180
+ difficult to achieve with LaTeX also.
data/Rakefile CHANGED
@@ -1,12 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'gem_docs'
4
+
5
+ GemDocs.install
6
+
1
7
  require 'bundler/gem_tasks'
8
+
9
+ # Installing into the user's gems must not inherit this project's bundle.
10
+ # RubyGems plugins (notably RDoc) may require dependencies outside that bundle.
11
+ module UnbundledGemInstallation
12
+ def install_gem(*args)
13
+ Bundler.with_unbundled_env { super }
14
+ end
15
+ end
16
+
17
+ Bundler::GemHelper.prepend(UnbundledGemInstallation)
18
+
2
19
  require 'rspec/core/rake_task'
20
+
3
21
  require 'rdoc/task'
4
22
 
5
23
  RDoc::Task.new do |rdoc|
6
24
  rdoc.main = 'README.rdoc'
7
25
  rdoc.rdoc_files.include('README.rdoc', 'lib')
8
26
  end
9
-
10
27
  RSpec::Core::RakeTask.new(:spec)
11
28
 
12
- task default: :spec
29
+ require 'rubocop/rake_task'
30
+
31
+ RuboCop::RakeTask.new
32
+
33
+ task default: %i[spec rubocop]