Compare commits

...

11 Commits

Author SHA1 Message Date
dependabot[bot]
4c2a3c9b96 Bump DavidAnson/markdownlint-cli2-action from 21 to 22
Bumps [DavidAnson/markdownlint-cli2-action](https://github.com/davidanson/markdownlint-cli2-action) from 21 to 22.
- [Release notes](https://github.com/davidanson/markdownlint-cli2-action/releases)
- [Commits](https://github.com/davidanson/markdownlint-cli2-action/compare/v21...v22)

---
updated-dependencies:
- dependency-name: DavidAnson/markdownlint-cli2-action
  dependency-version: '22'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-16 09:50:22 +01:00
Manuel Rüger
967efde9bd README.md: Update help output 2025-12-08 21:59:51 +01:00
dgudim
b3a6f1efae Update readme, add description for insecure-skip-tls-verify 2025-12-08 21:53:28 +01:00
dgudim
e82c425471 Rename insecure flag to insecure-skip-tls-verify 2025-12-08 21:53:28 +01:00
Danila Gudim
b36d7aa135 feature: Add --insecure flag for ignoring tls errors 2025-12-08 21:53:28 +01:00
Manuel Rüger
be4ff0d58a Use mimesniffing to detect text files 2025-12-08 21:36:28 +01:00
dependabot[bot]
8fbf355e33 Bump golang.org/x/text from 0.31.0 to 0.32.0
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.31.0 to 0.32.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.31.0...v0.32.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-version: 0.32.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-08 21:31:53 +01:00
dependabot[bot]
76850d1128 Bump github.com/dreampuf/mermaid.go from 0.0.38 to 0.0.39
Bumps [github.com/dreampuf/mermaid.go](https://github.com/dreampuf/mermaid.go) from 0.0.38 to 0.0.39.
- [Release notes](https://github.com/dreampuf/mermaid.go/releases)
- [Commits](https://github.com/dreampuf/mermaid.go/compare/v0.0.38...v0.0.39)

---
updated-dependencies:
- dependency-name: github.com/dreampuf/mermaid.go
  dependency-version: 0.0.39
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-08 18:09:33 +01:00
Manuel Rüger
817c9684ce fix: Include scale into the hash
Should fix https://github.com/kovetskiy/mark/issues/683
2025-12-08 17:14:16 +01:00
dependabot[bot]
1c708414dd Bump golang from 1.25.4 to 1.25.5
Bumps golang from 1.25.4 to 1.25.5.

---
updated-dependencies:
- dependency-name: golang
  dependency-version: 1.25.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-08 16:53:34 +01:00
Manuel Rüger
71668cac21 Fix issue with leading/trailing spaces in title
See also #672
2025-12-06 23:57:51 +01:00
14 changed files with 87 additions and 46 deletions

View File

@ -39,7 +39,7 @@ jobs:
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v6 uses: actions/checkout@v6
- name: markdownlint-cli2-action - name: markdownlint-cli2-action
uses: DavidAnson/markdownlint-cli2-action@v21 uses: DavidAnson/markdownlint-cli2-action@v22
# Executes Unit Tests # Executes Unit Tests
ci-unit-tests: ci-unit-tests:

View File

@ -1,4 +1,4 @@
FROM golang:1.25.4 AS builder FROM golang:1.25.5 AS builder
ENV GOPATH="/go" ENV GOPATH="/go"
WORKDIR /go/src/github.com/kovetskiy/mark WORKDIR /go/src/github.com/kovetskiy/mark
COPY / . COPY / .

View File

@ -815,23 +815,23 @@ USAGE:
mark [global options] mark [global options]
VERSION: VERSION:
14.0.2 v15.1.0@b3a6f1efae97dfaa1400a3175cdd3377f8176e88
DESCRIPTION: DESCRIPTION:
Mark is a tool to update Atlassian Confluence pages from markdown. Documentation is available here: https://github.com/kovetskiy/mark Mark is a tool to update Atlassian Confluence pages from markdown. Documentation is available here: https://github.com/kovetskiy/mark
GLOBAL OPTIONS: GLOBAL OPTIONS:
--files string, -f string use specified markdown file(s) for converting to html. Supports file globbing patterns (needs to be quoted). [$MARK_FILES] --files string, -f string use specified markdown file(s) for converting to html. Supports file globbing patterns (needs to be quoted). [$MARK_FILES]
--continue-on-error don't exit if an error occurs while processing a file, continue processing remaining files. (default: false) [$MARK_CONTINUE_ON_ERROR] --continue-on-error don't exit if an error occurs while processing a file, continue processing remaining files. [$MARK_CONTINUE_ON_ERROR]
--compile-only show resulting HTML and don't update Confluence page content. (default: false) [$MARK_COMPILE_ONLY] --compile-only show resulting HTML and don't update Confluence page content. [$MARK_COMPILE_ONLY]
--dry-run resolve page and ancestry, show resulting HTML and exit. (default: false) [$MARK_DRY_RUN] --dry-run resolve page and ancestry, show resulting HTML and exit. [$MARK_DRY_RUN]
--edit-lock, -k lock page editing to current user only to prevent accidental manual edits over Confluence Web UI. (default: false) [$MARK_EDIT_LOCK] --edit-lock, -k lock page editing to current user only to prevent accidental manual edits over Confluence Web UI. [$MARK_EDIT_LOCK]
--drop-h1 don't include the first H1 heading in Confluence output. (default: false) [$MARK_DROP_H1] --drop-h1 don't include the first H1 heading in Confluence output. [$MARK_DROP_H1]
--strip-linebreaks, -L remove linebreaks inside of tags, to accommodate non-standard Confluence behavior (default: false) [$MARK_STRIP_LINEBREAKS] --strip-linebreaks, -L remove linebreaks inside of tags, to accommodate non-standard Confluence behavior [$MARK_STRIP_LINEBREAKS]
--title-from-h1 extract page title from a leading H1 heading. If no H1 heading on a page exists, then title must be set in the page metadata. (default: false) [$MARK_TITLE_FROM_H1] --title-from-h1 extract page title from a leading H1 heading. If no H1 heading on a page exists, then title must be set in the page metadata. Mutually exclusive with --title-from-filename. [$MARK_TITLE_FROM_H1]
--title-append-generated-hash appends a short hash generated from the path of the page (space, parents, and title) to the title (default: false) [$MARK_TITLE_APPEND_GENERATED_HASH] --title-from-filename use the filename (without extension) as the Confluence page title if no explicit page title is set in the metadata. Mutually exclusive with --title-from-h1. [$MARK_TITLE_FROM_FILENAME]
--title-from-filename use the filename (without extension) as the Confluence page title if no explicit page title is set in the metadata. Mutually exclusive with --title-from-h1. (default: false) [$MARK_TITLE_FROM_FILENAME] --title-append-generated-hash appends a short hash generated from the path of the page (space, parents, and title) to the title [$MARK_TITLE_APPEND_GENERATED_HASH]
--minor-edit don't send notifications while updating Confluence page. (default: false) [$MARK_MINOR_EDIT] --minor-edit don't send notifications while updating Confluence page. [$MARK_MINOR_EDIT]
--version-message string add a message to the page version, to explain the edit (default: "") [$MARK_VERSION_MESSAGE] --version-message string add a message to the page version, to explain the edit (default: "") [$MARK_VERSION_MESSAGE]
--color string display logs in color. Possible values: auto, never. (default: "auto") [$MARK_COLOR] --color string display logs in color. Possible values: auto, never. (default: "auto") [$MARK_COLOR]
--log-level string set the log level. Possible values: TRACE, DEBUG, INFO, WARNING, ERROR, FATAL. (default: "info") [$MARK_LOG_LEVEL] --log-level string set the log level. Possible values: TRACE, DEBUG, INFO, WARNING, ERROR, FATAL. (default: "info") [$MARK_LOG_LEVEL]
@ -839,16 +839,17 @@ GLOBAL OPTIONS:
--password string, -p string use specified token for updating Confluence page. Specify - as password to read password from stdin, or your Personal access token. Username is not mandatory if personal access token is provided. For more info please see: https://developer.atlassian.com/server/confluence/confluence-server-rest-api/#authentication. [$MARK_PASSWORD] --password string, -p string use specified token for updating Confluence page. Specify - as password to read password from stdin, or your Personal access token. Username is not mandatory if personal access token is provided. For more info please see: https://developer.atlassian.com/server/confluence/confluence-server-rest-api/#authentication. [$MARK_PASSWORD]
--target-url string, -l string edit specified Confluence page. If -l is not specified, file should contain metadata (see above). [$MARK_TARGET_URL] --target-url string, -l string edit specified Confluence page. If -l is not specified, file should contain metadata (see above). [$MARK_TARGET_URL]
--base-url string, -b string base URL for Confluence. Alternative option for base_url config field. [$MARK_BASE_URL] --base-url string, -b string base URL for Confluence. Alternative option for base_url config field. [$MARK_BASE_URL]
--config string, -c string use the specified configuration file. (default: $HOME/.config/mark.toml") [$MARK_CONFIG] --config string, -c string use the specified configuration file. (default: "$HOME/.config/mark.toml") [$MARK_CONFIG]
--ci run on CI mode. It won't fail if files are not found. (default: false) [$MARK_CI] --ci run on CI mode. It won't fail if files are not found. [$MARK_CI]
--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]
--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. (default: false) [$MARK_CHANGES_ONLY] --changes-only Avoids re-uploading pages that haven't changed since the last run. [$MARK_CHANGES_ONLY]
--d2-scale float defines the scaling factor for d2 renderings. (default: 1) [$MARK_D2_SCALE] --d2-scale float defines the scaling factor for d2 renderings. (default: 1) [$MARK_D2_SCALE]
--features string [ --features string ] Enables optional features. Current features: d2, mermaid (default: "mermaid") [$MARK_FEATURES] --features string [ --features string ] Enables optional features. Current features: d2, mermaid, mkdocsadmonitions (default: "mermaid") [$MARK_FEATURES]
--insecure-skip-tls-verify skip TLS certificate verification (useful for self-signed certificates) [$MARK_INSECURE_SKIP_TLS_VERIFY]
--help, -h show help --help, -h show help
--version, -v print the version --version, -v print the version
``` ```

View File

@ -2,6 +2,7 @@ package confluence
import ( import (
"bytes" "bytes"
"crypto/tls"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@ -97,7 +98,7 @@ func (tracer *tracer) Printf(format string, args ...interface{}) {
log.Tracef(nil, tracer.prefix+" "+format, args...) log.Tracef(nil, tracer.prefix+" "+format, args...)
} }
func NewAPI(baseURL string, username string, password string) *API { func NewAPI(baseURL string, username string, password string, insecureSkipVerify bool) *API {
var auth *gopencils.BasicAuth var auth *gopencils.BasicAuth
if username != "" { if username != "" {
auth = &gopencils.BasicAuth{ auth = &gopencils.BasicAuth{
@ -105,7 +106,19 @@ func NewAPI(baseURL string, username string, password string) *API {
Password: password, Password: password,
} }
} }
rest := gopencils.Api(baseURL+"/rest/api", auth, 3) // set option for 3 retries on failure
var httpClient *http.Client
if insecureSkipVerify {
httpClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
}
rest := gopencils.Api(baseURL+"/rest/api", auth, httpClient, 3) // set option for 3 retries on failure
if username == "" { if username == "" {
if rest.Headers == nil { if rest.Headers == nil {
rest.Headers = http.Header{} rest.Headers = http.Header{}
@ -113,7 +126,7 @@ func NewAPI(baseURL string, username string, password string) *API {
rest.SetHeader("Authorization", fmt.Sprintf("Bearer %s", password)) rest.SetHeader("Authorization", fmt.Sprintf("Bearer %s", password))
} }
json := gopencils.Api(baseURL+"/rpc/json-rpc/confluenceservice-v2", auth, 3) json := gopencils.Api(baseURL+"/rpc/json-rpc/confluenceservice-v2", auth, httpClient, 3)
if log.GetLevel() == lorg.LevelTrace { if log.GetLevel() == lorg.LevelTrace {
rest.Logger = &tracer{"rest:"} rest.Logger = &tracer{"rest:"}

View File

@ -4,7 +4,9 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/base64" "encoding/base64"
"encoding/binary"
"fmt" "fmt"
"math"
"strconv" "strconv"
"time" "time"
@ -63,7 +65,14 @@ func ProcessD2(title string, d2Diagram []byte, scale float64) (attachment.Attach
return attachment.Attachment{}, err return attachment.Attachment{}, err
} }
checkSum, err := attachment.GetChecksum(bytes.NewReader(d2Diagram)) scaleAsBytes := make([]byte, 8)
binary.LittleEndian.PutUint64(scaleAsBytes, math.Float64bits(scale))
d2Bytes := append(d2Diagram, scaleAsBytes...)
checkSum, err := attachment.GetChecksum(bytes.NewReader(d2Bytes))
log.Debugf(nil, "Checksum: %q -> %s", title, checkSum) log.Debugf(nil, "Checksum: %q -> %s", title, checkSum)
if err != nil { if err != nil {

View File

@ -75,7 +75,7 @@ func TestExtractD2Image(t *testing.T) {
Filename: "example.png", Filename: "example.png",
Name: "example", Name: "example",
Replace: "example", Replace: "example",
Checksum: "58fa387384181445e2d8f90a8c7fda945cb75174f73e8b9853ff59b9e0103ddd", Checksum: "40e75f93e09da9242d4b1ab8e2892665ec7d5bd1ac78a4b65210ee219cf62297",
ID: "", ID: "",
Width: "198", Width: "198",
Height: "441", Height: "441",

5
go.mod
View File

@ -8,7 +8,7 @@ require (
github.com/bmatcuk/doublestar/v4 v4.9.1 github.com/bmatcuk/doublestar/v4 v4.9.1
github.com/chromedp/cdproto v0.0.0-20250803210736-d308e07a266d github.com/chromedp/cdproto v0.0.0-20250803210736-d308e07a266d
github.com/chromedp/chromedp v0.14.2 github.com/chromedp/chromedp v0.14.2
github.com/dreampuf/mermaid.go v0.0.38 github.com/dreampuf/mermaid.go v0.0.39
github.com/kovetskiy/gopencils v0.0.0-20250404051442-0b776066936a github.com/kovetskiy/gopencils v0.0.0-20250404051442-0b776066936a
github.com/kovetskiy/lorg v1.2.1-0.20240830111423-ba4fe8b6f7c4 github.com/kovetskiy/lorg v1.2.1-0.20240830111423-ba4fe8b6f7c4
github.com/reconquest/karma-go v1.5.0 github.com/reconquest/karma-go v1.5.0
@ -19,8 +19,7 @@ require (
github.com/urfave/cli-altsrc/v3 v3.1.0 github.com/urfave/cli-altsrc/v3 v3.1.0
github.com/urfave/cli/v3 v3.6.1 github.com/urfave/cli/v3 v3.6.1
github.com/yuin/goldmark v1.7.13 github.com/yuin/goldmark v1.7.13
golang.org/x/text v0.31.0 golang.org/x/text v0.32.0
golang.org/x/tools/godoc v0.1.0-deprecated
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
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

10
go.sum
View File

@ -31,8 +31,8 @@ github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yA
github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dop251/goja v0.0.0-20240927123429-241b342198c2 h1:Ux9RXuPQmTB4C1MKagNLme0krvq8ulewfor+ORO/QL4= github.com/dop251/goja v0.0.0-20240927123429-241b342198c2 h1:Ux9RXuPQmTB4C1MKagNLme0krvq8ulewfor+ORO/QL4=
github.com/dop251/goja v0.0.0-20240927123429-241b342198c2/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4= github.com/dop251/goja v0.0.0-20240927123429-241b342198c2/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4=
github.com/dreampuf/mermaid.go v0.0.38 h1:tYzlJ3GiyIJ1QCw6NMJPE1P3iUXqORiogkTWjbobLgs= github.com/dreampuf/mermaid.go v0.0.39 h1:K7R+FaAOxKd32/yic9SVz0u9bedS5nV/6nUgGnKdJuY=
github.com/dreampuf/mermaid.go v0.0.38/go.mod h1:xBmQWWnPFQl7HIfEz+KnZ+BpXPJl9qXe9aISIPJGsAM= github.com/dreampuf/mermaid.go v0.0.39/go.mod h1:xBmQWWnPFQl7HIfEz+KnZ+BpXPJl9qXe9aISIPJGsAM=
github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2 h1:iizUGZ9pEquQS5jTGkh4AqeeHCMbfbjeb0zMt0aEFzs= github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2 h1:iizUGZ9pEquQS5jTGkh4AqeeHCMbfbjeb0zMt0aEFzs=
github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M= github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M=
github.com/go-sourcemap/sourcemap v2.1.4+incompatible h1:a+iTbH5auLKxaNwQFg0B+TCYl6lbukKPc7b5x0n1s6Q= github.com/go-sourcemap/sourcemap v2.1.4+incompatible h1:a+iTbH5auLKxaNwQFg0B+TCYl6lbukKPc7b5x0n1s6Q=
@ -138,14 +138,12 @@ 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.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
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=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools/godoc v0.1.0-deprecated h1:o+aZ1BOj6Hsx/GBdJO/s815sqftjSnrZZwyYTHODvtk=
golang.org/x/tools/godoc v0.1.0-deprecated/go.mod h1:qM63CriJ961IHWmnWa9CjZnBndniPt4a3CK0PVB9bIg=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=

View File

@ -3,6 +3,8 @@ package mermaid
import ( import (
"bytes" "bytes"
"context" "context"
"encoding/binary"
"math"
"strconv" "strconv"
"time" "time"
@ -30,7 +32,13 @@ func ProcessMermaidLocally(title string, mermaidDiagram []byte, scale float64) (
return attachment.Attachment{}, err return attachment.Attachment{}, err
} }
checkSum, err := attachment.GetChecksum(bytes.NewReader(mermaidDiagram)) scaleAsBytes := make([]byte, 8)
binary.LittleEndian.PutUint64(scaleAsBytes, math.Float64bits(scale))
mermaidBytes := append(mermaidDiagram, scaleAsBytes...)
checkSum, err := attachment.GetChecksum(bytes.NewReader(mermaidBytes))
log.Debugf(nil, "Checksum: %q -> %s", title, checkSum) log.Debugf(nil, "Checksum: %q -> %s", title, checkSum)
if err != nil { if err != nil {

View File

@ -22,7 +22,7 @@ func TestExtractMermaidImage(t *testing.T) {
Filename: "example.png", Filename: "example.png",
Name: "example", Name: "example",
Replace: "example", Replace: "example",
Checksum: "1743a4f31ab66244591f06c8056e08053b8e0a554eb9a38709af6e9d145ac84f", Checksum: "26296b73c960c25850b37bc9dd77cb24fce1a78db83b37755a25af7f8a48cc96",
ID: "", ID: "",
Width: "87", Width: "87",
Height: "174", Height: "174",

View File

@ -189,6 +189,9 @@ func ExtractMeta(data []byte, spaceFromCli string, titleFromH1 bool, titleFromFi
) )
} }
// Remove trailing spaces from title
meta.Title = strings.Trim(meta.Title, " ")
meta.Space = strings.Trim(meta.Space, " ")
return meta, data[offset:], nil return meta, data[offset:], nil
} }

View File

@ -3,16 +3,17 @@ package page
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"net/http"
"net/url" "net/url"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strings"
"github.com/kovetskiy/mark/confluence" "github.com/kovetskiy/mark/confluence"
"github.com/kovetskiy/mark/metadata" "github.com/kovetskiy/mark/metadata"
"github.com/reconquest/karma-go" "github.com/reconquest/karma-go"
"github.com/reconquest/pkg/log" "github.com/reconquest/pkg/log"
"golang.org/x/tools/godoc/util"
) )
type LinkSubstitution struct { type LinkSubstitution struct {
@ -93,7 +94,10 @@ func resolveLink(
linkContents, err := os.ReadFile(filepath) linkContents, err := os.ReadFile(filepath)
if !util.IsText(linkContents) { contentType := http.DetectContentType(linkContents)
// Check if the MIME type starts with "text/"
if !strings.HasPrefix(contentType, "text/") {
log.Debugf(nil, "Ignoring link to file %q: detected content type %v", filepath, contentType)
return "", nil return "", nil
} }

View File

@ -49,7 +49,7 @@ func RunMark(ctx context.Context, cmd *cli.Command) error {
return err return err
} }
api := confluence.NewAPI(creds.BaseURL, creds.Username, creds.Password) api := confluence.NewAPI(creds.BaseURL, creds.Username, creds.Password, cmd.Bool("insecure-skip-tls-verify"))
files, err := doublestar.FilepathGlob(cmd.String("files")) files, err := doublestar.FilepathGlob(cmd.String("files"))
if err != nil { if err != nil {

View File

@ -196,6 +196,12 @@ var Flags = []cli.Flag{
Usage: "Enables optional features. Current features: d2, mermaid, mkdocsadmonitions", Usage: "Enables optional features. Current features: d2, mermaid, mkdocsadmonitions",
Sources: cli.NewValueSourceChain(cli.EnvVar("MARK_FEATURES"), altsrctoml.TOML("features", altsrc.NewStringPtrSourcer(&filename))), Sources: cli.NewValueSourceChain(cli.EnvVar("MARK_FEATURES"), altsrctoml.TOML("features", altsrc.NewStringPtrSourcer(&filename))),
}, },
&cli.BoolFlag{
Name: "insecure-skip-tls-verify",
Value: false,
Usage: "skip TLS certificate verification (useful for self-signed certificates)",
Sources: cli.NewValueSourceChain(cli.EnvVar("MARK_INSECURE_SKIP_TLS_VERIFY"), altsrctoml.TOML("insecure-skip-tls-verify", altsrc.NewStringPtrSourcer(&filename))),
},
} }
// CheckMutuallyExclusiveTitleFlags checks if both title-from-h1 and title-from-filename are set // CheckMutuallyExclusiveTitleFlags checks if both title-from-h1 and title-from-filename are set