v17 is a major release. Most people running mark from the command line need a few small changes, listed first. Programs that import mark's Go packages have more to change; that part follows.
mark with publish flags and no command no longer publishes. Run mark publish with the same flags.
# v16
mark -f docs/page.md
# v17
mark publish -f docs/page.mdmark -f docs/page.md fails, naming the command the option belongs to. The
global options (configuration file, connection, credentials, logging) can stay
before the command, and the environment variables and the configuration file
are read as before.
The old names are no longer read. In the configuration file an old key is refused as unknown, and the error names its replacement.
| v16 | v17 |
|---|---|
--target-url, MARK_TARGET_URL, target-url (publish) |
--url, MARK_PAGE_URL, url |
MARK_URL (export) |
MARK_PAGE_URL |
--math-format, MARK_MATH_FORMAT, math-format |
--math-output, MARK_MATH_OUTPUT, math-output |
--url, MARK_PAGE_URL and url now name the page for both publish and export. A configuration file whose url was only meant for mark export now sends mark publish to that page as well, or has it refuse a URL that carries no page id, such as a /display/KEY/Title address; mark publish --url "" sets the URL aside. Likewise, a CI job that sets MARK_PAGE_URL sends every mark publish of the job to that one page.
A key in the configuration file that no command reads now fails every command that reads the file, nested tables included. Previously it was silently ignored. The error lists every unknown key on one line, with the key it is probably a typo of:
unknown key in configuration file "mark.toml": "spcae" (did you mean "space"?)
Remove or correct the key.
Before v17, a value from the environment or the configuration file could clash with a different flag typed on the command line. For example, mark export --page-id 123 failed with "--page-id and --url each name a page" when MARK_PAGE_URL was set, and mark export --space DOCS -r silently exported only the URL's page. Now a setting given on the command line sets aside a conflicting one that came from the environment or the file. This covers:
- export's
--page-id,--url,--spaceand--titleagainstMARK_PAGE_ID,MARK_PAGE_URL,MARK_TITLEand their configuration keys. A set-aside page URL still provides the base URL when nothing else sets one. - publish's
--title-from-h1and--title-from-filename. --watch=falseagainst an emptyMARK_WATCHorwatch = "".- a configured
attachments-dirunderexport --recursive, where it is now ignored.
Two conflicting values typed on the command line, or two from the environment and the file, are still refused. The error now says where each value came from.
A blockquote becomes an admonition only with an explicit marker: a word followed by a colon at the start of its first line (> Note: …, > **Warning:** …), or a comment holding only the word. > Note that … and a bare > **Warn** are now plain quotes; add the colon to keep the box.
Each word now has one colour in every syntax, following GitHub and, for words GitHub lacks, MkDocs Material:
| Colour (Confluence macro) | > Word: |
> [!WORD] |
!!! word (mkdocsadmonitions) |
|---|---|---|---|
| Blue (info) | note, info, important | note, important | note, info, important, abstract, summary, tldr, todo |
| Green (tip) | tip, hint | tip | tip, hint, success, check, done |
| Yellow (note) | warning, warn, attention | warning | warning, attention |
| Red (warning) | caution, danger | caution | caution, danger, error, failure, fail, missing, bug |
What changes on pages you already publish:
| You wrote | v16 | v17 | To keep the v16 colour |
|---|---|---|---|
> Note: |
yellow | blue | > [!WARNING] or > Attention: |
> Warn:, > Warning: |
red | yellow | > Caution: or > Danger: |
!!! note |
yellow | blue | !!! warning or !!! attention |
!!! warning |
red | yellow | !!! danger |
New, and published as boxes where v16 left a plain quote:
> Important:,> Hint:,> Attention:,> Caution:and> Danger:;- MkDocs
important,hint,success,attention,caution,danger,error,abstract,summary,tldr,todo,check,done,failure,fail,missingandbug.
MkDocs types now match in any case (!!! Note works). > Error: … and > Success: … stay plain quotes, so quoted log lines are not turned into boxes. !!! question, !!! example and !!! quote stay quotes, since Confluence has no matching box. See Admonition Words for the full table.
An unknown value in a Content-Appearance header, front matter, --content-appearance or Config.ContentAppearance is now an error. Previously the page was published full width. The accepted values are full-width, default and max. fixed, an older editor's narrow layout, is refused too: use default. --changes-only does not notice a change of appearance, so publish once without it after changing --content-appearance.
title: 2024, space: 42 or emoji: 2705 in YAML front matter is now the text as written. Previously a value YAML reads as a number, a boolean or a date left the key unset with nothing said, so the page took its title from --title-from-h1 or --title-from-filename, or its space from --space. The same goes for type, layout, sidebar and image-align, so an unquoted value there is now handled as the same value in quotes is. A list or a mapping under one of these keys is still ignored, and now warned about.
An image or link written as attachment://path/to/file.png is no longer resolved to the attachment at that path. Write the path itself: .
mark --version prints a release as v17.0.0 (a go install …@v17.0.0 build), a checkout build as v17.0.0@<commit> or a Go pseudo-version, and appends +dirty when the tree had changes. Adjust scripts that parse it.
go install github.com/kovetskiy/mark/v17/cmd/mark@latestHomebrew, the release archives and the kovetskiy/mark image are published as before.
v17 reshapes the public API so that each package takes its settings as one options struct and a context.Context first. Most of the changes follow from that.
import "github.com/kovetskiy/mark/v17"Every import changes from /v16 to /v17.
-
mark.Run(ctx, config)replacesRun(config)andRunContext(ctx, config). -
ProcessFileis gone. Make amark.Publisherwithmark.NewPublisher(ctx, api, publishConfig), callPublishfor each file, andCloseit. One publisher keeps the folder cache and the browser across files.Closealso stops a browser or mermaid engine that is still starting. -
mark.Cleanup,chrome.Cleanup,d2.Cleanupandmermaid.Cleanupare gone: each run owns its browser and engine, and closes them. -
mark.Configembedsmark.PublishConfig, and its fields are grouped:Connection: BaseURL, Username, Password, InsecureSkipTLSVerify.Mode: CompileOnly, DryRun.Page: PageID, Space, Parents, TitleFromH1, TitleFromFilename, TitleAppendGeneratedHash, ContentAppearance.Update: MinorEdit, VersionMessage, EditLock, ChangesOnly, PreserveComments, AppendLabels, GlobalProperties.Links: CheckLinks, CheckLinksWarnOnly.Tracking: TrackPages, ManifestPage, ManifestPrefix, OnOrphan, OrphanUnder, NoOverwrite.Rendering: DropH1, StripLinebreaks, the mermaid, d2 and math settings, Features, ImageAlign, AttachReferenced, IncludePath, PageHeader.Report: OutputFormat.
ParentsFromPath,ParentsFromPathRoot,ContinueOnError,CIandUnwatchsit onConfigitself, andOutputonPublishConfig.ExportConfigholds its connection settings inExportConfig.Connection. -
mark.UploadAttachmentsreplacesattachment.ResolveAttachments. Packagevfsis gone: useattachment.Opener,attachment.LocalOSOpenerandattachment.LocalOS.
- The package at
…/v17/markdownis namedmarkdown(it wasmark). markdown.CompileMarkdown(ctx, source, stdlib, path, markdown.Options{…})replaces thetypes.MarkConfigargument; packagetypesis gone.DropFirstH1andStripNewlinesareDropH1andStripLinebreaks.- The legacy compile path is gone:
CompileMarkdownLegacy,CompileMarkdownWithTransformer,ConfluenceLegacyExtensionandrenderer.ConfluenceBlockQuoteRenderer. - goldmark v2:
renderer,parser,transformerandmarkdowntake and returngithub.com/yuin/goldmark/v2types, so a program extending them moves to goldmark v2 too. Everyrenderer.NewConfluence*Rendererreturns anhtml.Extension, and extensions provideParserOptions/RendererOptionsinstead ofExtend. - Admonitions:
renderer.BlockQuoteType,MkDocsAdmonitionTypeand theInfo/Note/Warn/Tip/NoneandA*constants are gone; userenderer.AdmonitionTypeandAdmonitionInfo,AdmonitionNote,AdmonitionWarning,AdmonitionTip,AdmonitionNone.LegacyBlockQuoteClassifieris replaced byrenderer.ClassifyBlockQuote.
mermaid.NewEnginereturns a*mermaid.EnginewithRender(ctx, title, diagram, mermaid.Options{Output, Scale, Bundle}), replacingUseEngineandProcessMermaid*.d2.Render(ctx, title, diagram, d2.Options{Output, Scale, Browser, InputPath, BundleRemote})replacesProcessD2andProcessD2SVG.math.Process(ctx, tex, math.Options{Display, Output, Scale, Browser}).chrome.NewBrowserreturns a*chrome.Browser, whosePNGFromSVG(ctx, …)replaces the package function.chrome.Contextis gone.- The new package
imageformat(Format,PNG,SVG) types every output setting.math.Formatand its constants are gone.
- gopencils is replaced by an in-repo HTTP client. Every
confluence.APImethod that makes a request takesctxfirst, and so does everything above it that does:manifest.Store, page operations and ancestry,LinkChecker.MissingPages,doctor.Run,stdlib.New. confluence.NewAPI(baseURL, confluence.Options{Username, Password, InsecureSkipVerify, KeepConcurrentEdits, Unwatch}).BaseURLis a method.UpdatePage(ctx, page, content, confluence.UpdateOptions{MinorEdit, VersionMessage, Appearance, Emoji}).- Errors are
*confluence.StatusError. Match them witherrors.IsagainstErrUnauthorized,ErrForbidden,ErrNotFound,ErrConflictandErrLoginPage. IsCloudis gone: useCloud, which also returns the error.LookupUserreturns*confluence.User, andDeletePageLabelreturns only an error.
metadata.ExtractMeta(data, metadata.ExtractOptions{…}).page.Rename/Archive/Delete/Watch/UnwatchtakeRenameOptions,ArchiveOptions,DeleteOptionsandWatchOptions. The ancestry functions takeapisecond and a trailingpage.AncestryOptions{DryRun, FolderCache, Parents, Folders}.page.NewLinkResolvertakesmetadata.ExtractOptions.fingerprint.Content(html, fingerprint.Properties{…}),doctor.Run(ctx, api, spaces, out).- Named string types replace plain strings:
report.Format,report.Status,report.OnOrphan,metadata.Appearance,mermaid.EngineKind,confluence.ContentType,export.Formatandexport.Metadata. metadata.ParseContentAppearanceandResolveContentAppearancereplaceNormalizeContentAppearance, and refuse unknown values.
| v16 | v17 |
|---|---|
util.Flags, util.RunMark, util.CheckFlags, util.CheckConfigFile |
removed; util.Run is the command line |
page.OnOrphan*, page.ParseOnOrphan |
report.OnOrphan*, report.ParseOnOrphan |
page.GenerateTinyLink, page.DecodeTinyLinkID |
confluence.GenerateTinyLink, confluence.DecodeTinyLinkID |
page.ResetFolderCache |
page.NewFolderCache |
renderer.SplitPageAnchor, ParseCodeBlockInfo, CodeLanguage, AdmonitionMarker; transformer.AnchorKey; parser.HeadingOptions |
internal (internal/syntax) |
metadata.CodeRegions, InCode, Region, IgnoreStart, IgnoreEnd |
internal (internal/mdsource) |
stdlib.New(api) |
stdlib.New(ctx, users) with a stdlib.UserLookup; a *confluence.API satisfies it |