polytexnic 1.9.2 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/polytexnic/postprocessors/html.rb +102 -18
- data/lib/polytexnic/postprocessors/polytex.rb +0 -3
- data/lib/polytexnic/preprocessors/html.rb +21 -1
- data/lib/polytexnic/utils.rb +6 -3
- data/lib/polytexnic/version.rb +1 -1
- data/lib/polytexnic.rb +9 -1
- data/spec/articles_spec.rb +1 -1
- data/spec/to_html/asides_spec.rb +4 -3
- data/spec/to_html/codelistings_spec.rb +3 -3
- data/spec/to_html/proof_theorem_spec.rb +185 -0
- metadata +4 -3
- data/arm64-darwin21 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08ef6b16e688ae517db09f1ccd14da9a9861fc14d0b7576267f2704ee28e2223'
|
4
|
+
data.tar.gz: 1d19e497423591bf533a01c7870e93fbff311639a35584c2fce4b2eb5fc70ce2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fb7f765d2eb5ef17df271b165aa628def5742333e672dd8fa599321e9e550a07af902e914768a2c90123a41ddec53a529677ee84c932d919ce7ce5c99400f50
|
7
|
+
data.tar.gz: d69d4ccc81b47e6098462888862813f9a1164232a09b16c473d2f7821fa3a4c24f6f1a540d03147689630c7daf5ac42ff653e6d3ee1ccdea96c6cd2fb689ea68
|
data/Gemfile.lock
CHANGED
@@ -45,6 +45,8 @@ module Polytexnic
|
|
45
45
|
restore_inline_verbatim(doc)
|
46
46
|
codelistings(doc)
|
47
47
|
asides(doc)
|
48
|
+
theorems_lemmas_etc(doc)
|
49
|
+
proofs(doc)
|
48
50
|
make_cross_references(doc)
|
49
51
|
hrefs(doc)
|
50
52
|
graphics_and_figures(doc)
|
@@ -463,8 +465,6 @@ module Polytexnic
|
|
463
465
|
# Returns true if node is inside section*.
|
464
466
|
def section_star?(node)
|
465
467
|
begin
|
466
|
-
# puts (val = node.parent.parent.attributes['class'].value) + '*******'
|
467
|
-
# puts node.parent.parent.parent.parent.children[1] if val == 'section-star'
|
468
468
|
node.parent.parent.attributes['class'].value == 'section-star'
|
469
469
|
rescue
|
470
470
|
false
|
@@ -543,9 +543,6 @@ module Polytexnic
|
|
543
543
|
|
544
544
|
# Returns the node for a list item (li).
|
545
545
|
def item(doc)
|
546
|
-
# doc.xpath('//item/p[@noindent="true"]').each do |node|
|
547
|
-
# node.replace(node.inner_html)
|
548
|
-
# end
|
549
546
|
doc.xpath('//item').each do |node|
|
550
547
|
clean_node node, %w{id-text id label}
|
551
548
|
node.name = 'li'
|
@@ -740,13 +737,42 @@ module Polytexnic
|
|
740
737
|
end
|
741
738
|
end
|
742
739
|
|
740
|
+
# Returns true if the environment type is a theorem, lemma, etc.
|
741
|
+
def theorem_environment?(css_classes)
|
742
|
+
return false if css_classes.nil?
|
743
|
+
css_classes.split.each do |css_class|
|
744
|
+
return true if @supported_theorem_types.include?(css_class)
|
745
|
+
end
|
746
|
+
return false
|
747
|
+
end
|
748
|
+
|
749
|
+
# Return the style class associated with an element.
|
750
|
+
# The only trick involves theorem environments.
|
751
|
+
# There are three defined in
|
752
|
+
# http://www.ams.org/arc/tex/amscls/amsthdoc.pdf:
|
753
|
+
# plain, definition, and remark
|
754
|
+
# So that this can be used without modification with other elements,
|
755
|
+
# if the element isn't a theorem we simply return the type itself.
|
756
|
+
def element_class(element_type)
|
757
|
+
return element_type unless theorem_environment?(element_type)
|
758
|
+
plain_styles = %w[theorem lemma corollary proposition conjecture]
|
759
|
+
definition_styles = %w[definition problem example exercise axiom]
|
760
|
+
remark_styles = %w[remark claim]
|
761
|
+
if plain_styles.include?(element_type)
|
762
|
+
"#{element_type} plain"
|
763
|
+
elsif definition_styles.include?(element_type)
|
764
|
+
"#{element_type} definition"
|
765
|
+
elsif remark_styles.include?(element_type)
|
766
|
+
"#{element_type} remark"
|
767
|
+
end
|
768
|
+
end
|
769
|
+
|
743
770
|
# Builds the full heading for codelisting-like environments.
|
744
771
|
# The full heading, such as "Listing 1.1: Foo bars." needs to be
|
745
772
|
# extracted and manipulated to produce the right tags and classes.
|
746
773
|
def build_heading(node, css_class)
|
747
774
|
node.name = 'div'
|
748
|
-
node['class'] = css_class
|
749
|
-
|
775
|
+
node['class'] = element_class(css_class)
|
750
776
|
heading = node.at_css('p')
|
751
777
|
heading.attributes.each do |key, value|
|
752
778
|
node.set_attribute(key, value)
|
@@ -754,18 +780,55 @@ module Polytexnic
|
|
754
780
|
end
|
755
781
|
heading.name = 'div'
|
756
782
|
heading['class'] = 'heading'
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
783
|
+
full_number = heading.at_css('strong')
|
784
|
+
full_number.name = 'span'
|
785
|
+
full_number['class'] = 'number'
|
786
|
+
# E.g., "Theorem 1.1 (Fermat’s Last Theorem)"
|
787
|
+
# label = "Theorem"
|
788
|
+
# actual_number_etc = ["1.1", "Fermat’s Last Theorem"]
|
789
|
+
full_label_content = full_number.content.strip
|
790
|
+
full_number.content = ''
|
791
|
+
content_array = full_label_content.split
|
792
|
+
label, actual_number_etc = content_array.shift, content_array
|
793
|
+
element_label = Nokogiri::XML::Node.new('span', heading)
|
794
|
+
# Make span for element's style label.
|
795
|
+
# <span class="plain_label">Theorem</span>
|
796
|
+
element_label['class'] = "#{element_class(css_class)}_label"
|
797
|
+
if article?
|
798
|
+
actual_number = actual_number_etc.first.sub!('0.', '')
|
799
|
+
else
|
800
|
+
actual_number = actual_number_etc.first
|
801
|
+
end
|
802
|
+
element_label.content = label
|
803
|
+
full_number << element_label
|
804
|
+
full_number << Nokogiri::XML::Text.new(" #{actual_number}", heading)
|
805
|
+
# Handle optional argument to theorems.
|
806
|
+
# E.g., \begin{theorem}[Fermat's Last Theorem]
|
807
|
+
environment_type = label.downcase
|
808
|
+
if theorem_environment?(environment_type)
|
809
|
+
# Theorem headings should be paragraphs instead of divs.
|
810
|
+
heading.name = 'p'
|
811
|
+
# This will be nonempty only if there's an optional argument
|
812
|
+
# as in \begin{theorem}[optional argument].
|
813
|
+
optarg = actual_number_etc[1..-1].join(" ")
|
814
|
+
unless optarg.empty?
|
815
|
+
# Add a span to parenthetical content for styling purpsoes.
|
816
|
+
# This handles things like "Theorem 1.1 (Fermat’s Last Theorem)".
|
817
|
+
theorem_description = Nokogiri::XML::Node.new('span', heading)
|
818
|
+
theorem_description['class'] = 'theorem_description'
|
819
|
+
theorem_description.content = optarg
|
820
|
+
full_number << Nokogiri::XML::Text.new(' ', heading)
|
821
|
+
full_number << theorem_description
|
822
|
+
end
|
823
|
+
full_number << Nokogiri::XML::Text.new('.', heading)
|
824
|
+
elsif css_class == 'codelisting'
|
763
825
|
description = node.at_css('.description').content
|
764
|
-
|
826
|
+
unless description.empty?
|
827
|
+
full_number << Nokogiri::XML::Text.new(':', heading)
|
828
|
+
end
|
765
829
|
else
|
766
|
-
|
830
|
+
full_number << Nokogiri::XML::Text.new('.', heading)
|
767
831
|
end
|
768
|
-
|
769
832
|
heading
|
770
833
|
end
|
771
834
|
|
@@ -814,6 +877,23 @@ module Polytexnic
|
|
814
877
|
end
|
815
878
|
end
|
816
879
|
|
880
|
+
# Processes theorems, lemmas, etc.
|
881
|
+
def theorems_lemmas_etc(doc)
|
882
|
+
@supported_theorem_types.each do |theorem_type|
|
883
|
+
doc.xpath("//#{theorem_type}").each do |node|
|
884
|
+
build_heading(node, theorem_type)
|
885
|
+
end
|
886
|
+
end
|
887
|
+
end
|
888
|
+
|
889
|
+
# Processes proofs.
|
890
|
+
def proofs(doc)
|
891
|
+
doc.xpath('//proof').each do |node|
|
892
|
+
node.name = 'div'
|
893
|
+
node['class'] = 'proof'
|
894
|
+
end
|
895
|
+
end
|
896
|
+
|
817
897
|
# Processes centered elements.
|
818
898
|
def center(doc)
|
819
899
|
doc.xpath('//center').each do |node|
|
@@ -912,11 +992,11 @@ module Polytexnic
|
|
912
992
|
|
913
993
|
# Creates linked cross-references.
|
914
994
|
def make_cross_references(doc)
|
915
|
-
#
|
995
|
+
# Build numbering tree.
|
916
996
|
doc.xpath('//*[@data-tralics-id]').each do |node|
|
917
997
|
node['data-number'] = formatted_number(node)
|
918
998
|
clean_node node, 'id-text'
|
919
|
-
# Add number span
|
999
|
+
# Add number span.
|
920
1000
|
if (head = node.css('h1 a, h2 a, h3 a').first)
|
921
1001
|
el = doc.create_element 'span'
|
922
1002
|
el.content = section_label(node)
|
@@ -1003,6 +1083,7 @@ module Polytexnic
|
|
1003
1083
|
@figure = 0
|
1004
1084
|
@table = 0
|
1005
1085
|
@aside = 0
|
1086
|
+
@theorem = 0
|
1006
1087
|
@cha = article? ? nil : node['id-text']
|
1007
1088
|
elsif node['class'] == 'section'
|
1008
1089
|
@sec = node['id-text']
|
@@ -1028,6 +1109,9 @@ module Polytexnic
|
|
1028
1109
|
elsif node.name == 'figure'
|
1029
1110
|
@figure = ref_number(node, @cha, @figure)
|
1030
1111
|
label_number(@cha, @figure)
|
1112
|
+
elsif theorem_environment?(node['class'])
|
1113
|
+
@theorem = number_from_id(node['id-text'])
|
1114
|
+
label_number(@cha, @theorem)
|
1031
1115
|
end
|
1032
1116
|
end
|
1033
1117
|
|
@@ -35,9 +35,6 @@ module Polytexnic
|
|
35
35
|
# which reduces syntax highlighting to a previously solved problem.
|
36
36
|
def write_polytex_code
|
37
37
|
code_cache.each do |key, (code, lang, in_codelisting, options)|
|
38
|
-
# puts '*********'
|
39
|
-
# puts @source.inspect
|
40
|
-
# raise code.inspect
|
41
38
|
latex = "%= lang:#{lang}#{options}\n" +
|
42
39
|
"\\begin{code}\n" + escape_hack(code) + "\n\\end{code}"
|
43
40
|
@source.gsub!(key, latex)
|
@@ -274,7 +274,7 @@ module Polytexnic
|
|
274
274
|
end
|
275
275
|
|
276
276
|
# Converts the alt table environments to simple tabular.
|
277
|
-
# This
|
277
|
+
# This was originally because kramdown outputs longtables by default,
|
278
278
|
# but as a side-effect you can also use longtables in PolyTeX
|
279
279
|
# input documents. The latest update includes support for the tabularx
|
280
280
|
# environment
|
@@ -317,6 +317,16 @@ module Polytexnic
|
|
317
317
|
"#{s}\n\\end{xmlelement*}"
|
318
318
|
end
|
319
319
|
|
320
|
+
# Wrap proofs in a 'proof' element.
|
321
|
+
string.gsub! /\\begin{proof}/ do |s|
|
322
|
+
"\\begin{xmlelement*}{proof}\n#{s}"
|
323
|
+
end
|
324
|
+
string.gsub! /\\end{proof}/ do |s|
|
325
|
+
"#{s}\n\\end{xmlelement*}"
|
326
|
+
end
|
327
|
+
string.gsub!(/\\begin{proof}/, '')
|
328
|
+
string.gsub!(/\\end{proof}/, '')
|
329
|
+
|
320
330
|
# Wrap asides in an 'aside' element.
|
321
331
|
string.gsub! /\\begin{aside}/ do |s|
|
322
332
|
"\\begin{xmlelement*}{aside}\n#{s}"
|
@@ -325,6 +335,16 @@ module Polytexnic
|
|
325
335
|
"#{s}\n\\end{xmlelement*}"
|
326
336
|
end
|
327
337
|
|
338
|
+
# Wrap theorem, lemma, etc., in corresponding elements.
|
339
|
+
@supported_theorem_types.each do |th|
|
340
|
+
string.gsub! /\\begin{#{th}}/ do |s|
|
341
|
+
"\\begin{xmlelement*}{#{th}}\n#{s}"
|
342
|
+
end
|
343
|
+
string.gsub! /\\end{#{th}}/ do |s|
|
344
|
+
"#{s}\n\\end{xmlelement*}"
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
328
348
|
# Replace quotations and verse with corresponding XML elements.
|
329
349
|
string.gsub! /\\begin{quote}/ do |s|
|
330
350
|
quotation = '\AddAttToCurrent{class}{quotation}'
|
data/lib/polytexnic/utils.rb
CHANGED
@@ -149,13 +149,16 @@ module Polytexnic
|
|
149
149
|
\newcommand{\newunicodechar}[2]{}
|
150
150
|
\newcommand{\extrafloats}[1]{}
|
151
151
|
EOS
|
152
|
-
|
152
|
+
custom = <<-EOS
|
153
153
|
\\usepackage{amsthm}
|
154
|
-
\\theoremstyle{definition}
|
155
154
|
\\newtheorem{codelisting}{#{language_labels["listing"]}}[chapter]
|
156
155
|
\\newtheorem{aside}{#{language_labels["aside"]}}[chapter]
|
156
|
+
\\newtheorem{theorem}{#{language_labels["theorem"]}}[chapter]
|
157
157
|
EOS
|
158
|
-
[
|
158
|
+
(@supported_theorem_types - ["theorem"]).each do |lab|
|
159
|
+
custom += "\\newtheorem{#{lab}}[theorem]{#{language_labels[lab]}}\n"
|
160
|
+
end
|
161
|
+
[base_commands, custom].join("\n")
|
159
162
|
end
|
160
163
|
|
161
164
|
# Highlights source code.
|
data/lib/polytexnic/version.rb
CHANGED
data/lib/polytexnic.rb
CHANGED
@@ -49,6 +49,10 @@ module Polytexnic
|
|
49
49
|
@literal_html_cache = {}
|
50
50
|
@maketitle_elements = {}
|
51
51
|
@article = options[:article]
|
52
|
+
@supported_theorem_types = %w[theorem lemma corollary proposition
|
53
|
+
conjecture
|
54
|
+
definition problem example exercise axiom
|
55
|
+
remark claim]
|
52
56
|
@language_labels = if (labels = options[:language_labels]).nil?
|
53
57
|
default_language_labels
|
54
58
|
else
|
@@ -109,11 +113,15 @@ module Polytexnic
|
|
109
113
|
|
110
114
|
# Returns the default labels for 'Chapter', 'Figure', etc.
|
111
115
|
def default_language_labels
|
116
|
+
theorem_labels = @supported_theorem_types.inject({}) do |labels, th|
|
117
|
+
labels[th] = th.capitalize
|
118
|
+
labels
|
119
|
+
end
|
112
120
|
{"part"=>"Part","chapter"=>{"word"=>"Chapter", "order"=>"standard"},
|
113
121
|
"section"=>"Section", "appendix"=>"Appendix", "table"=>"Table",
|
114
122
|
"figure"=>"Figure", "fig"=>"Fig", "aside"=>"Box", "listing"=>"Listing",
|
115
123
|
"equation"=>"Equation", "eq"=>"Eq", "frontmatter"=>"Frontmatter",
|
116
|
-
"contents"=>"Contents"}
|
124
|
+
"contents"=>"Contents"}.merge(theorem_labels)
|
117
125
|
end
|
118
126
|
|
119
127
|
def markdown?
|
data/spec/articles_spec.rb
CHANGED
@@ -43,7 +43,7 @@ $ subl .gemrc
|
|
43
43
|
let(:section) { '<a href="#sec-foo" class="heading"><span class="number">1 </span>' }
|
44
44
|
let(:figure) { '<span class="header">Figure 1</span>' }
|
45
45
|
let(:table) { '<span class="header">Table 1</span>' }
|
46
|
-
let(:listing) { '<span class="number">Listing 1
|
46
|
+
let(:listing) { '<span class="number"><span class="codelisting_label">Listing</span> 1:' }
|
47
47
|
let(:footnote) { '<sup id="cha-0_footnote-ref-1" class="footnote"><a href="#cha-0_footnote-1">1</a></sup>' }
|
48
48
|
|
49
49
|
let(:sref) { 'Section <span class="ref">1</span>' }
|
data/spec/to_html/asides_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
29
29
|
<div id="cid1" data-tralics-id="cid1" class="chapter" data-number="1"><h1><a href="#cid1" class="heading"><span class="number">Chapter 1 </span>Foo bar</a></h1>
|
30
30
|
<div class="aside" id="aside-lorem" data-tralics-id="uid1" data-number="1.1">
|
31
31
|
<div class="heading">
|
32
|
-
<span class="number">Box 1.1.</span>
|
32
|
+
<span class="number"><span class="aside_label">Box</span> 1.1.</span>
|
33
33
|
<span class="description">Lorem ipsum.</span>
|
34
34
|
</div>
|
35
35
|
<p>lorem ipsum</p>
|
@@ -47,7 +47,7 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
47
47
|
"order" => "standard" },
|
48
48
|
"aside" => "Cajón" })
|
49
49
|
end
|
50
|
-
it { should include 'Cajón 1.1' }
|
50
|
+
it { should include '<span class="aside_label">Cajón</span> 1.1' }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -67,7 +67,8 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
67
67
|
EOS
|
68
68
|
end
|
69
69
|
context "in a chapter" do
|
70
|
-
let(:
|
70
|
+
let(:prematerial) { "\\chapter{Foo}\n\n\\section{Bar}" }
|
71
|
+
let(:polytex) { prematerial + "\n" + aside}
|
71
72
|
it { should include ">1.1<" }
|
72
73
|
end
|
73
74
|
|
@@ -28,7 +28,7 @@ Listing~\ref{code:create_gemrc}
|
|
28
28
|
<div id="cid1" data-tralics-id="cid1" class="chapter" data-number="1"><h1><a href="#cid1" class="heading"><span class="number">Chapter 1 </span>Foo bar</a></h1>
|
29
29
|
<div class="codelisting" id="code-create_gemrc" data-tralics-id="uid1" data-number="1.1">
|
30
30
|
<div class="heading">
|
31
|
-
<span class="number">Listing 1.1:</span>
|
31
|
+
<span class="number"><span class="codelisting_label">Listing</span> 1.1:</span>
|
32
32
|
<span class="description">Creating a <code class="tt">gem</code> configuration file.<span class="intersentencespace"></span>
|
33
33
|
<span class="break"></span>
|
34
34
|
<code class="filepath">path/to/file</code>
|
@@ -72,8 +72,8 @@ Listing~\ref{code:create_gemrc}
|
|
72
72
|
Listing~\ref{code:create_gemrc}
|
73
73
|
EOS
|
74
74
|
end
|
75
|
-
it { should include 'Listing 1.1' }
|
76
|
-
it { should_not include 'Listing 1.1:' }
|
75
|
+
it { should include 'Listing</span> 1.1' }
|
76
|
+
it { should_not include 'Listing</span> 1.1:' }
|
77
77
|
end
|
78
78
|
|
79
79
|
context "containing code inclusion with a hyphen and a leading dot" do
|
@@ -0,0 +1,185 @@
|
|
1
|
+
# encoding=utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Polytexnic::Pipeline#to_html' do
|
5
|
+
|
6
|
+
let(:pipeline) { Polytexnic::Pipeline.new(polytex) }
|
7
|
+
subject(:processed_text) { pipeline.to_html }
|
8
|
+
|
9
|
+
describe "proof" do
|
10
|
+
let(:polytex) do <<-'EOS'
|
11
|
+
\chapter{Foo bar}
|
12
|
+
|
13
|
+
\begin{proof}
|
14
|
+
Lorem ipsum.
|
15
|
+
\end{proof}
|
16
|
+
EOS
|
17
|
+
end
|
18
|
+
it { should include("Lorem ipsum.") }
|
19
|
+
it { should include('<div class="proof">')}
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "chapter theorems" do
|
23
|
+
let(:polytex) do <<-'EOS'
|
24
|
+
\chapter{Foo bar}
|
25
|
+
|
26
|
+
\section{A section}
|
27
|
+
\label{sec:the_section}
|
28
|
+
|
29
|
+
\begin{theorem}
|
30
|
+
\label{th:lorem}
|
31
|
+
This is a theorem. It might have muliple lines.
|
32
|
+
|
33
|
+
Like this!
|
34
|
+
\end{theorem}
|
35
|
+
|
36
|
+
\begin{lemma}
|
37
|
+
\label{lemma:ipsum}
|
38
|
+
bar
|
39
|
+
\end{lemma}
|
40
|
+
|
41
|
+
\begin{corollary}
|
42
|
+
\label{cor:and_also}
|
43
|
+
quux
|
44
|
+
\end{corollary}
|
45
|
+
|
46
|
+
\begin{definition}
|
47
|
+
\label{def:a_definition}
|
48
|
+
foo
|
49
|
+
\end{definition}
|
50
|
+
|
51
|
+
\begin{remark}
|
52
|
+
able
|
53
|
+
\end{remark}
|
54
|
+
|
55
|
+
We'll see another theorem in Theorem~\ref{th:another},
|
56
|
+
and a lemma in Lemma~\ref{lemma:yet_another}.
|
57
|
+
|
58
|
+
\chapter{Another chapter}
|
59
|
+
|
60
|
+
We saw a theorem in Theorem~\ref{th:lorem} and a corollary
|
61
|
+
in Corollary~\ref{cor:and_also}.
|
62
|
+
|
63
|
+
\section{Another section}
|
64
|
+
|
65
|
+
\begin{theorem}
|
66
|
+
\label{th:another}
|
67
|
+
Another theorem
|
68
|
+
\end{end}
|
69
|
+
|
70
|
+
\begin{lemma}
|
71
|
+
\label{lemma:yet_another}
|
72
|
+
Yet another lemma.
|
73
|
+
\end{lemma}
|
74
|
+
|
75
|
+
EOS
|
76
|
+
end
|
77
|
+
|
78
|
+
it { should include("lorem") }
|
79
|
+
it { should include("Theorem</span> 1.1.</span>") }
|
80
|
+
it { should include("Lemma</span> 1.2") }
|
81
|
+
it { should include("Corollary</span> 1.3") }
|
82
|
+
it { should include("Definition</span> 1.4") }
|
83
|
+
it { should include("Remark</span> 1.5") }
|
84
|
+
it { should include("Theorem</span> 2.1") }
|
85
|
+
it { should include("Lemma</span> 2.2") }
|
86
|
+
it { should include('Theorem <a href="#th-lorem" class="hyperref"><span class="ref">1.1</span></a>')}
|
87
|
+
it { should include('Theorem <a href="#th-another" class="hyperref"><span class="ref">2.1</span></a>')}
|
88
|
+
it { should include('Lemma <a href="#lemma-yet_another" class="hyperref"><span class="ref">2.2</span></a>')}
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "articles theorems" do
|
92
|
+
before do
|
93
|
+
pipeline.stub(:article?).and_return(true)
|
94
|
+
end
|
95
|
+
|
96
|
+
let(:polytex) do <<-'EOS'
|
97
|
+
\section{A section}
|
98
|
+
\label{sec:the_section}
|
99
|
+
|
100
|
+
\begin{theorem}
|
101
|
+
\label{th:lorem}
|
102
|
+
This is a theorem. It might have muliple lines.
|
103
|
+
|
104
|
+
Like this!
|
105
|
+
\end{theorem}
|
106
|
+
|
107
|
+
\begin{lemma}
|
108
|
+
\label{lemma:ipsum}
|
109
|
+
bar
|
110
|
+
\end{lemma}
|
111
|
+
|
112
|
+
\begin{corollary}
|
113
|
+
\label{cor:and_also}
|
114
|
+
quux
|
115
|
+
\end{corollary}
|
116
|
+
|
117
|
+
\begin{definition}
|
118
|
+
\label{def:a_definition}
|
119
|
+
foo
|
120
|
+
\end{definition}
|
121
|
+
|
122
|
+
\begin{remark}
|
123
|
+
able
|
124
|
+
\end{remark}
|
125
|
+
|
126
|
+
We'll see another theorem in Theorem~\ref{th:another},
|
127
|
+
and a lemma in Lemma~\ref{lemma:yet_another}.
|
128
|
+
|
129
|
+
We saw a theorem in Theorem~\ref{th:lorem} and a corollary
|
130
|
+
in Corollary~\ref{cor:and_also}.
|
131
|
+
|
132
|
+
\section{Another section}
|
133
|
+
|
134
|
+
\begin{theorem}
|
135
|
+
\label{th:another}
|
136
|
+
Another theorem
|
137
|
+
\end{end}
|
138
|
+
|
139
|
+
\begin{lemma}
|
140
|
+
\label{lemma:yet_another}
|
141
|
+
Yet another lemma.
|
142
|
+
\end{lemma}
|
143
|
+
|
144
|
+
EOS
|
145
|
+
end
|
146
|
+
|
147
|
+
it { should include("lorem") }
|
148
|
+
it { should include("Theorem</span> 1") }
|
149
|
+
it { should include("Lemma</span> 2") }
|
150
|
+
it { should include("Corollary</span> 3") }
|
151
|
+
it { should include("Definition</span> 4") }
|
152
|
+
it { should include("Remark</span> 5") }
|
153
|
+
it { should include("Theorem</span> 6") }
|
154
|
+
it { should include("Lemma</span> 7") }
|
155
|
+
it { should include('Theorem <a href="#th-lorem" class="hyperref"><span class="ref">1</span></a>')}
|
156
|
+
it { should include('Theorem <a href="#th-another" class="hyperref"><span class="ref">6</span></a>')}
|
157
|
+
it { should include('Lemma <a href="#lemma-yet_another" class="hyperref"><span class="ref">7</span></a>')}
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "optional argument" do
|
161
|
+
let(:polytex) do <<-'EOS'
|
162
|
+
\chapter{A chapter}
|
163
|
+
|
164
|
+
\section{A section}
|
165
|
+
\label{sec:the_section}
|
166
|
+
|
167
|
+
\begin{theorem}[Fermat's Last Theorem]
|
168
|
+
\label{th:fermat}
|
169
|
+
It's true, I swear it!
|
170
|
+
\end{theorem}
|
171
|
+
|
172
|
+
\begin{proof}
|
173
|
+
This test is too small to contain it.
|
174
|
+
\end{proof}
|
175
|
+
EOS
|
176
|
+
end
|
177
|
+
|
178
|
+
let(:theorem_span) do
|
179
|
+
s = %(<span class="number"><span class="theorem plain_label">Theorem</span>)
|
180
|
+
s += %( 1.1 <span class="theorem_description">)
|
181
|
+
s += %((Fermat’s Last Theorem)</span>.</span>)
|
182
|
+
end
|
183
|
+
it { should include(theorem_span) }
|
184
|
+
end
|
185
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polytexnic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hartl
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -214,7 +214,6 @@ files:
|
|
214
214
|
- LICENSE.md
|
215
215
|
- README.md
|
216
216
|
- Rakefile
|
217
|
-
- arm64-darwin21
|
218
217
|
- bin/polytexnic
|
219
218
|
- lib/polytexnic.rb
|
220
219
|
- lib/polytexnic/code_inclusion.rb
|
@@ -271,6 +270,7 @@ files:
|
|
271
270
|
- spec/to_html/literal_environments/math_spec.rb
|
272
271
|
- spec/to_html/literal_environments/unicode_spec.rb
|
273
272
|
- spec/to_html/literal_environments/verbatim_spec.rb
|
273
|
+
- spec/to_html/proof_theorem_spec.rb
|
274
274
|
- spec/to_html/quotations_and_verse_spec.rb
|
275
275
|
- spec/to_html/table_of_contents_spec.rb
|
276
276
|
- spec/to_html/table_spec.rb
|
@@ -335,6 +335,7 @@ test_files:
|
|
335
335
|
- spec/to_html/literal_environments/math_spec.rb
|
336
336
|
- spec/to_html/literal_environments/unicode_spec.rb
|
337
337
|
- spec/to_html/literal_environments/verbatim_spec.rb
|
338
|
+
- spec/to_html/proof_theorem_spec.rb
|
338
339
|
- spec/to_html/quotations_and_verse_spec.rb
|
339
340
|
- spec/to_html/table_of_contents_spec.rb
|
340
341
|
- spec/to_html/table_spec.rb
|
data/arm64-darwin21
DELETED
Binary file
|