{"id":13412665,"url":"https://github.com/aymerick/douceur","last_synced_at":"2025-10-18T10:24:00.032Z","repository":{"id":30112832,"uuid":"33662664","full_name":"aymerick/douceur","owner":"aymerick","description":"A simple CSS parser and inliner in Go","archived":false,"fork":false,"pushed_at":"2022-09-11T15:20:35.000Z","size":46,"stargazers_count":243,"open_issues_count":9,"forks_count":43,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-07-31T20:51:16.310Z","etag":null,"topics":["css-parser","go"],"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/aymerick.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}},"created_at":"2015-04-09T10:21:26.000Z","updated_at":"2024-07-22T17:05:42.000Z","dependencies_parsed_at":"2022-08-26T09:52:19.147Z","dependency_job_id":null,"html_url":"https://github.com/aymerick/douceur","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymerick%2Fdouceur","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymerick%2Fdouceur/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymerick%2Fdouceur/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymerick%2Fdouceur/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aymerick","download_url":"https://codeload.github.com/aymerick/douceur/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254404357,"owners_count":22065641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["css-parser","go"],"created_at":"2024-07-30T20:01:27.534Z","updated_at":"2025-10-18T10:23:59.967Z","avatar_url":"https://github.com/aymerick.png","language":"Go","funding_links":[],"categories":["Email","\u003cspan id=\"电子邮件-email\"\u003e电子邮件 Email\u003c/span\u003e","电子邮件","電子郵件","邮件库","Relational Databases","邮件"],"sub_categories":["Advanced Console UIs","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","Search and Analytic Databases","检索及分析资料库","高級控制台界面","SQL 查询语句构建库","高级控制台界面"],"readme":"# douceur [![Build Status](https://secure.travis-ci.org/aymerick/douceur.svg?branch=master)](http://travis-ci.org/aymerick/douceur)\n\nA simple CSS parser and inliner in Golang.\n\n![Douceur Logo](https://github.com/aymerick/douceur/blob/master/douceur.png?raw=true \"Douceur\")\n\nParser is vaguely inspired by [CSS Syntax Module Level 3](http://www.w3.org/TR/css3-syntax) and [corresponding JS parser](https://github.com/tabatkins/parse-css).\n\nInliner only parses CSS defined in HTML document, it *DOES NOT* fetch external stylesheets (for now).\n\nInliner inserts additional attributes when possible, for example:\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n  \u003cstyle type=\"text/css\"\u003e\n    body {\n      background-color: #f2f2f2;\n    }\n  \u003c/style\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cp\u003eInline me !\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e`\n```\n\nBecomes:\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n  \u003c/head\u003e\n  \u003cbody style=\"background-color: #f2f2f2;\" bgcolor=\"#f2f2f2\"\u003e\n    \u003cp\u003eInline me !\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e`\n```\n\nThe `bgcolor` attribute is inserted, in addition to the inlined `background-color` style.\n\n\n## Tool usage\n\nInstall tool:\n\n    $ go install github.com/aymerick/douceur\n\nParse a CSS file and display result:\n\n    $ douceur parse inputfile.css\n\nInline CSS in an HTML document and display result:\n\n    $ douceur inline inputfile.html\n\n\n## Library usage\n\nFetch package:\n\n    $ go get github.com/aymerick/douceur\n\n\n### Parse CSS\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/aymerick/douceur/parser\"\n)\n\nfunc main() {\n    input := `body {\n    /* D4rK s1T3 */\n    background-color: black;\n        }\n\n  p     {\n    /* Try to read that ! HAHA! */\n    color: red; /* L O L */\n }\n`\n\n    stylesheet, err := parser.Parse(input)\n    if err != nil {\n        panic(\"Please fill a bug :)\")\n    }\n\n    fmt.Print(stylesheet.String())\n}\n```\n\nDisplays:\n\n```css\nbody {\n  background-color: black;\n}\np {\n  color: red;\n}\n```\n\n\n### Inline HTML\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/aymerick/douceur/inliner\"\n)\n\nfunc main() {\n    input := `\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"\u003e\n\u003chtml xmlns=\"http://www.w3.org/1999/xhtml\"\u003e\n  \u003chead\u003e\n\u003cmeta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/\u003e\n\u003cstyle type=\"text/css\"\u003e\n  p {\n    font-family: 'Helvetica Neue', Verdana, sans-serif;\n    color: #eee;\n  }\n\u003c/style\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cp\u003e\n      Inline me please!\n    \u003c/p\u003e\n\u003c/body\u003e\n\u003c/html\u003e`\n\n    html, err := inliner.Inline(input)\n    if err != nil {\n        panic(\"Please fill a bug :)\")\n    }\n\n    fmt.Print(html)\n}\n```\n\nDisplays:\n\n```css\n\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"\u003e\u003chtml xmlns=\"http://www.w3.org/1999/xhtml\"\u003e\u003chead\u003e\n\u003cmeta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/\u003e\n\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cp style=\"color: #eee; font-family: \u0026#39;Helvetica Neue\u0026#39;, Verdana, sans-serif;\"\u003e\n      Inline me please!\n    \u003c/p\u003e\n\n\u003c/body\u003e\u003c/html\u003e\n```\n\n## Test\n\n    go test ./... -v\n\n\n## Dependencies\n\n  - Parser uses [Gorilla CSS3 tokenizer](https://github.com/gorilla/css).\n  - Inliner uses [goquery](github.com/PuerkitoBio/goquery) to manipulate HTML.\n\n\n## Similar projects\n\n  - [premailer](https://github.com/premailer/premailer)\n  - [roadie](https://github.com/Mange/roadie)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faymerick%2Fdouceur","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faymerick%2Fdouceur","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faymerick%2Fdouceur/lists"}