{"id":22930864,"url":"https://github.com/tai2/decor","last_synced_at":"2026-05-05T23:33:07.694Z","repository":{"id":193050139,"uuid":"688009798","full_name":"tai2/decor","owner":"tai2","description":"decor is a Markdown transformer for single page, which uses a standalone HTML file as a template","archived":false,"fork":false,"pushed_at":"2025-11-20T19:46:24.000Z","size":3172,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-27T06:31:36.135Z","etag":null,"topics":["markdown","markdown-renderer"],"latest_commit_sha":null,"homepage":"https://deno.land/x/decor","language":"TypeScript","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/tai2.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-09-06T13:14:17.000Z","updated_at":"2025-05-12T10:47:08.000Z","dependencies_parsed_at":"2023-10-05T11:36:00.792Z","dependency_job_id":"2c3ad02e-0863-492f-9a94-d2b1a8b6632f","html_url":"https://github.com/tai2/decor","commit_stats":null,"previous_names":["tai2/decor"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/tai2/decor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tai2%2Fdecor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tai2%2Fdecor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tai2%2Fdecor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tai2%2Fdecor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tai2","download_url":"https://codeload.github.com/tai2/decor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tai2%2Fdecor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32672675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["markdown","markdown-renderer"],"created_at":"2024-12-14T10:30:28.240Z","updated_at":"2026-05-05T23:33:07.677Z","avatar_url":"https://github.com/tai2.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# What's decor?\n\n`decor` is a Markdown transformer which takes a Markdown file as content and a\nstandalone HTML file as a template. It is designed for rather oneshot single\npage use than fullset static site generation.\n\n# Installation\n\nIf you have deno in your system, you can install `decor` with the following\ncommand.\n\n```bash\ndeno install --allow-write --allow-read https://deno.land/x/decor/src/decor.ts\n```\n\nIf you are a [Homebrew](https://docs.brew.sh) user, you can install `decor` with\nthe following command.\n\n```\nbrew install tai2/brew/decor\n```\n\nFor other systems, you can download a binary from the\n[releases](https://github.com/tai2/decor/releases).\n\n# How to Use\n\n`decor` takes a pair of template and Markdown files as arguments.\n\n```bash\ndecor --template template.html content.md\n```\n\nThen it generates a rendered HTML to the standard output. The rules for\ntemplates are described in the following sections.\n\n# Options\n\n- `--help` Show help.\n- `--template` Template file. If omitted, the default template is used.\n- `--watch` Run `decor` in watch mode. It detects updates for the template and\n  content then emits the output.\n- `--output` Output filename. When omitted, output is emitted to the standard\n  output.\n- `--show-default-template` Emit the default template. You can use it as a\n  starting point of your own template.\n- `--parameters` Inject parameters from a JSON file\n\n# Template Structure\n\nTemplate is just a normal HTML file and has two responsibilities:\n\n- Define metadata like `\u003ctitle\u003e`, `\u003clink\u003e`, etc placed between `\u003chtml\u003e` and\n  `\u003cbody\u003e`.\n- Define the markup of each supported element inside `\u003cbody\u003e`. Mappings are\n  defined by `data-decor-*` attributes.\n\n## Supported Elements\n\n`decor` supports these Markdown elements. Parameters for each element depends on\nits type. `decor` follows the definitions in\n[the GFM specification](https://github.github.com/gfm/).\n\n| Element                                                     | Parameters                    |\n| ----------------------------------------------------------- | ----------------------------- |\n| `headding1` to `headding6`                                  | `content`                     |\n| `thematic_break`                                            | None                          |\n| `paragraph`                                                 | `content`                     |\n| `code_block`                                                | `content`, `infoString`       |\n| `block_quote`                                               | `content`                     |\n| `table`                                                     | `header`, `body`              |\n| `table_header`                                              | `content`                     |\n| `table_header_cell`                                         | `content`, `align`            |\n| `table_row`                                                 | `content`                     |\n| `table_row_cell`                                            | `content`, `align`            |\n| `ordered_list`                                              | `content`, `start`            |\n| `ordered_list_item`                                         | `content`                     |\n| `unordered_list`                                            | `content`                     |\n| `unordered_list_item`                                       | `content`                     |\n| `link`                                                      | `content`, `title`, `url`     |\n| `image`                                                     | `description`, `title`, `url` |\n| `video` (when video file is referenced with image notation) | `description`, `title`, `url` |\n| `code_span`                                                 | `content`                     |\n| `emphasis`                                                  | `content`                     |\n| `strong_emphasis`                                           | `content`                     |\n| `strikethrough`                                             | `content`                     |\n| `hard_line_break`                                           | None                          |\n\nThese keywards are also used as specifiers for corresponding template elements\nin template files.\n\n## Element Specifiers\n\nHere is a small but complete template example which contains only `headding1`\nand `headding2`. The default definisions are used for all other elements.\n\n`data-decor-element` is an attribute to specify mappings between Markdown\nelements and template elements. For each occurence of Markdown element in input,\n`decor` tries to look up the first element that has the corresponding element\nspecifier from the template file during conversion.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /\u003e\n    \u003clink href=\"/dist/output.css\" rel=\"stylesheet\" /\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1 data-decor-element=\"headding1\" class=\"text-3xl font-bold underline\"\u003e\n      Primary Headding\n    \u003c/h1\u003e\n    \u003ch2 data-decor-element=\"headding2\" class=\"text-2xl font-bold underline\"\u003e\n      Secondary Headding\n    \u003c/h2\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nYou can feed any markdown text like this to `decor`.\n\n```markdown\n# Markdown\n\nMarkdown is a lightweight markup language for creating formatted text using a\nplain-text editor.\n\n## History\n\nMarkdown was inspired by pre-existing conventions for marking up plain text in\nemail and usenet posts, such as the earlier markup languages setext (c. 1992),\nTextile (c. 2002), and reStructuredText (c. 2002).\n\n## Rise and divergence\n\nAs Markdown's popularity grew rapidly, many Markdown implementations appeared,\ndriven mostly by the need for additional features such as tables, footnotes,\ndefinition lists,[note 1] and Markdown inside HTML blocks.\n```\n\n`decor` replaces the body of the template with HTML fragment rendered from the\nmarkdown text. At last, the content and template turn into this output HTML.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /\u003e\n    \u003clink href=\"/dist/output.css\" rel=\"stylesheet\" /\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1 class=\"text-3xl font-bold underline\"\u003eMarkdown\u003c/h1\u003e\n    \u003cp\u003e\n      Markdown is a lightweight markup language for creating formatted text\n      using a plain-text editor.\n    \u003c/p\u003e\n    \u003ch2 class=\"text-2xl font-bold underline\"\u003eHistory\u003c/h2\u003e\n    \u003cp\u003e\n      Markdown was inspired by pre-existing conventions for marking up plain\n      text in email and usenet posts, such as the earlier markup languages\n      setext (c. 1992), Textile (c. 2002), and reStructuredText (c. 2002).\n    \u003c/p\u003e\n    \u003ch2 class=\"text-2xl font-bold underline\"\u003eRise and divergence\u003c/h2\u003e\n    \u003cp\u003e\n      As Markdown's popularity grew rapidly, many Markdown implementations\n      appeared, driven mostly by the need for additional features such as\n      tables, footnotes, definition lists,[note 1] and Markdown inside HTML\n      blocks.\n    \u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Content and Attribute Specifiers\n\nHere is a part of an example template for image notation.\n\n```html\n\u003cimg\n  data-decor-element=\"image\"\n  class=\"Image\"\n  src=\"image.jpg\"\n  alt=\"An example image\"\n  title=\"The title of the image\"\n/\u003e\n```\n\nNote that you don't need to use a \"standard\" element, which is `\u003cimg\u003e` in the\ncase of image, for rendering. You can even render nested elements to render a\nmarkdown element.\n\n```html\n\u003cfigure data-decor-element=\"image\" class=\"Figure\"\u003e\n  \u003cimg\n    data-decor-attribute-src=\"url\"\n    data-decor-attribute-alt=\"description\"\n    class=\"Figure-image\"\n    src=\"image.jpg\"\n    alt=\"An example image\"\n  /\u003e\n  \u003cfigcaption data-decor-content=\"title\" class=\"Figure-caption\"\u003e\n    The caption of the image\n  \u003c/figcaption\u003e\n\u003c/figure\u003e\n```\n\nYou can use `data-decor-attribute-[ATTRIBUTE_NAME]` inside an element to specify\na element and attribute an input parameter is mapped to. The last segment\nrepresents distination attribute name and the value of the attribute represents\nthe source parameter.\n\nAlso, `data-decor-content` is a specifier to map a parameter to the content of a\nelement. The content of the element is replaced with the parameter.\n\nIf these attributes are not specified, `decor` suposes the default mappings are\napplied to the root element. It depends on element type. For example, the\ndefault mappings of the `paragraph`and `image` elements look like these.\n\n```html\n\u003cp data-decor-content=\"content\"\u003e\u003c/p\u003e\n```\n\n```html\n\u003cimg\n  data-decor-attribute-src=\"url\"\n  data-decor-attribute-alt=\"description\"\n  data-decor-attribute-title=\"title\"\n/\u003e\n```\n\n## Parameter Replacement\n\nWith content and attribute specifiers, you can reference a special key name\nstarting with `param:`. When it is specified, decor tries to resolve the name\nwith a value from a JSON file specified with `--paramaters`. The JSON parameters\nare simple key value pairs like this.\n\n```json\n{\n  \"title\": \"This is a page title\",\n  \"spellcheck\": \"true\"\n}\n```\n\nParameter replacement happenes before normal conversion steps. The content of\nthe `title` element and `spellcheck` attributes of heading elements will be\nreplaced with the values in a JSON file in the example below\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /\u003e\n    \u003clink href=\"/dist/output.css\" rel=\"stylesheet\" /\u003e\n    \u003ctitle data-decor-content=\"param:title\"\u003ePage title\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\n      data-decor-element=\"headding1\"\n      class=\"text-3xl font-bold underline\"\n      data-decor-attribute-spellcheck=\"param:spellcheck\"\n    \u003e\n      Primary Headding\n    \u003c/h1\u003e\n    \u003ch2\n      data-decor-element=\"headding2\"\n      class=\"text-2xl font-bold underline\"\n      data-decor-attribute-spellcheck=\"param:spellcheck\"\n    \u003e\n      Secondary Headding\n    \u003c/h2\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n# Reviewing Template\n\nSince template is just a plain HTML, you can write and review it whatever ways\nyou want. When input is omitted, the default content included in `decor` is\nused. It's useful when you want to review your stylesheets during template\ndevelopment.\n\n# Reference\n\n- https://daringfireball.net/projects/markdown/syntax\n- https://github.github.com/gfm/\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftai2%2Fdecor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftai2%2Fdecor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftai2%2Fdecor/lists"}