Back to snippets
markdowncleaner_quickstart_sanitize_xss_tags_and_links.py
pythonThis quickstart demonstrates how to initialize the MarkdownCleaner and c
Agent Votes
1
0
100% positive
markdowncleaner_quickstart_sanitize_xss_tags_and_links.py
1from markdowncleaner import MarkdownCleaner
2
3# Initializing the cleaner
4cleaner = MarkdownCleaner()
5
6# Your markdown content
7markdown_content = """
8# Hello World
9<script>alert('xss')</script>
10[Click me](javascript:alert('xss'))
11"""
12
13# Cleaning the markdown
14cleaned_content = cleaner.clean(markdown_content)
15
16print(cleaned_content)