Edurag_beta / app /utils /markdowns_utils.py
Nugh75's picture
moduliazione del programma
080146c
raw
history blame contribute delete
521 Bytes
import re
# =====================================
# Funzioni relative al Markdown
# =====================================
def clean_markdown(text):
"""Rimuove markdown dal testo"""
text = re.sub(r'```[\s\S]*?```', '', text) # blocchi codice
text = re.sub(r'`.*?`', '', text) # codice inline
text = re.sub(r'\[([^\]]+)\]\([^\)]+\)', r'\1', text) # link
text = re.sub(r'\*\*(.*?)\*\*', r'\1', text) # bold
text = re.sub(r'\*(.*?)\*', r'\1', text) # italic
return text.strip()