mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-03 14:47:38 +08:00
Compare commits
No commits in common. "master" and "v16.3.0" have entirely different histories.
@ -56,12 +56,11 @@ Also, optional following headers are supported:
|
|||||||
* blogpost: [Blog post](https://confluence.atlassian.com/doc/blog-posts-834222533.html) in `Space`. Cannot have `Parent`(s)
|
* blogpost: [Blog post](https://confluence.atlassian.com/doc/blog-posts-834222533.html) in `Space`. Cannot have `Parent`(s)
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
<!-- Content-Appearance: (full-width|fixed|default) -->
|
<!-- Content-Appearance: (full-width|fixed) -->
|
||||||
```
|
```
|
||||||
|
|
||||||
* (default) full-width: content will fill the full page width
|
* (default) full-width: content will fill the full page width
|
||||||
* fixed: content will be rendered in a fixed narrow view
|
* fixed: content will be rendered in a fixed narrow view
|
||||||
* default: sets the Confluence property value to `"default"`, which is the narrow layout as set by the Confluence UI. Note: `fixed` maps to a different Confluence property value and can cause misaligned page title and body content — use `default` instead for the narrow layout.
|
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
<!-- Sidebar: <h2>Test</h2> -->
|
<!-- Sidebar: <h2>Test</h2> -->
|
||||||
@ -877,7 +876,7 @@ GLOBAL OPTIONS:
|
|||||||
--space string use specified space key. If the space key is not specified, it must be set in the page metadata. [$MARK_SPACE]
|
--space string use specified space key. If the space key is not specified, it must be set in the page metadata. [$MARK_SPACE]
|
||||||
--parents string A list containing the parents of the document separated by parents-delimiter (default: '/'). These will be prepended to the ones defined in the document itself. [$MARK_PARENTS]
|
--parents string A list containing the parents of the document separated by parents-delimiter (default: '/'). These will be prepended to the ones defined in the document itself. [$MARK_PARENTS]
|
||||||
--parents-delimiter string The delimiter used for the parents list (default: "/") [$MARK_PARENTS_DELIMITER]
|
--parents-delimiter string The delimiter used for the parents list (default: "/") [$MARK_PARENTS_DELIMITER]
|
||||||
--content-appearance string default content appearance for pages without a Content-Appearance header. Possible values: full-width, fixed, default. [$MARK_CONTENT_APPEARANCE]
|
--content-appearance string default content appearance for pages without a Content-Appearance header. Possible values: full-width, fixed. [$MARK_CONTENT_APPEARANCE]
|
||||||
--mermaid-scale float defines the scaling factor for mermaid renderings. (default: 1) [$MARK_MERMAID_SCALE]
|
--mermaid-scale float defines the scaling factor for mermaid renderings. (default: 1) [$MARK_MERMAID_SCALE]
|
||||||
--include-path string Path for shared includes, used as a fallback if the include doesn't exist in the current directory. [$MARK_INCLUDE_PATH]
|
--include-path string Path for shared includes, used as a fallback if the include doesn't exist in the current directory. [$MARK_INCLUDE_PATH]
|
||||||
--changes-only Avoids re-uploading pages that haven't changed since the last run. [$MARK_CHANGES_ONLY]
|
--changes-only Avoids re-uploading pages that haven't changed since the last run. [$MARK_CHANGES_ONLY]
|
||||||
|
|||||||
@ -49,13 +49,6 @@ func ResolveAttachments(
|
|||||||
attachments []Attachment,
|
attachments []Attachment,
|
||||||
) ([]Attachment, error) {
|
) ([]Attachment, error) {
|
||||||
for i := range attachments {
|
for i := range attachments {
|
||||||
// Skip checksum computation if already set (e.g. by mermaid/d2 renderers
|
|
||||||
// which use the source content as the stable checksum rather than the
|
|
||||||
// rendered PNG bytes, which may be non-deterministic across environments).
|
|
||||||
if attachments[i].Checksum != "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
checksum, err := GetChecksum(bytes.NewReader(attachments[i].FileBytes))
|
checksum, err := GetChecksum(bytes.NewReader(attachments[i].FileBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to get checksum for attachment %q: %w", attachments[i].Name, err)
|
return nil, fmt.Errorf("unable to get checksum for attachment %q: %w", attachments[i].Name, err)
|
||||||
|
|||||||
4
go.mod
4
go.mod
@ -8,14 +8,14 @@ require (
|
|||||||
github.com/chromedp/chromedp v0.15.1
|
github.com/chromedp/chromedp v0.15.1
|
||||||
github.com/dreampuf/mermaid.go v0.2.0
|
github.com/dreampuf/mermaid.go v0.2.0
|
||||||
github.com/kovetskiy/gopencils v0.0.0-20250404051442-0b776066936a
|
github.com/kovetskiy/gopencils v0.0.0-20250404051442-0b776066936a
|
||||||
github.com/rs/zerolog v1.35.1
|
github.com/rs/zerolog v1.35.0
|
||||||
github.com/stefanfritsch/goldmark-admonitions v1.1.1
|
github.com/stefanfritsch/goldmark-admonitions v1.1.1
|
||||||
github.com/stretchr/testify v1.11.1
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/urfave/cli-altsrc/v3 v3.1.0
|
github.com/urfave/cli-altsrc/v3 v3.1.0
|
||||||
github.com/urfave/cli/v3 v3.8.0
|
github.com/urfave/cli/v3 v3.8.0
|
||||||
github.com/yuin/goldmark v1.8.2
|
github.com/yuin/goldmark v1.8.2
|
||||||
go.yaml.in/yaml/v3 v3.0.4
|
go.yaml.in/yaml/v3 v3.0.4
|
||||||
golang.org/x/text v0.36.0
|
golang.org/x/text v0.35.0
|
||||||
oss.terrastruct.com/d2 v0.7.1
|
oss.terrastruct.com/d2 v0.7.1
|
||||||
oss.terrastruct.com/util-go v0.0.0-20250213174338-243d8661088a
|
oss.terrastruct.com/util-go v0.0.0-20250213174338-243d8661088a
|
||||||
)
|
)
|
||||||
|
|||||||
8
go.sum
8
go.sum
@ -78,8 +78,8 @@ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc
|
|||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||||
github.com/rs/zerolog v1.35.1 h1:m7xQeoiLIiV0BCEY4Hs+j2NG4Gp2o2KPKmhnnLiazKI=
|
github.com/rs/zerolog v1.35.0 h1:VD0ykx7HMiMJytqINBsKcbLS+BJ4WYjz+05us+LRTdI=
|
||||||
github.com/rs/zerolog v1.35.1/go.mod h1:EjML9kdfa/RMA7h/6z6pYmq1ykOuA8/mjWaEvGI+jcw=
|
github.com/rs/zerolog v1.35.0/go.mod h1:EjML9kdfa/RMA7h/6z6pYmq1ykOuA8/mjWaEvGI+jcw=
|
||||||
github.com/stefanfritsch/goldmark-admonitions v1.1.1 h1:SncsICdQrIYYaq02Ta+zyc9gNmMfYqQH2qwLSCJYxA4=
|
github.com/stefanfritsch/goldmark-admonitions v1.1.1 h1:SncsICdQrIYYaq02Ta+zyc9gNmMfYqQH2qwLSCJYxA4=
|
||||||
github.com/stefanfritsch/goldmark-admonitions v1.1.1/go.mod h1:cOZK5O0gE6eWfpxTdjGUmeONW2IL9j3Zujv3KlZWlLo=
|
github.com/stefanfritsch/goldmark-admonitions v1.1.1/go.mod h1:cOZK5O0gE6eWfpxTdjGUmeONW2IL9j3Zujv3KlZWlLo=
|
||||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
@ -134,8 +134,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
|
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
|
||||||
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
|
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
|||||||
@ -46,7 +46,6 @@ type Meta struct {
|
|||||||
const (
|
const (
|
||||||
FullWidthContentAppearance = "full-width"
|
FullWidthContentAppearance = "full-width"
|
||||||
FixedContentAppearance = "fixed"
|
FixedContentAppearance = "fixed"
|
||||||
DefaultContentAppearance = "default"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -123,12 +122,9 @@ func ExtractMeta(data []byte, spaceFromCli string, titleFromH1 bool, titleFromFi
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
case ContentAppearance:
|
case ContentAppearance:
|
||||||
switch strings.TrimSpace(value) {
|
if strings.TrimSpace(value) == FixedContentAppearance {
|
||||||
case FixedContentAppearance:
|
|
||||||
meta.ContentAppearance = FixedContentAppearance
|
meta.ContentAppearance = FixedContentAppearance
|
||||||
case DefaultContentAppearance:
|
} else {
|
||||||
meta.ContentAppearance = DefaultContentAppearance
|
|
||||||
default:
|
|
||||||
meta.ContentAppearance = FullWidthContentAppearance
|
meta.ContentAppearance = FullWidthContentAppearance
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,12 +166,9 @@ func ExtractMeta(data []byte, spaceFromCli string, titleFromH1 bool, titleFromFi
|
|||||||
|
|
||||||
// Use the global content appearance flag if the header is not set in the document
|
// Use the global content appearance flag if the header is not set in the document
|
||||||
if meta != nil && defaultContentAppearance != "" && meta.ContentAppearance == "" {
|
if meta != nil && defaultContentAppearance != "" && meta.ContentAppearance == "" {
|
||||||
switch strings.TrimSpace(defaultContentAppearance) {
|
if strings.TrimSpace(defaultContentAppearance) == FixedContentAppearance {
|
||||||
case FixedContentAppearance:
|
|
||||||
meta.ContentAppearance = FixedContentAppearance
|
meta.ContentAppearance = FixedContentAppearance
|
||||||
case DefaultContentAppearance:
|
} else {
|
||||||
meta.ContentAppearance = DefaultContentAppearance
|
|
||||||
default:
|
|
||||||
meta.ContentAppearance = FullWidthContentAppearance
|
meta.ContentAppearance = FullWidthContentAppearance
|
||||||
}
|
}
|
||||||
} else if meta != nil && meta.ContentAppearance == "" {
|
} else if meta != nil && meta.ContentAppearance == "" {
|
||||||
|
|||||||
@ -88,22 +88,4 @@ func TestExtractMetaContentAppearance(t *testing.T) {
|
|||||||
assert.NotNil(t, meta)
|
assert.NotNil(t, meta)
|
||||||
assert.Equal(t, FullWidthContentAppearance, meta.ContentAppearance)
|
assert.Equal(t, FullWidthContentAppearance, meta.ContentAppearance)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("default appearance via cli flag", func(t *testing.T) {
|
|
||||||
data := []byte("<!-- Space: DOC -->\n<!-- Title: Example -->\n\nbody\n")
|
|
||||||
|
|
||||||
meta, _, err := ExtractMeta(data, "", false, false, "", nil, false, DefaultContentAppearance)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.NotNil(t, meta)
|
|
||||||
assert.Equal(t, DefaultContentAppearance, meta.ContentAppearance)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("default appearance via header", func(t *testing.T) {
|
|
||||||
data := []byte("<!-- Space: DOC -->\n<!-- Title: Example -->\n<!-- Content-Appearance: default -->\n\nbody\n")
|
|
||||||
|
|
||||||
meta, _, err := ExtractMeta(data, "", false, false, "", nil, false, "")
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.NotNil(t, meta)
|
|
||||||
assert.Equal(t, DefaultContentAppearance, meta.ContentAppearance)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -169,7 +169,7 @@ var Flags = []cli.Flag{
|
|||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "content-appearance",
|
Name: "content-appearance",
|
||||||
Value: "",
|
Value: "",
|
||||||
Usage: "default content appearance for pages without a Content-Appearance header. Possible values: full-width, fixed, default.",
|
Usage: "default content appearance for pages without a Content-Appearance header. Possible values: full-width, fixed.",
|
||||||
Sources: cli.NewValueSourceChain(
|
Sources: cli.NewValueSourceChain(
|
||||||
cli.EnvVar("MARK_CONTENT_APPEARANCE"),
|
cli.EnvVar("MARK_CONTENT_APPEARANCE"),
|
||||||
altsrctoml.TOML("content-appearance", altsrc.NewStringPtrSourcer(&filename)),
|
altsrctoml.TOML("content-appearance", altsrc.NewStringPtrSourcer(&filename)),
|
||||||
@ -236,11 +236,11 @@ func CheckFlags(context context.Context, command *cli.Command) (context.Context,
|
|||||||
contentAppearance := strings.TrimSpace(command.String("content-appearance"))
|
contentAppearance := strings.TrimSpace(command.String("content-appearance"))
|
||||||
if contentAppearance != "" {
|
if contentAppearance != "" {
|
||||||
switch contentAppearance {
|
switch contentAppearance {
|
||||||
case "full-width", "fixed", "default":
|
case "full-width", "fixed":
|
||||||
// ok
|
// ok
|
||||||
default:
|
default:
|
||||||
return context, fmt.Errorf(
|
return context, fmt.Errorf(
|
||||||
"invalid value for --content-appearance: %q (expected: full-width, fixed, or default)",
|
"invalid value for --content-appearance: %q (expected: full-width or fixed)",
|
||||||
contentAppearance,
|
contentAppearance,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user