Package: mdtocf
RequirementsThis Python package has been tested and designed for:Ubuntu 18.04 LTSPython 3.7.5and several python libraries:PickelDB v0.9Mistune v2.0 Markdown ParserAtlassian Python API v1.5Please seerequirements.txtfor specific python packages/modules versions required.Missing Features (Todo)Attachments (e.g. images, pdf, etc.)InstallDownload the package and prepare Python environment alternatives:gitclone"https://github.com/olafrv/mdtocf.git"cdmdtocf
makevirtualenvInstall the package for its use:Note:If you skip virtual environment you should ensure using python >= 3.7sourcevenv/bin/activate# Activate virtual environment (optional)makeinstall# Option 1: Use local package in ./mdtocfmakeinstall-pypi# Option 2: Install package from PyPImkdir-p~/dbs# Create temporal database directorydeactivate# Deactivate virtual environment (if activated)See an example code inmdtocf.pyand the targettest-publishinsideMakefileshow some parameters examples.Publish using local scriptNote:If you skip virtual environment you should ensure using python >= 3.7sourcevenv/bin/activate# Virtual environment (if created)PYTHON=$(makepython-path)# Used: venv/bin/python or $PATH (python3.7, python3 or python)${PYTHON}-mmdtocf.mdtocf--help${PYTHON}-mmdtocf.mdtocf\--confluenceUsername"olafrv@gmail.com"\--confluenceApiToken"****************"\--confluenceUrl"https://olafrv.atlassian.net"\--confluenceSpace"TEST"\--confluenceParentPageId"33114"\--confluencePageTitlePrefix"[Test] "\--markdownDir./examples\--db~/dbs/examples.db
deactivate# Deactivate virtual environment (if activated)Publish using Docker (Image locally built)makedocker
dockerrun--rm-itmdtocf--help
dockerrun--rm-it\--mounttype=bind,source="$(pwd)"/examples,target=/mdtocf/examples\--mounttype=bind,source=~/dbs,target=/mdtocf/dbs\mdtocf\--confluenceUsername"olafrv@gmail.com"\--confluenceApiToken"****************"\--confluenceUrl"https://olafrv.atlassian.net"\--confluenceSpace"TEST"\--confluenceParentPageId"33114"\--confluencePageTitlePrefix"[Test] "\--markdownDir"./examples"\--db~/dbs/examples.dbPublish using Docker (Image downloaded from Github's Packages)# Check <VERSION> in https://github.com/olafrv/mdtocf/packagesexportIMAGE=docker.pkg.github.com/olafrv/mdtocf/mdtocf:<VERSION>dockerrun--rm-it$IMAGE--help
dockerrun--rm-it\--mounttype=bind,source="$(pwd)"/examples,target=/mdtocf/examples\--mounttype=bind,source=~/dbs,target=/mdtocf/dbs\$IMAGE--confluenceUsername"olafrv@gmail.com"\--confluenceApiToken"****************"\--confluenceUrl"https://olafrv.atlassian.net"\--confluenceSpace"TEST"\--confluenceParentPageId"33114"\--confluencePageTitlePrefix"[Test] "\--markdownDir./examples\--db~/dbs/examples.dbOutput and ResultsOutput:DEL => Id: 3409835, Title: [Test] Folder B
DEL => Id: 3409844, Title: [Test] 1
DEL => Id: 3409824, Title: [Test] Folder A
DEL => Id: 3409853, Title: [Test] Page AA
DEL => Id: att3409862, Title: example.png
DEL Att. => Title: example.png
DEL => Id: 3409867, Title: [Test] Example Page
UPD => Title: [Test] Folder A
Can't find '[Test] Folder A' page on the https://olafrv.atlassian.net/wiki!
IDX => Title: [Test] Folder B
Can't find '[Test] Folder B' page on the https://olafrv.atlassian.net/wiki!
UPD => Title: [Test] 1
Can't find '[Test] 1' page on the https://olafrv.atlassian.net/wiki!
UPD => Title: [Test] Page AA
Can't find '[Test] Page AA' page on the https://olafrv.atlassian.net/wiki!
UPD Att. => Title: example.png
UPD Att. => Title: example.png
UPD => Title: [Test] Example Page
Can't find '[Test] Example Page' page on the https://olafrv.atlassian.net/wiki!The"Can't find..."means"not found but creating..."(Python Atlassian API).Results in ConfluenceRendering and publishing./examplesproduce the following final result in Confluence:About Markdown CompatibilityThis scripts depends onMistune v2 Markdown Parser,
compatible withCommonMarkThe (optional) metadata heading in markdown (.md) files likes the one which follows below used byHugo, it is not part of CommonMarkdown standard, but just a popular way of specify in YAML markdown metadata usable for external tools.---title:My Page Titledate:2019-03-26T08:47:11+01:00draft:truechapter:truekind:index---It is parsed and partially used by this script to organize the content in
Attlasian Confluence. A test for this can be run:maketest-reUninstallsourcevenv/bin/activate# Activate virtual environment (optional)makeuninstall# Remove installed package and dependenciesdeactivate# Deactivate virtual environment (if activated)Development & Testingmakepython-version# Print detected Python version (also after target "dev")makepython-path# Print detected Python binary (also after target "dev")makedev# Virtualenv and install (./mdtocf)maketest-re# Test markdown metadata regexpmaketest-publish# Publish ./examples to Atlassianmaketest-docker# Test docker imagemaketest-gihub-docker# Test github docker package imagegitcommit-a# After increment VERSION file content#make github-package    # Already done by target "github-release"#make pypi-live         # Already done by target "github-release"makegithub-release# Will trigger .github/workflows/mdtocf.ymlmakeclean# Delete temporal dirs, files and docker imagesReferencesMarkdownhttps://spec.commonmark.orghttps://spec.commonmark.org/dingus/Mistune v2https://github.com/lepture/mistunehttps://mistune.readthedocs.io/en/latest/Python v3https://docs.python.org/3/https://docs.python.org/3/howto/regex.htmlhttps://pypi.org/project/atlassian-python-api/https://atlassian-python-api.readthedocs.io/confluence.htmlConfluence and Storage Format (Cloud API)https://developer.atlassian.com/cloud/confluence/rest/https://confluence.atlassian.com/doc/confluence-server-documentation-135922.htmlhttps://confluence.atlassian.com/doc/confluence-storage-format-790796544.htmlhttps://confluence.atlassian.com/doc/macros-139387.htmlhttps://confluence.atlassian.com/conf59/code-block-macro-792499083.htmlhttps://confluence.atlassian.com/confkb/how-to-get-confluence-page-id-648380445.htmlhttps://confluence.atlassian.com/doc/delete-or-restore-a-page-139429.html