Xwiki Import Markdown File

#!/usr/bin/env python3 """ XWiki Markdown Importer Requires: pip install requests markdown beautifulsoup4 """ import requests import os import sys import re from requests.auth import HTTPBasicAuth from pathlib import Path

# Bold and Italic markdown_text = re.sub(r'\*\*(.*?)\*\*', r'**\1**', markdown_text) markdown_text = re.sub(r'\*(.*?)\*', r'//\1//', markdown_text)

# Send request response = requests.put( url, json=data, auth=HTTPBasicAuth(USERNAME, PASSWORD), headers={"Content-Type": "application/json"} ) xwiki import markdown

# Import single file importer.import_file("document.md", space="Main")

# Links markdown_text = re.sub(r'\[(.*?)\]\((.*?)\)', r'[[\1>>\2]]', markdown_text) markdown_text) markdown_text = re.sub(r'\*(.*?)\*'

# Wrap in markdown macro wiki_content = f"{{{{markdown}}}}\n{markdown_content}\n{{{{/markdown}}}}"

# Lists markdown_text = re.sub(r'^\- (.*?)$', r'* \1', markdown_text, flags=re.M) markdown_text = re.sub(r'^\* (.*?)$', r'* \1', markdown_text, flags=re.M) markdown_text = re.sub(r'^\+ (.*?)$', r'** \1', markdown_text, flags=re.M) flags=re.M) markdown_text = re.sub(r'^\* (.*?)$'

return markdown_text with open('document.md', 'r') as f: md_content = f.read()

The administration is not responsible for the content of the material.
Copyright holders
Repack by R.G. Mechanics © 2024
xwiki import markdown