feat: release version 1.0.5

This commit is contained in:
2026-08-20 14:30:22 +09:00
parent f910db8901
commit 6537ab1f20
35 changed files with 1151 additions and 181 deletions
+48
View File
@@ -0,0 +1,48 @@
import { marked, Renderer } from 'marked';
function escapeHtml(value: string): string {
return value
.replaceAll('&', '&')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;')
.replaceAll('"', '&quot;')
.replaceAll("'", '&#39;');
}
function safeUrl(value: string): string | null {
const trimmed = value.trim();
if (trimmed.startsWith('#') || trimmed.startsWith('/')) return trimmed;
try {
const url = new URL(trimmed);
return ['http:', 'https:'].includes(url.protocol) ? url.href : null;
} catch {
return null;
}
}
const renderer = new Renderer();
renderer.html = ({ text }) => escapeHtml(text);
renderer.link = function ({ href, title, tokens }) {
const label = this.parser.parseInline(tokens);
const url = safeUrl(href);
if (!url) return label;
const titleAttribute = title ? ` title="${escapeHtml(title)}"` : '';
return `<a href="${escapeHtml(url)}"${titleAttribute} target="_blank" rel="noreferrer">${label}</a>`;
};
renderer.image = ({ href, title, text }) => {
const url = safeUrl(href);
if (!url) return escapeHtml(text);
const titleAttribute = title ? ` title="${escapeHtml(title)}"` : '';
return `<img src="${escapeHtml(url)}" alt="${escapeHtml(text)}"${titleAttribute} loading="lazy">`;
};
export function renderReleaseMarkdown(markdown: string): string {
return marked.parse(markdown, {
async: false,
breaks: true,
gfm: true,
renderer
}) as string;
}