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 +4 -4
- data/lib/hammer/tag_parser.rb +10 -2
- data/lib/hammer/version.rb +1 -1
- data/spec/path_resolution_spec.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 589ceae0ff8729f2cb3ecc0ee32d4838ace1138571c9c86d71ca78c17056e528
|
|
4
|
+
data.tar.gz: dca32a180fecf6664e35f2b6731190fc05c52fcf4833df8f0046dcb9030eb5f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b150e39c1399ca2ae16ca81b6bc605cf5c98ce7a4574d802a575319de6b2bbd422f70a1c4c9b710da351d0d48003960ba31658cb0968f18388f665ff40630e3a
|
|
7
|
+
data.tar.gz: 846a0033ac0b6a5f3da13e50c543eada11d89902c809f8db1970e90c7a03ff90e308e8ba3f752fc2f3ea1b63673ad67e30f4be5203d9d431d20ae091151d9961
|
data/lib/hammer/tag_parser.rb
CHANGED
|
@@ -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
|
data/lib/hammer/version.rb
CHANGED
|
@@ -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 -->" />'
|