Repository: kovetskiy/mark
Pull request #401 (2023-12-18 16:28:41)

Fix layout section attribute tags
I was finding that without `ac:` prefix on the `type` attribute that the attribute was being ignored.

I wondered if the attribute had been expected without the prefix in other versions of confluence but is appears this is correct in all the versions currently documented.

- [8.7](https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html#ConfluenceStorageFormat-Pagelayouts)
- [8.0](https://confluence.atlassian.com/conf80/confluence-storage-format-1188407674.html#ConfluenceStorageFormat-Pagelayouts)
- [7.16](https://confluence.atlassian.com/conf716/confluence-storage-format-1108682045.html#ConfluenceStorageFormat-Pagelayouts)

Elsewhere in the mark codebase the `ac:` prefix used too. I've only tested this on a single confluence version but it seems like it should be correct for other versions.


Patch:
diff --git a/go.mod b/go.mod
index 9e58755..eb6219c 100644
--- a/go.mod
+++ b/go.mod
@@ -13,7 +13,7 @@ require (
 	github.com/stretchr/testify v1.8.4
 	github.com/urfave/cli/v2 v2.26.0
 	github.com/yuin/goldmark v1.5.6
-	golang.org/x/tools v0.16.0
+	golang.org/x/tools v0.16.1
 	gopkg.in/yaml.v3 v3.0.1
 )
 
diff --git a/go.sum b/go.sum
index 48d18ee..7b8a325 100644
--- a/go.sum
+++ b/go.sum
@@ -66,8 +66,8 @@ github.com/zazab/zhash v0.0.0-20210630080733-6e809466f8d3/go.mod h1:NtepZ8TEXErP
 golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
 golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM=
-golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
+golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=
+golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/pkg/mark/renderer/htmlblock.go b/pkg/mark/renderer/htmlblock.go
index 7f900b5..acb3206 100644
--- a/pkg/mark/renderer/htmlblock.go
+++ b/pkg/mark/renderer/htmlblock.go
@@ -45,22 +45,22 @@ func (r *ConfluenceHTMLBlockRenderer) renderHTMLBlock(w util.BufWriter, source [
 			_, _ = w.WriteString("</ac:layout>\n")
 			return ast.WalkContinue, nil
 		case "<!-- ac:layout-section type:single -->":
-			_, _ = w.WriteString("<ac:layout-section type=\"single\">\n")
+			_, _ = w.WriteString("<ac:layout-section ac:type=\"single\">\n")
 			return ast.WalkContinue, nil
 		case "<!-- ac:layout-section type:two_equal -->":
-			_, _ = w.WriteString("<ac:layout-section type=\"two_equal\">\n")
+			_, _ = w.WriteString("<ac:layout-section ac:type=\"two_equal\">\n")
 			return ast.WalkContinue, nil
 		case "<!-- ac:layout-section type:two_left_sidebar -->":
-			_, _ = w.WriteString("<ac:layout-section type=\"two_left_sidebar\">\n")
+			_, _ = w.WriteString("<ac:layout-section ac:type=\"two_left_sidebar\">\n")
 			return ast.WalkContinue, nil
 		case "<!-- ac:layout-section type:two_right_sidebar -->":
-			_, _ = w.WriteString("<ac:layout-section type=\"two_right_sidebar\">\n")
+			_, _ = w.WriteString("<ac:layout-section ac:type=\"two_right_sidebar\">\n")
 			return ast.WalkContinue, nil
 		case "<!-- ac:layout-section type:three -->":
-			_, _ = w.WriteString("<ac:layout-section type=\"three\">\n")
+			_, _ = w.WriteString("<ac:layout-section ac:type=\"three\">\n")
 			return ast.WalkContinue, nil
 		case "<!-- ac:layout-section type:three_with_sidebars -->":
-			_, _ = w.WriteString("<ac:layout-section type=\"three_with_sidebars\">\n")
+			_, _ = w.WriteString("<ac:layout-section ac:type=\"three_with_sidebars\">\n")
 			return ast.WalkContinue, nil
 		case "<!-- ac:layout-section end -->":
 			_, _ = w.WriteString("</ac:layout-section>\n")


Test patch:
diff --git a/pkg/mark/testdata/pagelayout-droph1.html b/pkg/mark/testdata/pagelayout-droph1.html
index 66f5783..a244202 100644
--- a/pkg/mark/testdata/pagelayout-droph1.html
+++ b/pkg/mark/testdata/pagelayout-droph1.html
@@ -1,5 +1,5 @@
 <ac:layout>
-<ac:layout-section type="three_with_sidebars">
+<ac:layout-section ac:type="three_with_sidebars">
 <ac:layout-cell>
 <p>More Content</p>
 </ac:layout-cell>
@@ -10,7 +10,7 @@
 <p>Even More Content</p>
 </ac:layout-cell>
 </ac:layout-section>
-<ac:layout-section type="single">
+<ac:layout-section ac:type="single">
 <ac:layout-cell>
 <p>Still More Content</p>
 </ac:layout-cell>
diff --git a/pkg/mark/testdata/pagelayout-stripnewlines.html b/pkg/mark/testdata/pagelayout-stripnewlines.html
index 66f5783..a244202 100644
--- a/pkg/mark/testdata/pagelayout-stripnewlines.html
+++ b/pkg/mark/testdata/pagelayout-stripnewlines.html
@@ -1,5 +1,5 @@
 <ac:layout>
-<ac:layout-section type="three_with_sidebars">
+<ac:layout-section ac:type="three_with_sidebars">
 <ac:layout-cell>
 <p>More Content</p>
 </ac:layout-cell>
@@ -10,7 +10,7 @@
 <p>Even More Content</p>
 </ac:layout-cell>
 </ac:layout-section>
-<ac:layout-section type="single">
+<ac:layout-section ac:type="single">
 <ac:layout-cell>
 <p>Still More Content</p>
 </ac:layout-cell>
diff --git a/pkg/mark/testdata/pagelayout.html b/pkg/mark/testdata/pagelayout.html
index 66f5783..a244202 100644
--- a/pkg/mark/testdata/pagelayout.html
+++ b/pkg/mark/testdata/pagelayout.html
@@ -1,5 +1,5 @@
 <ac:layout>
-<ac:layout-section type="three_with_sidebars">
+<ac:layout-section ac:type="three_with_sidebars">
 <ac:layout-cell>
 <p>More Content</p>
 </ac:layout-cell>
@@ -10,7 +10,7 @@
 <p>Even More Content</p>
 </ac:layout-cell>
 </ac:layout-section>
-<ac:layout-section type="single">
+<ac:layout-section ac:type="single">
 <ac:layout-cell>
 <p>Still More Content</p>
 </ac:layout-cell>