polytexnic 1.1.4 → 1.1.5

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
  SHA1:
3
- metadata.gz: ea14cfbcb4bdd08795b37315bd7187585f12030c
4
- data.tar.gz: 335d87363e054d2fef85f3fe4609874e7811b4f5
3
+ metadata.gz: b9365791fe43e93ce220fb5b947dc2d0ee8b0739
4
+ data.tar.gz: 518c1e4d4ce55ecc0643472428295dbe5df6a538
5
5
  SHA512:
6
- metadata.gz: 04ba7029301eedf24b8e5fcc1b0b23c9e23e1f1169b5e2c0d09e7c9a78ea40e52e4e385589c8625f823eda953769de55a3d432158f94dcf7c95aeeb83c92fcac
7
- data.tar.gz: d46e70f38f8555c482e44f19703b8547c503647007be4c6e8078344fcf9d669a7992fa321454d2e608e85c7c22f1a4d17330a6215c14221d8a5061623d4f3abc
6
+ metadata.gz: f67be04f1a31890d4e22916be834c0793a6e9894fb8ab526fb9783380a2acf218b39dacdeaf3f150da7e317608174268d5c471c3f41c723ae8ab0b7c6575a617
7
+ data.tar.gz: 738bd6741d7e7c109c7ac7c603f8c3f1b03a74f759382319f3a1e7f6d26f89173b533a5e726728daee19010ec66e934e05541369f15fb306016228bcadfddbd9
@@ -414,21 +414,22 @@ module Polytexnic
414
414
  # Update: Hacked a solution to handle the uncommon case of a footnote
415
415
  # inside a section* environment.
416
416
  def chapter_number(node)
417
- if section_star?(node)
418
- return chapter_number(section_star_chapter(node))
419
- end
420
417
  return 0 if article?
421
418
  number = node['data-number']
422
419
  if number && !number.empty?
423
420
  number.split('.').first.to_i
421
+ elsif section_star?(node)
422
+ chapter_number(section_star_chapter(node))
424
423
  else
425
424
  chapter_number(node.parent) rescue nil
426
425
  end
427
426
  end
428
427
 
429
- # Returns true if node comes from a '\section*'.
428
+ # Returns true if node is inside section*.
430
429
  def section_star?(node)
431
430
  begin
431
+ # puts (val = node.parent.parent.attributes['class'].value) + '*******'
432
+ # puts node.parent.parent.parent.parent.children[1] if val == 'section-star'
432
433
  node.parent.parent.attributes['class'].value == 'section-star'
433
434
  rescue
434
435
  false
@@ -437,7 +438,12 @@ module Polytexnic
437
438
 
438
439
  # Returns the chapter node for a section*.
439
440
  def section_star_chapter(node)
440
- node.parent.parent.parent.children[1]
441
+ section_star = node.parent.parent
442
+ potential_chapter = section_star
443
+ # Keep accessing previous siblings until we hit a chapter.
444
+ while (potential_chapter = potential_chapter.previous_sibling) do
445
+ return potential_chapter if chapter?(potential_chapter)
446
+ end
441
447
  end
442
448
 
443
449
  # Handles logos for TeX and LaTeX.
@@ -920,8 +926,9 @@ module Polytexnic
920
926
 
921
927
  # Returns true if the node represents a chapter.
922
928
  def chapter?(node)
923
- is_section = node['data-number'].match(/\./)
924
- !(@cha.nil? || is_section)
929
+ attributes = node.attributes
930
+ attributes && attributes['class'] &&
931
+ attributes['class'].value =~ /chapter/
925
932
  end
926
933
 
927
934
  # Returns the name to use for chapters.
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.1.4"
2
+ VERSION = "1.1.5"
3
3
  end
@@ -178,13 +178,23 @@ describe 'Polytexnic::Pipeline#to_html' do
178
178
 
179
179
  describe "footnote inside a section*" do
180
180
  let(:polytex) do <<-'EOS'
181
+ \chapter{The first}
182
+
183
+ Test
184
+
185
+ \chapter{The second}
186
+
187
+ Also test
188
+
181
189
  \chapter{Lorem}
190
+
182
191
  Foo bar
192
+
183
193
  \section*{Baz}
184
194
 
185
195
  Lorem ipsum.\footnote{Dolor sit amet.}
186
196
  EOS
187
197
  end
188
- it { should include 'cha-1_footnote' }
198
+ it { should include 'cha-3_footnote' }
189
199
  end
190
200
  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.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl