beachio-hammer 0.1.0.pre7 → 0.1.0.pre8

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: 7f49550d59c10cbcb9b8ed9dae068082d5962abd833fcf2b6b039d07ce409b5e
4
- data.tar.gz: 4e04f20a894021945d2366a00a4b4239404541d139d60ed99c93c49afff767e5
3
+ metadata.gz: 589ceae0ff8729f2cb3ecc0ee32d4838ace1138571c9c86d71ca78c17056e528
4
+ data.tar.gz: dca32a180fecf6664e35f2b6731190fc05c52fcf4833df8f0046dcb9030eb5f6
5
5
  SHA512:
6
- metadata.gz: 69c67662fc6d413a3af72e8873ad96345e8e363a87fac6657c1c10385239ab195201805c2e9d1784beae717316f15e9835ba81f1483e39f43b8028c971d03ab4
7
- data.tar.gz: 0efecd32fde11e6c6b6be017f427554cd7d57c11ad633d766c8b61be499b660cf7f61928e25dbcfd53db52cfe1ed765016c0ab0a5aa0d71a13503b921ed4f029
6
+ metadata.gz: b150e39c1399ca2ae16ca81b6bc605cf5c98ce7a4574d802a575319de6b2bbd422f70a1c4c9b710da351d0d48003960ba31658cb0968f18388f665ff40630e3a
7
+ data.tar.gz: 846a0033ac0b6a5f3da13e50c543eada11d89902c809f8db1970e90c7a03ff90e308e8ba3f752fc2f3ea1b63673ad67e30f4be5203d9d431d20ae091151d9961
@@ -439,8 +439,15 @@ module Hammer
439
439
  end
440
440
 
441
441
  def resolve_path_reference(ref)
442
+ fragment = ""
443
+ if ref.include?("#")
444
+ base, anchor = ref.split("#", 2)
445
+ ref = base
446
+ fragment = "##{anchor}" unless anchor.nil? || anchor.empty?
447
+ end
448
+
442
449
  if ref == "/"
443
- return root_relative_path
450
+ return "#{root_relative_path}#{fragment}"
444
451
  end
445
452
 
446
453
  preserve_slash = ref.end_with?("/")
@@ -462,7 +469,8 @@ module Hammer
462
469
 
463
470
  @delegate&.warning(@current_file_path, "File not found: #{ref}") if paths.empty?
464
471
 
465
- generate_context_aware_path(relative_path, preserve_trailing_slash: preserve_slash)
472
+ resolved = generate_context_aware_path(relative_path, preserve_trailing_slash: preserve_slash)
473
+ "#{resolved}#{fragment}"
466
474
  end
467
475
 
468
476
  def root_relative_path
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hammer
4
- VERSION = "0.1.0.pre7"
4
+ VERSION = "0.1.0.pre8"
5
5
  end
@@ -24,6 +24,15 @@ RSpec.describe Hammer::TagParser do
24
24
  expect(result).to include('href="../../"')
25
25
  end
26
26
 
27
+ it "preserves URL fragments when resolving @path to a page" do
28
+ parser.current_file_path = "index.html"
29
+ content = '<a href="<!-- @path work/mixfit/#team -->">'
30
+
31
+ result = parser.send(:parse, content)
32
+
33
+ expect(result).to match(/href="[^"]*mixfit\/#team"/)
34
+ end
35
+
27
36
  it "does not corrupt digits in image filenames when resolving @path" do
28
37
  parser.current_file_path = "products/forge/index.html"
29
38
  content = '<img src="<!-- @path assets/images/products/forge-2.jpg -->" />'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beachio-hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre7
4
+ version: 0.1.0.pre8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beach.io