diff --git a/markdown.go b/markdown.go index 21a7d35..af155aa 100644 --- a/markdown.go +++ b/markdown.go @@ -27,16 +27,6 @@ var mdrenderer = html.NewRenderer(html.RendererOptions{ }, }) -func stripLinksFromMarkdown(md string) string { - // Regular expression to match Markdown links and HTML links - linkRegex := regexp.MustCompile(`\[([^\]]*)\]\([^)]*\)|]*>(.*?)`) - - // Replace both Markdown and HTML links with just the link text - strippedMD := linkRegex.ReplaceAllString(md, "$1$2") - - return strippedMD -} - var tgivmdrenderer = html.NewRenderer(html.RendererOptions{ Flags: html.CommonFlags | html.HrefTargetBlank, RenderNodeHook: func(w io.Writer, node ast.Node, entering bool) (ast.WalkStatus, bool) { @@ -85,10 +75,6 @@ func mdToHTML(md string, usingTelegramInstantView bool) string { // create HTML renderer with extensions output := string(markdown.Render(doc, renderer)) - if skipLinks { - output = stripLinksFromMarkdown(output) - } - // sanitize content output = sanitizeXSS(output) diff --git a/render_event.go b/render_event.go index 23448f9..b068287 100644 --- a/render_event.go +++ b/render_event.go @@ -235,7 +235,7 @@ func renderEvent(w http.ResponseWriter, r *http.Request) { if data.event.Kind == 30023 || data.event.Kind == 30024 { // Remove duplicate title inside the body data.content = strings.ReplaceAll(data.content, "# "+data.event.subject, "") - data.content = mdToHTML(data.content, data.templateId == TelegramInstantView, false) + data.content = mdToHTML(data.content, data.templateId == TelegramInstantView) } else if data.event.Kind == 30818 { data.content = asciidocToHTML(data.content) } else { diff --git a/utils.go b/utils.go index c4618d5..4248ed3 100644 --- a/utils.go +++ b/utils.go @@ -343,7 +343,7 @@ func renderQuotesAsHTML(ctx context.Context, input string, usingTelegramInstantV var content string if event.Kind == 30023 { - content = mdToHTML(event.Content, usingTelegramInstantView, false) + content = mdToHTML(event.Content, usingTelegramInstantView) } else { content = basicFormatting(event.Content, false, usingTelegramInstantView, false) }