All Projects → kovetskiy → Mark

kovetskiy / Mark

Licence: other
Sync your markdown files with Confluence pages.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Mark

How To Markdown
Learn how to start using Markdown
Stars: ✭ 173 (-5.46%)
Mutual labels:  markdown
Comunidades En Telegram
Listado de Chats de Comunidades en Telegram
Stars: ✭ 178 (-2.73%)
Mutual labels:  markdown
Trpl Zh Cn
Rust 程序设计语言(第二版 & 2018 edition)
Stars: ✭ 2,627 (+1335.52%)
Mutual labels:  markdown
Sheets
Store & retrieve your static content in plain text files
Stars: ✭ 175 (-4.37%)
Mutual labels:  markdown
Mota
🎡 A state management library
Stars: ✭ 177 (-3.28%)
Mutual labels:  markdown
Markdown
CommonMark-compliant markdown parser and renderer in Go. This repository has moved to https://gitlab.com/golang-commonmark/markdown
Stars: ✭ 180 (-1.64%)
Mutual labels:  markdown
Mininote
📔 A simple Markdown note-taking editor
Stars: ✭ 171 (-6.56%)
Mutual labels:  markdown
Django Markupfield
📑 a MarkupField for Django
Stars: ✭ 184 (+0.55%)
Mutual labels:  markdown
Notion2md
Export notion page to markdown.
Stars: ✭ 176 (-3.83%)
Mutual labels:  markdown
Qmarkdowntextedit
A C++ Qt QPlainTextEdit widget with markdown highlighting support and a lot of other extras
Stars: ✭ 182 (-0.55%)
Mutual labels:  markdown
Sinn
a blog based on of react,webpack3,dva,redux,material-ui,fetch,generator,markdown,nodejs,koa2,mongoose,docker,shell,and async/await 基于react+koa2技术栈的个人开源博客系统
Stars: ✭ 175 (-4.37%)
Mutual labels:  markdown
Markdown Img Paste
一个可以快速粘贴剪贴板里的照片到markdown的插件,并且可以设置使用七牛存储照片。
Stars: ✭ 176 (-3.83%)
Mutual labels:  markdown
Press
Minimalist Markdown Publishing for Nuxt.js
Stars: ✭ 181 (-1.09%)
Mutual labels:  markdown
Slideshow
slideshow gems - write your slides / talks / presentations in plain text with markdown formatting conventions
Stars: ✭ 173 (-5.46%)
Mutual labels:  markdown
Badges
📝 Markdown code for lots of small badges 🎀 📌 (shields.io, forthebadge.com etc) 😎. Contributions are welcome! Please add yours!
Stars: ✭ 2,987 (+1532.24%)
Mutual labels:  markdown
Mandown
man-page inspired Markdown viewer
Stars: ✭ 173 (-5.46%)
Mutual labels:  markdown
Rmarkdown
Dynamic Documents for R
Stars: ✭ 2,319 (+1167.21%)
Mutual labels:  markdown
Laravel Markdown
A small, lightweight and easy-to-use Laravel package for handling markdown.
Stars: ✭ 185 (+1.09%)
Mutual labels:  markdown
Markdown Plus
Markdown editor with extra features.
Stars: ✭ 2,139 (+1068.85%)
Mutual labels:  markdown
Markdown Preview.nvim
markdown preview plugin for (neo)vim
Stars: ✭ 2,858 (+1461.75%)
Mutual labels:  markdown

Mark

Mark — 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 Parent headers, if Mark can't find specified parent by title, Mark creates it.

Also, optional following headers are supported:

<!-- Layout: (article|plain) -->
  • (default) article: content will be put in narrow column for ease of reading;
  • plain: content will fill all page;

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> -->

Templates can accept configuration data in YAML format which immediately follows the Include tag:

<!-- Include: <path>
     <yaml-data> -->

Mark also supports attachments. The standard way involves declaring an Attachment along with the other items in the header, then have any links with the same path:

<!-- Attachment: <path-to-image> -->

<beginning of page content>

An attached link is [here](<path-to-image>)

NOTE: Be careful with Attachment! If your path string is a subset of another longer string or referenced in text, you may get undesired behavior.

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 <yaml-data> using ${<number>} syntax, where <number> is number of a capture group in regexp (${0} is used for entire regexp match), for example:

  <!-- Macro: MYJIRA-\d+
       Template: ac:jira:ticket
       Ticket: ${0} -->

Code Blocks

If you have long code blocks, you can make them collapsible with the Code Block Macro:

```bash collapse
...
some long bash code block
...
```

And you can also add a title:

```bash collapse title Some long long bash function
...
some long bash code block
...
```

You can collapse or have a title without language or any mix, but the language must stay in the front if it is given:

[<language>] ["collapse"] ["title" <your title>]

Template & Macros

By default, mark provides several built-in templates and macros:

  • template ac:status to include badge-like text, which accepts following parameters:

    • Title: text to display in the badge
    • Color: color to use as background/border for badge
      • Grey
      • Red
      • Yellow
      • Green
      • Blue
    • Subtle: specify to fill badge with background or not
      • true
      • false
  • template ac:jira:ticket to include JIRA ticket link. Parameters:

    • Ticket: Jira ticket number like BUGS-123.

    See: https://confluence.atlassian.com/conf59/status-macro-792499207.html

  • macro @{...} to mention user by name specified in the braces.

Template & Macros Usecases

Insert Disclaimer

disclaimer.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 Badge

article.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 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 Macro as you like but the Template field must have the ac:toc value. Also, note the single quotes around 'false'.

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 Jira Ticket

article.md

<!-- Space: TEST -->
<!-- Title: TODO List -->

<!-- Macro: MYJIRA-\d+
     Template: ac:jira:ticket
     Ticket: ${0} -->

See task MYJIRA-123.

Installation

Go Get

go get -v github.com/kovetskiy/mark

Releases

Download a release from the Releases page

Docker

$ docker run --rm -i kovetskiy/mark:latest mark <params>

Usage

mark [options] [-u <username>] [-p <password>] [-k] [-l <url>] -f <file>
mark [options] [-u <username>] [-p <password>] [-k] [-b <url>] -f <file>
mark [options] [-u <username>] [-p <password>] [--drop-h1] -f <file>
mark -v | --version
mark -h | --help
  • -u <username> — Use specified username for updating Confluence page.
  • -p <password> — Use specified password for updating Confluence page. Specify - as password to read password from stdin.
  • -l <url> — Edit specified Confluence page. If -l is not specified, file should contain metadata (see above).
  • -b <url> or --base-url <url> – Base URL for Confluence. Alternative option for base_url config field.
  • -f <file> — Use specified markdown file for converting to html.
  • -c <file> — Specify configuration file which should be used for reading Confluence page URL and markdown file path.
  • -k — Lock page editing to current user only to prevent accidental manual edits over Confluence Web UI.
  • --drop-h1 – Don't include H1 headings in Confluence output.
  • --dry-run — Show resulting HTML and don't update Confluence page content.
  • --minor-edit — Don't send notifications while updating Confluence page.
  • --trace — Enable trace logs.
  • -v | --version — Show version.
  • -h | --help — Show help screen and call 911.

You can store user credentials in the configuration file, which should be located in ~/.config/mark with the following format (TOML):

username = "smith"
password = "matrixishere"
# If you are using Confluence Cloud add the /wiki suffix to base_url
base_url = "http://confluence.local"

NOTE: Labels aren't supported when using minor-edit!

Tricks

Continuous Integration

It'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 kovetskiy/mark image for creating a job container where the repository with documentation will be cloned to. The following command finds all *.md files and runs mark against them one by one:

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 main branch. It means you can safely push your changes into feature branches without being afraid that they automatically shown in Confluence, then go through the reviewal process and automatically deploy them when PR got merged.

only:
  branches:
    - main
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].