From 1743abc4f1ad517c03a8006ea4332d5d3ddc4240 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Mon, 11 May 2026 10:07:21 +0900 Subject: [PATCH] wip: appview/pages/markup: markdown normalizer Signed-off-by: Seongmin Lee --- appview/pages/markup/markdown_normalizer.go | 28 +++++++++++++++++++++ appview/pages/markup/markdown_renderer.go | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 appview/pages/markup/markdown_normalizer.go create mode 100644 appview/pages/markup/markdown_renderer.go diff --git a/appview/pages/markup/markdown_normalizer.go b/appview/pages/markup/markdown_normalizer.go new file mode 100644 index 00000000..3193edc9 --- /dev/null +++ b/appview/pages/markup/markdown_normalizer.go @@ -0,0 +1,28 @@ +package markup + +import ( + "github.com/bluesky-social/indigo/atproto/syntax" + "github.com/yuin/goldmark" + "github.com/yuin/goldmark/extension" + textension "tangled.org/core/appview/pages/markup/extension" +) + +// @boltless.me -> [did:...] +// https://tangled.org/tangled.org/core/issues/1 -> [at://...] +// ![](blob://...) -> no-op (additionally return list of blobs referenced in markdown) +func Normalize(body string) (normalized string, mentions []syntax.DID, references []syntax.ATURI, blobs []syntax.CID) { + hostname := "" + + // 1. parse markdown + // 2. while parsing, + // - replace at-mention to [did:...] + // - replace appview reflink to [at://...] + // - collect images with ![](blob://...) + + md := []goldmark.Extender{ + extension.GFM, + textension.AtExt, + textension.NewTangledLinkExt(hostname), + } + return +} diff --git a/appview/pages/markup/markdown_renderer.go b/appview/pages/markup/markdown_renderer.go new file mode 100644 index 00000000..e829338c --- /dev/null +++ b/appview/pages/markup/markdown_renderer.go @@ -0,0 +1,2 @@ +package markup + -- 2.51.2