polytexnic 1.9.1 → 1.10.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: 1b5dc960f818c0dd1342080a1d886582ecdd67a8ccf7688cae86e79c18309278
4
- data.tar.gz: 24f2ce7be9a136c54aacab4a78d47ff17598182c8095038c95c6a215ab0c45f4
3
+ metadata.gz: 97df7a0f9860c92ab7a0f07d95c8aa4b1fd6a0416f0c64cdf1179d02884b21b9
4
+ data.tar.gz: 2d8f24f8eb0d2be40e1fd37fa81599df119684560e807ad8de6b151fedb36eb0
5
5
  SHA512:
6
- metadata.gz: e972fa4b84925ef11ac37e246184811bd5630ac3b6036f9609a67dd5816be0e04c53ea15db9e440571f596ad341e88316eeaf488137c61da8395503f0ea0fba1
7
- data.tar.gz: 1140d6a5159c5c166a8eb3c7db75882a93782b976721e1bac76a7c29439a702a76c1cfcbdc33166090c53adcb2b013663e55a63fb5849147621516a697149c09
6
+ metadata.gz: b33bea198951ee6f66a4f9e90127e440f406b8cc7f54a5b07ca07142a365f1cdb971a15f6be415c8230dc7959e8a5a3eb4fa260efe88906db1c983581fb97181
7
+ data.tar.gz: 7e29667969dcd57f6dfb4bde2ce175d2c0510402658a3238efbccf46fae6bf486c230bab3290926dbfd3d5cefa8e473568d5e022c2c459bdc86472e73e29a31c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polytexnic (1.9.1)
4
+ polytexnic (1.10.0)
5
5
  json (= 2.3.1)
6
6
  kramdown (= 2.4.0)
7
7
  msgpack (= 1.2.10)
@@ -23,14 +23,9 @@ module Polytexnic
23
23
  %w[align* eqnarray* equation* gather* multline*]
24
24
  end
25
25
 
26
- def math_environments_starred
27
- %w[align* eqnarray* equation* gather* multline*]
28
- end
29
-
30
26
  # Returns a list of all literal types.
31
27
  def literal_types
32
- %w[verbatim Vertatim code metacode] +
33
- math_environments
28
+ %w[verbatim Vertatim code metacode] + math_environments
34
29
  end
35
30
 
36
31
  # Handles environments that should be passed through the pipeline intact.
@@ -83,8 +78,6 @@ module Polytexnic
83
78
  literal_type = line.literal_type
84
79
  skip = line.math_environment? || latex
85
80
  if line.math_environment? && !latex
86
- # puts line
87
- # puts "****"
88
81
  output << '\begin{xmlelement*}{equation}'
89
82
  if line.starred?
90
83
  output << '\begin{equation*}'
@@ -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,47 @@ 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)
776
+ # Extract theorem content (if any). This super-hacky.
777
+ # th_regex = /data-tralics-id=".*?"><strong>.*?<\/strong>(.*?)<\/div>/m
778
+ # theorem_content = node.to_xhtml.scan(th_regex).flatten.first
779
+ # theorem_content.gsub!("\n\n", '') if theorem_content
780
+ # raise theorem_content
750
781
  heading = node.at_css('p')
751
782
  heading.attributes.each do |key, value|
752
783
  node.set_attribute(key, value)
@@ -754,18 +785,61 @@ module Polytexnic
754
785
  end
755
786
  heading.name = 'div'
756
787
  heading['class'] = 'heading'
757
-
758
- number = heading.at_css('strong')
759
- number.content = number.content.sub!('0.', '') if article?
760
- number.name = 'span'
761
- number['class'] = 'number'
762
- if css_class == 'codelisting'
788
+ full_number = heading.at_css('strong')
789
+ full_number.name = 'span'
790
+ full_number['class'] = 'number'
791
+ # E.g., "Theorem 1.1 (Fermat’s Last Theorem)"
792
+ # label = "Theorem"
793
+ # actual_number_etc = ["1.1", "Fermat’s Last Theorem"]
794
+ full_label_content = full_number.content.strip
795
+ full_number.content = ''
796
+ content_array = full_label_content.split
797
+ label, actual_number_etc = content_array.shift, content_array
798
+ element_label = Nokogiri::XML::Node.new('span', heading)
799
+ # Make span for element's style label.
800
+ # <span class="plain_label">Theorem</span>
801
+ element_label['class'] = "#{element_class(css_class)}_label"
802
+ if article?
803
+ actual_number = actual_number_etc.first.sub!('0.', '')
804
+ else
805
+ actual_number = actual_number_etc.first
806
+ end
807
+ element_label.content = label
808
+ full_number << element_label
809
+ full_number << Nokogiri::XML::Text.new(" #{actual_number}", heading)
810
+ # Handle optional argument to theorems.
811
+ # E.g., \begin{theorem}[Fermat's Last Theorem]
812
+ environment_type = label.downcase
813
+ if theorem_environment?(environment_type)
814
+ # Theorem headings should be paragraphs instead of divs.
815
+ heading.name = 'p'
816
+ # This will be nonempty only if there's an optional argument
817
+ # as in \begin{theorem}[optional argument].
818
+ optarg = actual_number_etc[1..-1].join(" ")
819
+ unless optarg.empty?
820
+ # Add a span to parenthetical content for styling purpsoes.
821
+ # This handles things like "Theorem 1.1 (Fermat’s Last Theorem)".
822
+ theorem_description = Nokogiri::XML::Node.new('span', heading)
823
+ theorem_description['class'] = 'theorem_description'
824
+ theorem_description.content = optarg
825
+ full_number << Nokogiri::XML::Text.new(' ', heading)
826
+ full_number << theorem_description
827
+ end
828
+ full_number << Nokogiri::XML::Text.new('.', heading)
829
+ # # We remove all paragraphs and append the previously extracted
830
+ # # theorem content. The desired numbered heading is just the
831
+ # # first line, so we split on newline and take the first element.
832
+ # number_html = full_number.to_xhtml.split("\n").first
833
+ # full_number.inner_html = number_html + theorem_content
834
+ elsif css_class == 'codelisting'
763
835
  description = node.at_css('.description').content
764
- number.content += ':' unless description.empty?
836
+ unless description.empty?
837
+ full_number << Nokogiri::XML::Text.new(':', heading)
838
+ end
765
839
  else
766
- number.content += '.'
840
+ full_number << Nokogiri::XML::Text.new('.', heading)
767
841
  end
768
-
842
+ # raise heading.to_xhtml
769
843
  heading
770
844
  end
771
845
 
@@ -814,6 +888,23 @@ module Polytexnic
814
888
  end
815
889
  end
816
890
 
891
+ # Processes theorems, lemmas, etc.
892
+ def theorems_lemmas_etc(doc)
893
+ @supported_theorem_types.each do |theorem_type|
894
+ doc.xpath("//#{theorem_type}").each do |node|
895
+ build_heading(node, theorem_type)
896
+ end
897
+ end
898
+ end
899
+
900
+ # Processes proofs.
901
+ def proofs(doc)
902
+ doc.xpath('//proof').each do |node|
903
+ node.name = 'div'
904
+ node['class'] = 'proof'
905
+ end
906
+ end
907
+
817
908
  # Processes centered elements.
818
909
  def center(doc)
819
910
  doc.xpath('//center').each do |node|
@@ -912,11 +1003,11 @@ module Polytexnic
912
1003
 
913
1004
  # Creates linked cross-references.
914
1005
  def make_cross_references(doc)
915
- # build numbering tree
1006
+ # Build numbering tree.
916
1007
  doc.xpath('//*[@data-tralics-id]').each do |node|
917
1008
  node['data-number'] = formatted_number(node)
918
1009
  clean_node node, 'id-text'
919
- # Add number span
1010
+ # Add number span.
920
1011
  if (head = node.css('h1 a, h2 a, h3 a').first)
921
1012
  el = doc.create_element 'span'
922
1013
  el.content = section_label(node)
@@ -1003,6 +1094,7 @@ module Polytexnic
1003
1094
  @figure = 0
1004
1095
  @table = 0
1005
1096
  @aside = 0
1097
+ @theorem = 0
1006
1098
  @cha = article? ? nil : node['id-text']
1007
1099
  elsif node['class'] == 'section'
1008
1100
  @sec = node['id-text']
@@ -1028,6 +1120,9 @@ module Polytexnic
1028
1120
  elsif node.name == 'figure'
1029
1121
  @figure = ref_number(node, @cha, @figure)
1030
1122
  label_number(@cha, @figure)
1123
+ elsif theorem_environment?(node['class'])
1124
+ @theorem = number_from_id(node['id-text'])
1125
+ label_number(@cha, @theorem)
1031
1126
  end
1032
1127
  end
1033
1128
 
@@ -18,7 +18,9 @@ module Polytexnic
18
18
  # Escapes backslashes even more.
19
19
  # Have I mentioned how much I hate backslashes?
20
20
  def extra_escape(string)
21
- string.gsub('\\', '\\\\\\')
21
+ string.gsub('\\', '\\\\\\').
22
+ gsub("\\'", '\\\\' + "'").
23
+ gsub('\\\\\\', '\\\\\\')
22
24
  end
23
25
  end
24
26
  end
@@ -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 is was originaly because kramdown outputs longtables by default,
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}'
@@ -149,13 +149,16 @@ module Polytexnic
149
149
  \newcommand{\newunicodechar}[2]{}
150
150
  \newcommand{\extrafloats}[1]{}
151
151
  EOS
152
- custom_commands = <<-EOS
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
- [base_commands, custom_commands].join("\n")
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.
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.9.1"
2
+ VERSION = "1.10.0"
3
3
  end
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?
@@ -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:</span>' }
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>' }
@@ -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(:polytex) { '\chapter{Foo bar}' + "\n" + aside}
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
@@ -103,6 +103,19 @@ end
103
103
 
104
104
  it { should resemble polytex }
105
105
 
106
+ context "align* environment" do
107
+ let(:polytex) do <<-'EOS'
108
+ \begin{align*}
109
+ x &= 1\\
110
+ y & = 2 \\
111
+ x + y &= 3
112
+ \end{align*}
113
+ EOS
114
+ end
115
+
116
+ it { should resemble polytex }
117
+ end
118
+
106
119
  context "containing an example of highlighted code" do
107
120
  let(:polytex) do <<-'EOS'
108
121
  \begin{verbatim}
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.9.1
4
+ version: 1.10.0
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-08-20 00:00:00.000000000 Z
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