Blog

Xwiki Import Markdown «CONFIRMED»

In an exclusive interview, Jane Doe told us her experience of what happened before, during, and after she was sex trafficked by GirlsDoPorn. This is her story.

xwiki import markdown

Xwiki Import Markdown «CONFIRMED»

#!/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

# Code blocks markdown_text = re.sub(r'```(\w*)\n(.*?)```', r'{{code language="\1"}}\n\2\n{{/code}}', markdown_text, flags=re.DOTALL) xwiki import markdown

def import_markdown_file(file_path, page_name): """Import a markdown file to XWiki""" flags=re.DOTALL) def import_markdown_file(file_path

class XWikiMarkdownImporter: def (self, url, username, password): self.base_url = url.rstrip('/') self.auth = HTTPBasicAuth(username, password) self.session = requests.Session() self.session.auth = self.auth xwiki import markdown

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

def batch_import(self, directory, space): """Import all markdown files from a directory""" md_files = list(Path(directory).glob('*.md')) if not md_files: print(f"No .md files found in {directory}") return print(f"Found {len(md_files)} markdown files") success_count = 0 for md_file in md_files: if self.import_file(md_file, space): success_count += 1 print(f"\nImport complete: {success_count}/{len(md_files)} successful") if name == " main ": importer = XWikiMarkdownImporter( url="http://localhost:8080/xwiki", username="Admin", password="admin" )