{"id":13483570,"url":"https://github.com/longbridge/html-pipeline","last_synced_at":"2026-01-12T01:51:20.567Z","repository":{"id":55066281,"uuid":"241021763","full_name":"longbridge/html-pipeline","owner":"longbridge","description":"HTML processing filters and utilities in Go version","archived":false,"fork":false,"pushed_at":"2025-03-31T02:32:47.000Z","size":99,"stargazers_count":24,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-01T22:28:07.244Z","etag":null,"topics":["go","html","html-processor","markdown","pipeline","text-processor"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/longbridge.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-17T04:47:56.000Z","updated_at":"2025-09-06T19:33:55.000Z","dependencies_parsed_at":"2025-08-11T08:31:29.341Z","dependency_job_id":null,"html_url":"https://github.com/longbridge/html-pipeline","commit_stats":null,"previous_names":["huacnlee/html-pipeline","longbridge/html-pipeline","longbridgeapp/html-pipeline"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/longbridge/html-pipeline","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longbridge%2Fhtml-pipeline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longbridge%2Fhtml-pipeline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longbridge%2Fhtml-pipeline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longbridge%2Fhtml-pipeline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/longbridge","download_url":"https://codeload.github.com/longbridge/html-pipeline/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longbridge%2Fhtml-pipeline/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28331257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"ssl_error","status_checked_at":"2026-01-12T00:36:15.229Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","html","html-processor","markdown","pipeline","text-processor"],"created_at":"2024-07-31T17:01:12.893Z","updated_at":"2026-01-12T01:51:20.551Z","avatar_url":"https://github.com/longbridge.png","language":"Go","funding_links":[],"categories":["Markdown/Text Processors"],"sub_categories":[],"readme":"# HTML Pipeline for Go\n\n\n[![Go](https://github.com/longbridgeapp/html-pipeline/actions/workflows/go.yml/badge.svg)](https://github.com/longbridgeapp/html-pipeline/actions/workflows/go.yml)\n\nThis is go version of [html-pipeline](https://github.com/jch/html-pipeline)\n\n## Other versions\n\n- [html-pipeline](https://github.com/jch/html-pipeline) - Ruby\n- [html-pipeline.cr](https://github.com/huacnlee/html-pipeline.cr) - Crystal\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/PuerkitoBio/goquery\"\n\tpipeline \"github.com/longbridgeapp/html-pipeline\"\n)\n\n// ImageMaxWidthFilter a custom filter example\ntype ImageMaxWidthFilter struct{}\n\nfunc (f ImageMaxWidthFilter) Call(doc *goquery.Document) (err error) {\n\tdoc.Find(\"img\").Each(func(i int, node *goquery.Selection) {\n\t\tnode.SetAttr(\"style\", `max-width: 100%`)\n\t})\n\n\treturn\n}\n\nfunc main() {\n\tpipe := pipeline.NewPipeline([]pipeline.Filter{\n\t\tpipeline.MarkdownFilter{},\n\t\tpipeline.SanitizationFilter{},\n\t\tImageMaxWidthFilter{},\n\t\tpipeline.MentionFilter{\n\t\t\tPrefix: \"#\",\n\t\t\tFormat: func(name string) string {\n\t\t\t\treturn fmt.Sprintf(`\u003ca href=\"https://github.com/topic/%s\"\u003e#%s\u003c/a\u003e`, name, name)\n\t\t\t},\n\t\t},\n\t\tpipeline.MentionFilter{\n\t\t\tPrefix: \"@\",\n\t\t\tFormat: func(name string) string {\n\t\t\t\treturn fmt.Sprintf(`\u003ca href=\"https://github.com/%s\"\u003e@%s\u003c/a\u003e`, name, name)\n\t\t\t},\n\t\t},\n\t})\n\n\tmarkdown := `# Hello world\n\n![](javascript:alert) [Click me](javascript:alert)\n\nThis is #html-pipeline example, @huacnlee created.`\n\tout, _ := pipe.Call(markdown)\n\tfmt.Println(out)\n\n\t/*\n\t\t\u003ch1\u003eHello world\u003c/h1\u003e\n\n\t\t\u003cp\u003e\u003cimg alt=\"\" style=\"max-width: 100%\"/\u003e Click me\u003c/p\u003e\n\n\t\t\u003cp\u003eThis is \u003ca href=\"https://github.com/topic/html-pipeline\"\u003e#html-pipeline\u003c/a\u003e example, \u003ca href=\"https://github.com/huacnlee\"\u003e@huacnlee\u003c/a\u003e created.\u003c/p\u003e\n\t*/\n}\n```\n\nhttps://play.golang.org/p/zB0T7KczdB4\n\n## Use for Plain Text case\n\nSometimes, you may want use html-pipeline to manage the Plain Text process.\n\nFor example:\n\n- Match mentions, and then send notifications.\n- Convert Mention / HashTag or other text into other format.\n\nBut in HTML mode, it will escape some chars (`\"`, `'`, `\u0026`) ... We don't wants that.\n\nSo, there have `NewPlainPipeline` method for you to create a plain mode pipeline without any escape.\n\n\u003e NOTE: For secruity, this pipeline will remove all HTML tags `\u003c.+?\u003e`\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/longbridgeapp/html-pipeline\"\n)\n\nfunc main() {\n\tpipe := pipeline.NewPlainPipeline([]pipeline.Filter{\n\t\tpipeline.MentionFilter{\n\t\t\tPrefix: \"#\",\n\t\t\tFormat: func(name string) string {\n\t\t\t\treturn fmt.Sprintf(`[hashtag name=\"%s\"]%s[/hashtag]`, name, name)\n\t\t\t},\n\t\t},\n\t\tpipeline.MentionFilter{\n\t\t\tPrefix: \"@\",\n\t\t\tFormat: func(name string) string {\n\t\t\t\treturn fmt.Sprintf(`[mention name=\"%s\"]@%s[/mention]`, name, name)\n\t\t\t},\n\t\t},\n\t})\n\n\ttext := `\"Hello\" \u0026 'world' this \u003cscript\u003edanger\u003c/script\u003e is #html-pipeline created by @huacnlee.`\n\tout, _ := pipe.Call(text)\n\tfmt.Println(out)\n\t// \"Hello\" \u0026 'world' this danger is [hashtag name=\"html-pipeline\"]html-pipeline[/hashtag] created by [mention name=\"huacnlee\"]@huacnlee[/mention].\n}\n```\n\nhttps://play.golang.org/p/vxKZU9jJi3u\n\n## Built-in filters\n\n- [SanitizationFilter](https://github.com/longbridgeapp/html-pipeline/blob/master/sanitization_filter.go) - Use [bluemonday](github.com/microcosm-cc/bluemonday) default UGCPolicy to sanitize html\n- [MarkdownFilter](https://github.com/longbridgeapp/html-pipeline/blob/master/markdown_filter.go) - Use [blackfriday](https://github.com/russross/blackfriday) to covert Markdown to HTML.\n- [MentionFilter](https://github.com/longbridgeapp/html-pipeline/blob/master/mention_filter.go) - Match Mention or HashTag like Twitter.\n- [HTMLEscapeFilter](https://github.com/longbridgeapp/html-pipeline/blob/master/html_escape_filter.go) - HTML Escape for plain text.\n- [SimpleFormatFilter](https://github.com/longbridgeapp/html-pipeline/blob/master/simple_format_filter.go) - Format plain text for covert `\\n\\n` into paragraph, like Rails [simple_format](https://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-simple_format).\n- [AutoCorrectFilter](https://github.com/longbridgeapp/html-pipeline/blob/master/auto_correct_filter.go) - Use [AutoCorrect](https://github.com/longbridgeapp/autocorrect) to automatically add spaces between CJK and English words.\n- [ImageProxyFilter](https://github.com/longbridgeapp/html-pipeline/blob/master/image_proxy_filter.go) - _DEPRECATED_ A filter can match all `img` to replace src as proxy url with [imageproxy](https://github.com/longbridgeapp/imageproxy).\n- [ImageURLFilter](https://github.com/longbridgeapp/html-pipeline/blob/master/image_url_filter.go) - A filter can match `img` to replace with rules like ([imageproxy](https://github.com/willnorris/imageproxy), Ban URL, Thumb version ...).\n- [ExternalLinkFilter](https://github.com/longbridgeapp/html-pipeline/blob/master/external_link_filter.go) a filter to match external links to add `rel=\"nofollow\"`, `target=\"_blank\"`.\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flongbridge%2Fhtml-pipeline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flongbridge%2Fhtml-pipeline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flongbridge%2Fhtml-pipeline/lists"}