Skip to content

Commit 30f0802

Browse files
committed
markup/asciidocext: Correct attribute derivation for workingFolderCurrent
Fixes issues with `outdir`, `imagesoutdir`, and `imagesdir` when `markup.asciidocext.workingFolderCurrent` is active. The prior logic failed in several scenarios due to improper attribute derivation from the page's relative permalink. The updated logic now correctly handles: - Multi-byte characters - Multilingual multi-host sites - Site builds from a subdirectory - Pages using ugly URLs Closes #9202 Closes #10183 Closes #10473
1 parent 2c80dee commit 30f0802

File tree

12 files changed

+1578
-188
lines changed

12 files changed

+1578
-188
lines changed

‎htesting/test_helpers.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func IsGitHubAction() bool {
121121
}
122122

123123
// SupportsAll reports whether the running system supports all Hugo features,
124-
// e.g. Asciidoc, Pandoc etc.
124+
// e.g. AsciiDoc, Pandoc etc.
125125
func SupportsAll() bool {
126126
return IsGitHubAction() || os.Getenv("CI_LOCAL") != ""
127127
}

‎hugolib/page_test.go‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,12 @@ func testAllMarkdownEnginesForPages(t *testing.T,
368368
shouldExecute func() bool
369369
}{
370370
{"md", func() bool { return true }},
371-
{"ad", func() bool { return asciidocext.Supports() }},
371+
{"ad", func() bool {
372+
if ok, _ := asciidocext.Supports(); ok {
373+
return true
374+
}
375+
return false
376+
}},
372377
{"rst", func() bool { return !htesting.IsRealCI() && rst.Supports() }},
373378
}
374379

@@ -591,7 +596,7 @@ func TestPageSummary(t *testing.T) {
591596
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
592597
p := pages[0]
593598
checkPageTitle(t, p, "SimpleWithoutSummaryDelimiter")
594-
// Source is not Asciidoctor- or RST-compatible so don't test them
599+
// Source is not AsciiDoc- or RST-compatible so don't test them
595600
if ext != "ad" && ext != "rst" {
596601
checkPageContent(t, p, normalizeExpected(ext, "<p><a href=\"https://lipsum.com/\">Lorem ipsum</a> dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>\n\n<p>Additional text.</p>\n\n<p>Further text.</p>\n"), ext)
597602
checkPageSummary(t, p, normalizeExpected(ext, "<p><a href=\"https://lipsum.com/\">Lorem ipsum</a> dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><p>Additional text.</p>"), ext)
@@ -621,7 +626,7 @@ func TestPageWithSummaryParameter(t *testing.T) {
621626
p := pages[0]
622627
checkPageTitle(t, p, "SimpleWithSummaryParameter")
623628
checkPageContent(t, p, normalizeExpected(ext, "<p>Some text.</p>\n\n<p>Some more text.</p>\n"), ext)
624-
// Summary is not Asciidoctor- or RST-compatible so don't test them
629+
// Summary is not AsciiDoc- or RST-compatible so don't test them
625630
if ext != "ad" && ext != "rst" {
626631
checkPageSummary(t, p, normalizeExpected(ext, "Page with summary parameter and <a href=\"http://www.example.com/\">a link</a>"), ext)
627632
}

‎hugolib/pagesfromdata/pagesfromgotmpl_integration_test.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ docs/p1/sub/mymixcasetext2.txt
132132
b.AssertFileContent("public/docs/p3/index.html", "<strong>Hello World Default</strong>")
133133
}
134134

135-
func TestPagesFromGoTmplAsciidocAndSimilar(t *testing.T) {
135+
func TestPagesFromGoTmplAsciiDocAndSimilar(t *testing.T) {
136136
files := `
137137
-- hugo.toml --
138138
disableKinds = ["taxonomy", "term", "rss", "sitemap"]
@@ -153,7 +153,7 @@ allow = ['asciidoctor', 'pandoc','rst2html', 'python']
153153

154154
b := hugolib.Test(t, files)
155155

156-
if asciidocext.Supports() {
156+
if ok, _ := asciidocext.Supports(); ok {
157157
b.AssertFileContent("public/docs/asciidoc/index.html",
158158
"Mark my words, <mark>automation is essential</mark>",
159159
"Path: /docs/asciidoc|",
@@ -511,7 +511,7 @@ baseURL = "https://example.com"
511511
func TestPagesFromGoTmplCascade(t *testing.T) {
512512
t.Parallel()
513513

514-
files := `
514+
files := `
515515
-- hugo.toml --
516516
disableKinds = ["taxonomy", "term", "rss", "sitemap"]
517517
baseURL = "https://example.com"
@@ -531,7 +531,7 @@ baseURL = "https://example.com"
531531
func TestPagesFromGoBuildOptions(t *testing.T) {
532532
t.Parallel()
533533

534-
files := `
534+
files := `
535535
-- hugo.toml --
536536
disableKinds = ["taxonomy", "term", "rss", "sitemap"]
537537
baseURL = "https://example.com"
@@ -719,11 +719,11 @@ func TestPagesFromGoTmplMenusMap(t *testing.T) {
719719
-- hugo.toml --
720720
disableKinds = ['rss','section','sitemap','taxonomy','term']
721721
-- content/_content.gotmpl --
722-
{{ $menu1 := dict
722+
{{ $menu1 := dict
723723
"parent" "main-page"
724724
"identifier" "id1"
725725
}}
726-
{{ $menu2 := dict
726+
{{ $menu2 := dict
727727
"parent" "main-page"
728728
"identifier" "id2"
729729
}}
@@ -934,7 +934,7 @@ Title: {{ .Title }}|Content: {{ .Content }}|
934934
func TestPagesFromGoTmplHome(t *testing.T) {
935935
t.Parallel()
936936

937-
files := `
937+
files := `
938938
-- hugo.toml --
939939
disableKinds = ["taxonomy", "term", "rss", "sitemap"]
940940
baseURL = "https://example.com"

‎hugolib/rebuild_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,9 +1838,9 @@ Myotherpartial Inline.|{{ .Title }}|
18381838
b.AssertFileContent("public/index.html", "My inline partial in all Edited.")
18391839
}
18401840

1841-
func TestRebuildEditAsciidocContentFile(t *testing.T) {
1842-
if !asciidocext.Supports() {
1843-
t.Skip("skip asciidoc")
1841+
func TestRebuildEditAsciiDocContentFile(t *testing.T) {
1842+
if ok, err := asciidocext.Supports(); !ok {
1843+
t.Skip(err)
18441844
}
18451845
files := `
18461846
-- hugo.toml --

‎hugolib/securitypolicies_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ func TestSecurityPolicies(t *testing.T) {
7474
testVariant(c, cb, "")
7575
})
7676

77-
c.Run("Asciidoc, denied", func(c *qt.C) {
77+
c.Run("AsciiDoc, denied", func(c *qt.C) {
7878
c.Parallel()
79-
if !asciidocext.Supports() {
80-
c.Skip()
79+
if ok, err := asciidocext.Supports(); !ok {
80+
c.Skip(err)
8181
}
8282

8383
cb := func(b *sitesBuilder) {

0 commit comments

Comments
 (0)