migrate body API

This commit is contained in:
2022-10-05 12:32:48 +03:00
parent 5811e0e878
commit 9b16d5017a
4 changed files with 25 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
import base64
import os
import re
import uuid
from .html2text import html2text
TOOLTIP_REGEX = r"(\/\/\/(.+)\/\/\/)"
@@ -236,18 +236,22 @@ def cleanup(body):
return newbody
def extract_md(body, oid):
def extract_md(body, oid=""):
newbody = body
if newbody:
newbody = extract_md_images(newbody, oid)
uid = oid or uuid.uuid4()
newbody = extract_md_images(newbody, uid)
if not newbody:
raise Exception("extract_images error")
newbody = cleanup(newbody)
if not newbody:
raise Exception("cleanup error")
newbody, placed = place_tooltips(newbody)
if not newbody:
raise Exception("place_tooltips error")
if placed:
newbody = "import Tooltip from '$/components/Article/Tooltip'\n\n" + newbody
return newbody