在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):kovetskiy/mark开源软件地址(OpenSource Url):https://github.com/kovetskiy/mark开源编程语言(OpenSource Language):Go 98.3%开源软件介绍(OpenSource Introduction):MarkMark — a tool for syncing your markdown documentation with Atlassian Confluence pages. Read the blog post discussing the tool — https://samizdat.dev/use-markdown-for-confluence/ This is very useful if you store documentation to your software in a Git repository and don't want to do an extra job of updating Confluence page using a tinymce wysiwyg enterprise core editor which always breaks everything. Mark does the same but in a different way. Mark reads your markdown file, creates a Confluence page if it's not found by its name, uploads attachments, translates Markdown into HTML and updates the contents of the page via REST API. It's like you don't even need to create sections/pages in your Confluence anymore, just use them in your Markdown documentation. Mark uses an extended file format, which, still being valid markdown, contains several HTML-ish metadata headers, which can be used to locate page inside Confluence instance and update it accordingly. File in the extended format should follow the specification: <!-- Space: <space key> -->
<!-- Parent: <parent 1> -->
<!-- Parent: <parent 2> -->
<!-- Title: <title> -->
<!-- Attachment: <local path> -->
<!-- Label: <label 1> -->
<!-- Label: <label 2> -->
<page contents> There can be any number of Also, optional following headers are supported: <!-- Layout: (article|plain) -->
<!-- Type: (page|blogpost) -->
<!-- Sidebar: <h2>Test</h2> --> Setting the sidebar creates a column on the right side. You're able to add any valid HTML content. Adding this property sets the layout to Mark supports Go templates, which can be included into article by using path to the template relative to current working dir, e.g.: <!-- Include: <path> --> Optionally the delimiters can be defined: <!-- Include: <path>
Delims: "<<", ">>"
--> Or they can be switched off to disable processing: <!-- Include: <path>
Delims: none
--> Note: Switching delimiters off really simply changes them to ASCII characters "\x00" and "\x01" which, usually should not occure in a template. Templates can accept configuration data in YAML format which immediately
follows the <!-- Include: <path>
<yaml-data> --> Mark also supports attachments. The standard way involves declaring an
<!-- Attachment: <path-to-image> -->
<beginning of page content>
An attached link is [here](<path-to-image>) NOTE: Be careful with Mark also supports macro definitions, which are defined as regexps which will be replaced with specified template: <!-- Macro: <regexp>
Template: <path>
<yaml-data> --> Capture groups can be defined in the macro's which can be later
referenced in the <!-- Macro: MYJIRA-\d+
Template: ac:jira:ticket
Ticket: ${0} --> Macros can also use inline templates.
Inline templates are templates where the template content
is described in the <!-- Macro: <tblbox\s+(.*?)\s*>
Template: #inline
title: ${1}
inline: |
<table>
<thead><tr><th>{{ .title }}</th></tr></thead>
<tbody><tr><td>
-->
<!-- Macro: </tblbox>
Template: #also_inline
also_inline: |
</td></tr></tbody></table>
-->
<tblbox with a title>
and some
content
</tblbox> Code BlocksIf you have long code blocks, you can make them collapsible with the Code Block Macro:
And you can also add a title:
You can collapse or have a title without language or any mix, but the language must stay in the front if it is given:
Template & MacrosBy default, mark provides several built-in templates and macros:
Template & Macros UsecasesInsert Disclaimerdisclaimer.md **NOTE**: this document is generated, do not edit manually. article.md <!-- Space: TEST -->
<!-- Title: My Article -->
<!-- Include: disclaimer.md -->
This is my article. Insert Status Badgearticle.md <!-- Space: TEST -->
<!-- Title: TODO List -->
<!-- Macro: :done:
Template: ac:status
Title: DONE
Color: Green -->
<!-- Macro: :todo:
Template: ac:status
Title: TODO
Color: Blue -->
* :done: Write Article
* :todo: Publish Article Insert Colored Text Boxarticle.md <!-- Space: TEST -->
<!-- Title: Announcement -->
<!-- Macro: :box:([^:]+):([^:]*):(.+):
Template: ac:box
Icon: true
Name: ${1}
Title: ${2}
Body: ${3} -->
:box:info::Foobar:
:box:tip:Tip of day:Foobar:
:box:note::Foobar:
:box:warning:Alert!:Foobar: Insert Table of Contents<!-- Include: ac:toc --> If default TOC looks don't find a way to your heart, try parametrizing it, for example: <!-- Macro: :toc:
Template: ac:toc
Printable: 'false'
MinLevel: 2 -->
# This is my nice title
:toc: You can call the See Confluence TOC Macro for the list of parameters - keep in mind that here they start with capital letters. Every skipped field will have the default value, so feel free to include only the ones that you require. Insert Children DisplayTo include Children Display (TOC displaying children pages) use following macro: <!-- Macro: :children:
Template: ac:children
-->
# This is my nicer title
:children: You can use various parameters to modify Children Display: <!-- Macro: :children:
Template: ac:children
Sort: title
Style: h3
Excerpt: simple
First: 10
Page: Space:Page title
Depth: 2
Reverse: false
All: false -->
# This is my nicest title
:children: Insert Jira Ticketarticle.md <!-- Space: TEST -->
<!-- Title: TODO List -->
<!-- Macro: MYJIRA-\d+
Template: ac:jira:ticket
Ticket: ${0} -->
See task MYJIRA-123. InstallationHomebrewbrew tap kovetskiy/mark
brew install mark Go Install / Go Getgo install github.com/kovetskiy/mark@latest For older versions go get -v github.com/kovetskiy/mark ReleasesDownload a release from the Releases page Docker$ docker run --rm -i kovetskiy/mark:latest mark <params> Compile and install using docker-composeMostly useful when you intend to enhance # Create the binary
$ docker-compose run markbuilder
# "install" the binary
$ cp mark /usr/local/bin Usage
You can store user credentials in the configuration file, which should be
located in ~/.config/mark (or specified via username = "your-email"
password = "password-or-api-key-for-confluence-cloud"
# If you are using Confluence Cloud add the /wiki suffix to base_url
base_url = "http://confluence.local"
h1_title = true
h1_drop = true NOTE: Labels aren't supported when using TricksContinuous IntegrationIt's quite trivial to integrate Mark into a CI/CD system, here is an example with Snake CI in case of self-hosted Bitbucket Server / Data Center. stages:
- sync
Sync documentation:
stage: sync
only:
branches:
- main
image: kovetskiy/mark
commands:
- for file in $(find -type f -name '*.md'); do
echo "> Sync $file";
mark -u $MARK_USER -p $MARK_PASS -b $MARK_URL -f $file || exit 1;
echo;
done In this example, I'm using the for file in $(find -type f -name '*.md'); do
echo "> Sync $file";
mark -u $MARK_USER -p $MARK_PASS -b $MARK_URL -f $file || exit 1;
echo;
done The following directive tells the CI to run this particular job only if the changes are pushed into the
only:
branches:
- main File GlobbingRather than running mark -f "helpful_cmds/*.md" Issues, Bugs & ContributionsI've started the project to solve my own problem and open sourced the solution so anyone who has a problem like me can solve it too. I have no profits/sponsors from this projects which means I don't really prioritize working on this project in my free time. I still check the issues and do code reviews for Pull Requests which means if you encounter a bug in the program, you should not expect me to fix it as soon as possible, but I'll be very glad to merge your own contributions into the project and release the new version. I try to label all new issues so it's easy to find a bug or a feature request to fix/implement, if you are willing to help with the project, you can use the following labels to find issues, just make sure to reply in the issue to let everyone know you took the issue:
Contributors |
Stanislav Seletskiy |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论