schneiderl-md2cf


Nameschneiderl-md2cf JSON
Version 0.99.99 PyPI version JSON
download
home_pagehttps://github.com/schneiderl/md2cf
SummaryConvert Markdown documents to Confluence
upload_time2023-11-10 12:40:37
maintainer
docs_urlNone
authorschneiderl
requires_python>=3.7
licenseMIT
keywords markdown confluence
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # md2cf

`md2cf` is a tool and library that allows you to convert Markdown documents to Confluence Storage format and upload them to a Confluence instance.

## Features

- **Convert Markdown documents:** `md2cf` includes a library that implements a [Mistune](https://github.com/lepture/mistune) renderer, which outputs Confluence Storage Format.
- **Talk to the Confluence API:** `md2cf` also features an embedded micro-implementation of the [Confluence Server REST API](https://developer.atlassian.com/server/confluence/confluence-server-rest-api/) with basic support for creating and updating pages and attachments.
- **Automate the upload process:** You can use `md2cf`'s full-featured command line utility to automate the upload process for you.


## Installation

```bash
# Install md2cf via pip
pip install md2cf

# If you only need to use md2cf for uploading documents to Confluence,
# it's recommended to use pipx:
pipx install md2cf
```

## Getting started

To see all available options and parameters, run `md2cf --help`.

To upload a document, you need to provide at least the following five parameters:

- The **URL** of your Confluence instance, including the path to the REST API (e.g., `http://confluence.example.com/rest/api`)
- Either:
    - The **username** and **password** to log in to the instance
    - A **personal access token**
- The **space** in which to publish the page
- The **files or directories** to be uploaded. If none are specified, the contents will be read from standard input.

Example basic usage:

```bash
md2cf --host 'https://confluence.example.com/rest/api' --username foo --password bar --space TEST document.md
```

Or, if using a token:

```bash
md2cf --host 'https://confluence.example.com/rest/api' --token '2104v3ryl0ngt0k3n720' --space TEST document.md
```

> :warning: Avoid entering your password (or token) as a command line parameter, as this is [generally a bad practice](https://unix.stackexchange.com/q/78734). Instead, when running the script interactively, omit the `--password` parameter and securely enter the password when prompted.

> :warning: Note that tokens function differently between [Confluence Cloud](https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/) and [self-hosted instances](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html). When using Confluence Cloud, you should use your token **as your password** with the `--username` and `--password` parameters. With self-hosted instances, use the `--token` parameter instead.

You can also supply the hostname, username, password, token, and space as **environment variables**:

- `CONFLUENCE_HOST`
- `CONFLUENCE_USERNAME`
- `CONFLUENCE_PASSWORD`
- `CONFLUENCE_TOKEN`
- `CONFLUENCE_SPACE`

If you are using self-signed certificates or want to **ignore SSL errors**, use the `--insecure` option.

You can **upload multiple files** or entire folders. If you specify a folder, `md2cf` will traverse it recursively and upload all files that end in `.md`. For more information, see [Uploading Folders](#uploading-folders).

If you would like to preview `md2cf`'s actions without modifying Confluence, use the `--dry-run` option. This will print a list of page data without making any changes.

## Page information arguments

### Page title

The title of the page can be sourced from multiple places, in the following order of priority:
* The `--title` command-line parameter
* A `title` entry in the document's front matter, which is a YAML block delimited by `---` lines at the top of the file:

  ```yaml
  ---
  title: This is a title
  ---
  ```
* The first top-level header found in the document (i.e., the first `#` header)
* The filename, if there are no top-level headers.

Note that if you are reading from standard input, you must either specify the title through the command line or include a title as a header or in the front matter within the content.

To avoid repeating the top level header in the body of the page, pass the `--strip-top-header` parameter to strip it from the document.

When uploading entire folders, consider adding a prefix to each page title to prevent collisions. You can do this by using the `--prefix` parameter.

### Removing extra newlines

If your document uses single newlines to break lines (for example, if it was typeset with a fixed column width), Confluence Cloud might preserve those newlines, resulting in a document that's difficult to read. To fix this, use the `--remove-text-newlines` parameter, which replaces every newline within a paragraph with a space.


<details>
<summary>Example</summary>
For example, this will turn

```text
This is a document
with hardcoded newlines
in its paragraphs.

It's not that nice
to read.
```

into

```text
This is a document with hardcoded newlines in its paragraphs.

It's not that nice to read.
```
</details>

### Adding a preface and/or postface

The `--preface-markdown`, `--preface-file`, `--postface-markdown`, and `--postface-file` commands enable you to add text at the beginning or end of each page. This is especially helpful if you're mirroring documentation to Confluence and want to notify users that it will be automatically updated.

The `--preface-markdown` and `--postface-markdown` options allow you to specify Markdown text directly in the command line. If no text is specified, a default paragraph will be used stating:

> **Contents are auto-generated, do not edit.**

Alternatively, the `--preface-file` and `--postface-file` options allow you to specify a path to a markdown file which will be prepended or appended to every page.

> :warning: Note that preface and postface Markdown is parsed separately and added to the body after the main page has been parsed. Therefore, it will not affect behavior tied to the page contents, such as title or front matter detection.

### Page labels

To add labels to your page, include a `labels` entry in your document's front matter. The front matter is a YAML block delimited by `---` lines at the top of the file. Here's an example:

```yaml
---
labels:
- first label
- second label
---
# Rest of the Markdown document
```

Note that by default, the labels you specify will be added to any existing labels. If you want to replace all existing labels with only the ones you specified, use the `--replace-all-labels` option.

### Parent page

To upload the page under **a specific parent**, you can provide the parent's page ID using the `--parent-id` parameter, or its title using the `--parent-title` parameter.

To move a page to a **top-level page** (i.e. directly under the space's Home Page), use the `--top-level` flag.

### Update message

Optionally, you can provide an **update message** using the `--message` parameter to describe the change you made. If you're using the `--only-changed` option at the same time, the version update message will also include a hash of the page or attachment contents at the end.

### Updating an existing page

If you upload a page with the same title twice, it will update the existing page.

To update a page using its ID, use the `--page-id` option. This allows you to modify the page's title or update a page with a title that is difficult to use as a parameter.

To avoid sending notifications to page watchers, use the `--minor-edit` option. This corresponds to the "Notify watchers" checkbox when editing pages manually.

### Avoiding uploading content that hasn't changed

To avoid re-uploading unchanged content and receiving update emails when there are no changes, consider using the `--only-changed` option. Keep in mind that this option will include a hash of the page or attachment contents in the version update message.

## Linking to other documents (relative links)

By default, support for relative links is disabled. To enable it, pass the `--enable-relative-links` flag. The behavior of relative links is similar to [GitHub relative links](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-readmes#relative-links-and-image-paths-in-readme-files), with the exception that links starting with `/` are **not supported** and will be left unchanged.

Reference to a section from another file is possible using Markdown fragment link navigation:
` [link](./file.md#section-name) // note the dash!`

In file.md:
```
## ...
## section name
```

> :warning: Enabling this function requires two uploads for every page containing relative links. First, a page must be uploaded to Confluence with all internal links replaced by placeholders. Then, once the final Confluence link is known, the placeholders will be replaced with the appropriate links.

By default, relative links that point to non-existent files (or files that are not being uploaded in the current batch) will result in an error. To ignore these errors and keep the links as they are, use the `--ignore-relative-link-errors` flag.

## Directory arguments

### Uploading Folders Recursively

To help you mirror large documentation to Confluence, `md2cf` allows you to upload entire folders. When using this feature, `md2cf` will recursively traverse all subdirectories and upload any `.md` files it encounters.

By default, `md2cf` will respect your `.gitignore` file and skip any files or folders it defines. If you prefer to upload everything in the folder, use the `--no-gitignore` option.

Please note that Confluence can only nest pages under other pages. As a result, folders will be represented by empty pages with the same title as the folder in the final upload. You can customize this behavior using one of the three command line parameters defined in the next sections.

#### Customizing folder names

Folder names like `interesting-subsection` or `dir1` are not particularly nice. If you pass the `--beautify-folders` option, all spaces and hyphens in folder names will be replaced with spaces and the first letter will be capitalized, producing `Interesting subsection` and `Dir1`.

Alternatively, you can create a YAML file called `.pages` with the following format in every folder you wish to rename.
If you pass the `--use-pages-file`, the folder will be given that title.

Folder names like `interesting-subsection` or `dir1` may not be aesthetically pleasing. If you use the `--beautify-folders` option, spaces and hyphens in folder names will be replaced with spaces, and the first letter of each word will be capitalized, resulting in `Interesting Subsection` and `Dir1`.

Alternatively, you can create a YAML file called `.pages` in every folder you want to rename, using the following format, and if you use the `--use-pages-file` option, the folder will be renamed using the title specified in the `.pages` file.

```yaml
title: "This is a fantastic title!"
```

#### Collapse single pages

You can collapse directories that only contain one document by passing the `--collapse-single-pages` parameter.

<details>
<summary>Example</summary>
This means that a folder layout like this:

```text
document.md
folder1/
  documentA.md
  documentB.md
folder2/
  other-document.md
```

will be uploaded to Confluence like this:

```text
document
folder1/
  documentA
  documentB
other-document
```
</details>

#### Dealing with empty folders

Passing `--skip-empty` will not create pages for empty folders.

<details>
<summary>Example</summary>
```text
document.md
folder1/
  folder2/
    folder3/
      other-document.md
folderA/
  interesting-document.md
    folderB/
      folderC/
        lonely-document.md
```

will be uploaded as:

```text
document
folder3/
  other-document
folderA/
  interesting-document
  folderC/
    lonely-document
```
</details>

Alternatively, you can specify `--collapse-empty` to merge empty folders together.

<details>
<summary>Example</summary>
```text
document.md
folder1/
  folder2/
    folder3/
      other-document.md
folderA/
  interesting-document.md
    folderB/
      folderC/
        lonely-document.md
```

will be uploaded as:

```text
document
folder1/folder2/folder3/
  other-document
folderA/
  interesting-document
  folderB/folderC/
    lonely-document
```
</details>

## Terminal output format

By default, `md2cf` produces rich output with animated progress bars that are meant for human consumption. If the output is redirected to a file, the progress bars will not be displayed and only the final result will be written to the file. Error messages are always printed to standard error.

In addition to the default format, `md2cf` also supports two other output formats.

### JSON output

When `--output json` is passed to `md2cf`, the JSON output for each page as returned by Confluence will be printed. Note that normal progress output will not be displayed.

> :warning: Please note that JSON entries will only be printed for page creation/updates. They will not be printed for attachment creation/updates and will not be printed for second-pass updates for [relative links](#linking-to-other-documents-relative-links).


### Minimal output

When passing the `--output minimal` option to `md2cf`, the tool will only print the final Confluence URL for each page, as in versions prior to `2.0.0`. The normal progress output will be omitted.

> :warning: Note that URLs will only be printed for page creation/updates. They will not be printed for attachment creation/updates and will not be printed for second-pass updates for [relative links](#linking-to-other-documents-relative-links).


## Library usage

`md2cf` can of course be used as a Python library. It exposes two useful modules: the renderer and the API wrapper.

### Renderer

Use the `ConfluenceRenderer` class to generate Confluence Storage Format
output from a Markdown document.

```python
import mistune
from md2cf.confluence_renderer import ConfluenceRenderer

markdown_text = "# Page title\n\nInteresting *content* here!"

renderer = ConfluenceRenderer(use_xhtml=True)
confluence_mistune = mistune.Markdown(renderer=renderer)
confluence_body = confluence_mistune(markdown_text)
```

### API

md2cf embeds a teeny-tiny implementation of the Confluence Server REST
API that allows you to create, read, and update pages.

```python
from md2cf.api import MinimalConfluence

confluence = MinimalConfluence(host='https://example.com/rest/api', username='foo', password='bar')

confluence.create_page(space='TEST', title='Test page', body='<p>Nothing</p>', update_message='Created page')

page = confluence.get_page(title='Test page', space_key='TEST')
confluence.update_page(page=page, body='New content', update_message='Changed page contents')
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/schneiderl/md2cf",
    "name": "schneiderl-md2cf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "markdown confluence",
    "author": "schneiderl",
    "author_email": "schneiderl@schneiderl.com",
    "download_url": "https://files.pythonhosted.org/packages/7b/db/7599dc72fd80c7db6e630fea43339ff06c66798315620079d1ba485f0869/schneiderl_md2cf-0.99.99.tar.gz",
    "platform": null,
    "description": "# md2cf\n\n`md2cf` is a tool and library that allows you to convert Markdown documents to Confluence Storage format and upload them to a Confluence instance.\n\n## Features\n\n- **Convert Markdown documents:** `md2cf` includes a library that implements a [Mistune](https://github.com/lepture/mistune) renderer, which outputs Confluence Storage Format.\n- **Talk to the Confluence API:** `md2cf` also features an embedded micro-implementation of the [Confluence Server REST API](https://developer.atlassian.com/server/confluence/confluence-server-rest-api/) with basic support for creating and updating pages and attachments.\n- **Automate the upload process:** You can use `md2cf`'s full-featured command line utility to automate the upload process for you.\n\n\n## Installation\n\n```bash\n# Install md2cf via pip\npip install md2cf\n\n# If you only need to use md2cf for uploading documents to Confluence,\n# it's recommended to use pipx:\npipx install md2cf\n```\n\n## Getting started\n\nTo see all available options and parameters, run `md2cf --help`.\n\nTo upload a document, you need to provide at least the following five parameters:\n\n- The **URL** of your Confluence instance, including the path to the REST API (e.g., `http://confluence.example.com/rest/api`)\n- Either:\n    - The **username** and **password** to log in to the instance\n    - A **personal access token**\n- The **space** in which to publish the page\n- The **files or directories** to be uploaded. If none are specified, the contents will be read from standard input.\n\nExample basic usage:\n\n```bash\nmd2cf --host 'https://confluence.example.com/rest/api' --username foo --password bar --space TEST document.md\n```\n\nOr, if using a token:\n\n```bash\nmd2cf --host 'https://confluence.example.com/rest/api' --token '2104v3ryl0ngt0k3n720' --space TEST document.md\n```\n\n> :warning: Avoid entering your password (or token) as a command line parameter, as this is [generally a bad practice](https://unix.stackexchange.com/q/78734). Instead, when running the script interactively, omit the `--password` parameter and securely enter the password when prompted.\n\n> :warning: Note that tokens function differently between [Confluence Cloud](https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/) and [self-hosted instances](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html). When using Confluence Cloud, you should use your token **as your password** with the `--username` and `--password` parameters. With self-hosted instances, use the `--token` parameter instead.\n\nYou can also supply the hostname, username, password, token, and space as **environment variables**:\n\n- `CONFLUENCE_HOST`\n- `CONFLUENCE_USERNAME`\n- `CONFLUENCE_PASSWORD`\n- `CONFLUENCE_TOKEN`\n- `CONFLUENCE_SPACE`\n\nIf you are using self-signed certificates or want to **ignore SSL errors**, use the `--insecure` option.\n\nYou can **upload multiple files** or entire folders. If you specify a folder, `md2cf` will traverse it recursively and upload all files that end in `.md`. For more information, see [Uploading Folders](#uploading-folders).\n\nIf you would like to preview `md2cf`'s actions without modifying Confluence, use the `--dry-run` option. This will print a list of page data without making any changes.\n\n## Page information arguments\n\n### Page title\n\nThe title of the page can be sourced from multiple places, in the following order of priority:\n* The `--title` command-line parameter\n* A `title` entry in the document's front matter, which is a YAML block delimited by `---` lines at the top of the file:\n\n  ```yaml\n  ---\n  title: This is a title\n  ---\n  ```\n* The first top-level header found in the document (i.e., the first `#` header)\n* The filename, if there are no top-level headers.\n\nNote that if you are reading from standard input, you must either specify the title through the command line or include a title as a header or in the front matter within the content.\n\nTo avoid repeating the top level header in the body of the page, pass the `--strip-top-header` parameter to strip it from the document.\n\nWhen uploading entire folders, consider adding a prefix to each page title to prevent collisions. You can do this by using the `--prefix` parameter.\n\n### Removing extra newlines\n\nIf your document uses single newlines to break lines (for example, if it was typeset with a fixed column width), Confluence Cloud might preserve those newlines, resulting in a document that's difficult to read. To fix this, use the `--remove-text-newlines` parameter, which replaces every newline within a paragraph with a space.\n\n\n<details>\n<summary>Example</summary>\nFor example, this will turn\n\n```text\nThis is a document\nwith hardcoded newlines\nin its paragraphs.\n\nIt's not that nice\nto read.\n```\n\ninto\n\n```text\nThis is a document with hardcoded newlines in its paragraphs.\n\nIt's not that nice to read.\n```\n</details>\n\n### Adding a preface and/or postface\n\nThe `--preface-markdown`, `--preface-file`, `--postface-markdown`, and `--postface-file` commands enable you to add text at the beginning or end of each page. This is especially helpful if you're mirroring documentation to Confluence and want to notify users that it will be automatically updated.\n\nThe `--preface-markdown` and `--postface-markdown` options allow you to specify Markdown text directly in the command line. If no text is specified, a default paragraph will be used stating:\n\n> **Contents are auto-generated, do not edit.**\n\nAlternatively, the `--preface-file` and `--postface-file` options allow you to specify a path to a markdown file which will be prepended or appended to every page.\n\n> :warning: Note that preface and postface Markdown is parsed separately and added to the body after the main page has been parsed. Therefore, it will not affect behavior tied to the page contents, such as title or front matter detection.\n\n### Page labels\n\nTo add labels to your page, include a `labels` entry in your document's front matter. The front matter is a YAML block delimited by `---` lines at the top of the file. Here's an example:\n\n```yaml\n---\nlabels:\n- first label\n- second label\n---\n# Rest of the Markdown document\n```\n\nNote that by default, the labels you specify will be added to any existing labels. If you want to replace all existing labels with only the ones you specified, use the `--replace-all-labels` option.\n\n### Parent page\n\nTo upload the page under **a specific parent**, you can provide the parent's page ID using the `--parent-id` parameter, or its title using the `--parent-title` parameter.\n\nTo move a page to a **top-level page** (i.e. directly under the space's Home Page), use the `--top-level` flag.\n\n### Update message\n\nOptionally, you can provide an **update message** using the `--message` parameter to describe the change you made. If you're using the `--only-changed` option at the same time, the version update message will also include a hash of the page or attachment contents at the end.\n\n### Updating an existing page\n\nIf you upload a page with the same title twice, it will update the existing page.\n\nTo update a page using its ID, use the `--page-id` option. This allows you to modify the page's title or update a page with a title that is difficult to use as a parameter.\n\nTo avoid sending notifications to page watchers, use the `--minor-edit` option. This corresponds to the \"Notify watchers\" checkbox when editing pages manually.\n\n### Avoiding uploading content that hasn't changed\n\nTo avoid re-uploading unchanged content and receiving update emails when there are no changes, consider using the `--only-changed` option. Keep in mind that this option will include a hash of the page or attachment contents in the version update message.\n\n## Linking to other documents (relative links)\n\nBy default, support for relative links is disabled. To enable it, pass the `--enable-relative-links` flag. The behavior of relative links is similar to [GitHub relative links](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-readmes#relative-links-and-image-paths-in-readme-files), with the exception that links starting with `/` are **not supported** and will be left unchanged.\n\nReference to a section from another file is possible using Markdown fragment link navigation:\n` [link](./file.md#section-name) // note the dash!`\n\nIn file.md:\n```\n## ...\n## section name\n```\n\n> :warning: Enabling this function requires two uploads for every page containing relative links. First, a page must be uploaded to Confluence with all internal links replaced by placeholders. Then, once the final Confluence link is known, the placeholders will be replaced with the appropriate links.\n\nBy default, relative links that point to non-existent files (or files that are not being uploaded in the current batch) will result in an error. To ignore these errors and keep the links as they are, use the `--ignore-relative-link-errors` flag.\n\n## Directory arguments\n\n### Uploading Folders Recursively\n\nTo help you mirror large documentation to Confluence, `md2cf` allows you to upload entire folders. When using this feature, `md2cf` will recursively traverse all subdirectories and upload any `.md` files it encounters.\n\nBy default, `md2cf` will respect your `.gitignore` file and skip any files or folders it defines. If you prefer to upload everything in the folder, use the `--no-gitignore` option.\n\nPlease note that Confluence can only nest pages under other pages. As a result, folders will be represented by empty pages with the same title as the folder in the final upload. You can customize this behavior using one of the three command line parameters defined in the next sections.\n\n#### Customizing folder names\n\nFolder names like `interesting-subsection` or `dir1` are not particularly nice. If you pass the `--beautify-folders` option, all spaces and hyphens in folder names will be replaced with spaces and the first letter will be capitalized, producing `Interesting subsection` and `Dir1`.\n\nAlternatively, you can create a YAML file called `.pages` with the following format in every folder you wish to rename.\nIf you pass the `--use-pages-file`, the folder will be given that title.\n\nFolder names like `interesting-subsection` or `dir1` may not be aesthetically pleasing. If you use the `--beautify-folders` option, spaces and hyphens in folder names will be replaced with spaces, and the first letter of each word will be capitalized, resulting in `Interesting Subsection` and `Dir1`.\n\nAlternatively, you can create a YAML file called `.pages` in every folder you want to rename, using the following format, and if you use the `--use-pages-file` option, the folder will be renamed using the title specified in the `.pages` file.\n\n```yaml\ntitle: \"This is a fantastic title!\"\n```\n\n#### Collapse single pages\n\nYou can collapse directories that only contain one document by passing the `--collapse-single-pages` parameter.\n\n<details>\n<summary>Example</summary>\nThis means that a folder layout like this:\n\n```text\ndocument.md\nfolder1/\n  documentA.md\n  documentB.md\nfolder2/\n  other-document.md\n```\n\nwill be uploaded to Confluence like this:\n\n```text\ndocument\nfolder1/\n  documentA\n  documentB\nother-document\n```\n</details>\n\n#### Dealing with empty folders\n\nPassing `--skip-empty` will not create pages for empty folders.\n\n<details>\n<summary>Example</summary>\n```text\ndocument.md\nfolder1/\n  folder2/\n    folder3/\n      other-document.md\nfolderA/\n  interesting-document.md\n    folderB/\n      folderC/\n        lonely-document.md\n```\n\nwill be uploaded as:\n\n```text\ndocument\nfolder3/\n  other-document\nfolderA/\n  interesting-document\n  folderC/\n    lonely-document\n```\n</details>\n\nAlternatively, you can specify `--collapse-empty` to merge empty folders together.\n\n<details>\n<summary>Example</summary>\n```text\ndocument.md\nfolder1/\n  folder2/\n    folder3/\n      other-document.md\nfolderA/\n  interesting-document.md\n    folderB/\n      folderC/\n        lonely-document.md\n```\n\nwill be uploaded as:\n\n```text\ndocument\nfolder1/folder2/folder3/\n  other-document\nfolderA/\n  interesting-document\n  folderB/folderC/\n    lonely-document\n```\n</details>\n\n## Terminal output format\n\nBy default, `md2cf` produces rich output with animated progress bars that are meant for human consumption. If the output is redirected to a file, the progress bars will not be displayed and only the final result will be written to the file. Error messages are always printed to standard error.\n\nIn addition to the default format, `md2cf` also supports two other output formats.\n\n### JSON output\n\nWhen `--output json` is passed to `md2cf`, the JSON output for each page as returned by Confluence will be printed. Note that normal progress output will not be displayed.\n\n> :warning: Please note that JSON entries will only be printed for page creation/updates. They will not be printed for attachment creation/updates and will not be printed for second-pass updates for [relative links](#linking-to-other-documents-relative-links).\n\n\n### Minimal output\n\nWhen passing the `--output minimal` option to `md2cf`, the tool will only print the final Confluence URL for each page, as in versions prior to `2.0.0`. The normal progress output will be omitted.\n\n> :warning: Note that URLs will only be printed for page creation/updates. They will not be printed for attachment creation/updates and will not be printed for second-pass updates for [relative links](#linking-to-other-documents-relative-links).\n\n\n## Library usage\n\n`md2cf` can of course be used as a Python library. It exposes two useful modules: the renderer and the API wrapper.\n\n### Renderer\n\nUse the `ConfluenceRenderer` class to generate Confluence Storage Format\noutput from a Markdown document.\n\n```python\nimport mistune\nfrom md2cf.confluence_renderer import ConfluenceRenderer\n\nmarkdown_text = \"# Page title\\n\\nInteresting *content* here!\"\n\nrenderer = ConfluenceRenderer(use_xhtml=True)\nconfluence_mistune = mistune.Markdown(renderer=renderer)\nconfluence_body = confluence_mistune(markdown_text)\n```\n\n### API\n\nmd2cf embeds a teeny-tiny implementation of the Confluence Server REST\nAPI that allows you to create, read, and update pages.\n\n```python\nfrom md2cf.api import MinimalConfluence\n\nconfluence = MinimalConfluence(host='https://example.com/rest/api', username='foo', password='bar')\n\nconfluence.create_page(space='TEST', title='Test page', body='<p>Nothing</p>', update_message='Created page')\n\npage = confluence.get_page(title='Test page', space_key='TEST')\nconfluence.update_page(page=page, body='New content', update_message='Changed page contents')\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Convert Markdown documents to Confluence",
    "version": "0.99.99",
    "project_urls": {
        "Homepage": "https://github.com/schneiderl/md2cf"
    },
    "split_keywords": [
        "markdown",
        "confluence"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7bdf077506570ccde0c682f28d65675691a201999cf4203859fa31805c5571ab",
                "md5": "043fda8c50a90b28b81bb02085659128",
                "sha256": "2e8595dc18206421f3a612fb7da1d924eaf3376d2162b38353feecab65fc3c69"
            },
            "downloads": -1,
            "filename": "schneiderl_md2cf-0.99.99-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "043fda8c50a90b28b81bb02085659128",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 25961,
            "upload_time": "2023-11-10T12:40:36",
            "upload_time_iso_8601": "2023-11-10T12:40:36.263165Z",
            "url": "https://files.pythonhosted.org/packages/7b/df/077506570ccde0c682f28d65675691a201999cf4203859fa31805c5571ab/schneiderl_md2cf-0.99.99-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7bdb7599dc72fd80c7db6e630fea43339ff06c66798315620079d1ba485f0869",
                "md5": "352b42aa1fb9a92a4734946181868ce0",
                "sha256": "53a7ff96e8c16c48e34e1ebf7aa8c27316c4c849971c6450b332a5236aeb9762"
            },
            "downloads": -1,
            "filename": "schneiderl_md2cf-0.99.99.tar.gz",
            "has_sig": false,
            "md5_digest": "352b42aa1fb9a92a4734946181868ce0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 27334,
            "upload_time": "2023-11-10T12:40:37",
            "upload_time_iso_8601": "2023-11-10T12:40:37.691483Z",
            "url": "https://files.pythonhosted.org/packages/7b/db/7599dc72fd80c7db6e630fea43339ff06c66798315620079d1ba485f0869/schneiderl_md2cf-0.99.99.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-10 12:40:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "schneiderl",
    "github_project": "md2cf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "schneiderl-md2cf"
}
        
Elapsed time: 0.13765s