• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

RittmanMead/md_to_conf: Markdown to Confluence import

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

RittmanMead/md_to_conf

开源软件地址(OpenSource Url):

https://github.com/RittmanMead/md_to_conf

开源编程语言(OpenSource Language):

Python 100.0%

开源软件介绍(OpenSource Introduction):

Markdown to Confluence Converter

A script to import a named markdown document into Confluence.

It handles inline images as well as code blocks.

Also there is support for some custom markdown tags for use with commonly used Confluence macros.

The file will be converted into HTML or Confluence storage markup when required.

Then a page will be created in the space or if it already exists, the page will be uploaded.

Configuration

Download

Requirements

Python 3.6+

Python venv

The project code and dependencies can be used based on python virtualenv.

Create a new python virtualenv:

> python3 -m venv venv

Or in Anaconda

conda create --name md_to_conf python=3.7 --yes

Make the virtualenv active:

> source venv/bin/activate

Dependencies

Required python dependencies can be installed using:

pip3 install -r requirements.txt

Environment Variables

To use it, you will need your Confluence username, API key and organisation name. To generate an API key go to https://id.atlassian.com/manage/api-tokens.

You will also need the organization name that is used in the subdomain. For example the URL: https://fawltytowers.atlassian.net/wiki/ would indicate an organization name of fawltytowers.

If the organization name contains a dot, it will be considered as a Fully Qualified Domain Name. For example the URL: https://fawltytowers.mydomain.com/ would indicate an organization name of fawltytowers.mydomain.com.

These can be specified at runtime or set as Confluence environment variables (e.g. add to your ~/.profile or ~/.bash_profile on Mac OS):

export CONFLUENCE_USERNAME='basil'
export CONFLUENCE_API_KEY='abc123'
export CONFLUENCE_ORGNAME='fawltytowers'

On Windows, this can be set via system properties.

Use

Basic

The minimum accepted parameters are the markdown file to upload as well as the Confluence space key you wish to upload to. For the following examples assume 'Test Space' with key: TST.

python3 md2conf.py readme.md TST

Mandatory Confluence parameters can also be set here if not already set as environment variables:

  • -u --username: Confluence User
  • -p --apikey: Confluence API Key
  • -o --orgname: Confluence Organisation
python3 md2conf.py readme.md TST -u basil -p abc123 -o fawltytowers

Use -h to view a list of all available options.

Other Uses

Use -a or --ancestor to designate the name of a page which the page should be created under.

python md2conf.py readme.md TST -a "Parent Page Name"

Use -d or --delete to delete the page instead of create it. Obviously this won't work if it doesn't already exist.

Use -n or --nossl to specify a non-SSL url, i.e. http:// instead of https://.

Use -l or --loglevel to specify a different logging level, i.e DEBUG.

Use -s or --simulate to stop processing before interacting with confluence API, i.e. only converting the markdown document to confluence format.

Markdown

The original markdown to HTML conversion is performed by the Python markdown library. Additionally, the page name is taken from the first line of the markdown file, usually assumed to be the title. In the case of this document, the page would be called: Markdown to Confluence Converter.

Standard markdown syntax for images and code blocks will be automatically converted. The images are uploaded as attachments and the references updated in the HTML. The code blocks will be converted to the Confluence Code Block macro and also supports syntax highlighting.

Doctoc

If present, what is between the doctoc anchor format:

<!-- START doctoc ...
...
... END doctoc -->

will be replaced by confluence "toc" macro leading to something like:

<h2>Table of Content</h2>
<p>
    <ac:structured-macro ac:name="toc">
      <ac:parameter ac:name="printable">true</ac:parameter>
      <ac:parameter ac:name="style">disc</ac:parameter>
      <ac:parameter ac:name="maxLevel">7</ac:parameter>
      <ac:parameter ac:name="minLevel">1</ac:parameter>
      <ac:parameter ac:name="type">list</ac:parameter>
      <ac:parameter ac:name="outline">clear</ac:parameter>
      <ac:parameter ac:name="include">.*</ac:parameter>
    </ac:structured-macro>
    </p>

Information, Note and Warning Macros

Warning: Any blockquotes used will implement an information macro. This could potentially harm your formatting.

Block quotes in Markdown are rendered as information macros.

> This is an info

macros

> Note: This is a note

macros

> Warning: This is a warning

macros

Alternatively, using a custom Markdown syntax also works:

~?This is an info.?~

~!This is a note.!~

~%This is a warning.%~

Miscellaneous

    ╚⊙ ⊙╝
  ╚═(███)═╝
 ╚═(███)═╝
╚═(███)═╝
 ╚═(███)═╝
  ╚═(███)═╝
   ╚═(███)═╝



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
lezer-parser/markdown: A lezer-integrated Markdown parser发布时间:2022-08-18
下一篇:
antfu/vite-plugin-md: Markdown with Vue for Vite发布时间:2022-08-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap