-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<!DOCTYPE html> | ||
<html lang="zh"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Markdown 过滤器</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
line-height: 1.6; | ||
margin: 0; | ||
padding: 20px; | ||
background-color: #f4f4f4; | ||
} | ||
.container { | ||
max-width: 800px; | ||
margin: 0 auto; | ||
background-color: #fff; | ||
padding: 20px; | ||
border-radius: 5px; | ||
box-shadow: 0 0 10px rgba(0,0,0,0.1); | ||
} | ||
h1 { | ||
text-align: center; | ||
color: #333; | ||
} | ||
textarea { | ||
width: 100%; | ||
height: 200px; | ||
margin-bottom: 10px; | ||
padding: 10px; | ||
border: 1px solid #ddd; | ||
border-radius: 4px; | ||
resize: vertical; | ||
} | ||
button { | ||
display: block; | ||
width: 100%; | ||
padding: 10px; | ||
background-color: #4CAF50; | ||
color: white; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
font-size: 16px; | ||
} | ||
button:hover { | ||
background-color: #45a049; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Markdown 过滤器</h1> | ||
<textarea id="input" placeholder="在这里粘贴您的 Markdown 内容..."></textarea> | ||
<button onclick="filterMarkdown()">过滤</button> | ||
<textarea id="output" placeholder="过滤后的内容将显示在这里..." readonly></textarea> | ||
</div> | ||
|
||
<script> | ||
function filterMarkdown() { | ||
const input = document.getElementById('input').value; | ||
const output = document.getElementById('output'); | ||
|
||
let filtered = input; | ||
|
||
// 移除 Jekyll 元数据 | ||
filtered = filtered.replace(/^---[\s\S]*?---/, ''); | ||
|
||
// 移除 HTML 标签 | ||
filtered = filtered.replace(/<[^>]*>/g, ''); | ||
|
||
// 移除图片 | ||
filtered = filtered.replace(/!\[.*?\]\(.*?\)/g, ''); | ||
|
||
// 移除链接,但保留链接文本 | ||
filtered = filtered.replace(/\[([^\]]+)\]\(.*?\)/g, '$1'); | ||
|
||
// 移除代码块 | ||
filtered = filtered.replace(/```[\s\S]*?```/g, ''); | ||
|
||
// 移除行内代码 | ||
filtered = filtered.replace(/`[^`\n]+`/g, ''); | ||
|
||
// 移除标题符号 (#) | ||
filtered = filtered.replace(/^#{1,6}\s/gm, ''); | ||
|
||
// 移除列表符号 | ||
filtered = filtered.replace(/^[-*+]\s/gm, ''); | ||
|
||
// 移除数字列表 | ||
filtered = filtered.replace(/^\d+\.\s/gm, ''); | ||
|
||
// 移除引用符号 | ||
filtered = filtered.replace(/^>\s/gm, ''); | ||
|
||
// 移除水平线 | ||
filtered = filtered.replace(/^[-*_]{3,}\s*$/gm, ''); | ||
|
||
// 移除表格 | ||
filtered = filtered.replace(/^\|.*\|$/gm, ''); | ||
|
||
// 移除多余的空行 | ||
filtered = filtered.replace(/\n{3,}/g, '\n\n'); | ||
|
||
output.value = filtered.trim(); | ||
} | ||
</script> | ||
</body> | ||
</html> |