{"id":24983690,"url":"https://github.com/posthtml/posthtml-mso","last_synced_at":"2025-07-09T19:35:14.317Z","repository":{"id":38844464,"uuid":"254433424","full_name":"posthtml/posthtml-mso","owner":"posthtml","description":"Makes writing Outlook conditionals in HTML emails easy.","archived":false,"fork":false,"pushed_at":"2024-10-21T08:52:37.000Z","size":1403,"stargazers_count":21,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T21:06:06.652Z","etag":null,"topics":["conditionals","email-templates","html","html-comments","html-email","mso","outlook","outlook-conditionals","posthtml","posthtml-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/posthtml.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":null,"patreon":"posthtml","open_collective":"posthtml","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://mailviews.com"]}},"created_at":"2020-04-09T17:12:29.000Z","updated_at":"2024-10-21T08:52:40.000Z","dependencies_parsed_at":"2024-03-04T00:35:05.703Z","dependency_job_id":"abcef289-6267-426f-8539-3f994a4751bf","html_url":"https://github.com/posthtml/posthtml-mso","commit_stats":{"total_commits":119,"total_committers":4,"mean_commits":29.75,"dds":"0.46218487394957986","last_synced_commit":"43f95aabbe9ea20d0864e626eee682f29d6c9e8e"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-mso","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-mso/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-mso/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-mso/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/posthtml-mso/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244047646,"owners_count":20389206,"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":["conditionals","email-templates","html","html-comments","html-email","mso","outlook","outlook-conditionals","posthtml","posthtml-plugin"],"created_at":"2025-02-04T09:20:16.870Z","updated_at":"2025-03-17T14:14:17.544Z","avatar_url":"https://github.com/posthtml.png","language":"JavaScript","funding_links":["https://patreon.com/posthtml","https://opencollective.com/posthtml","https://mailviews.com"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"150\" height=\"150\" title=\"PostHTML\" src=\"https://posthtml.github.io/posthtml/logo.svg\"\u003e\n  \u003ch1\u003eOutlook Conditionals\u003c/h1\u003e\n  \u003cp\u003eMakes it easy to write Outlook conditionals in HTML emails\u003c/p\u003e\n\n  [![Version][npm-version-shield]][npm]\n  [![Build][github-ci-shield]][github-ci]\n  [![License][license-shield]][license]\n  [![Downloads][npm-stats-shield]][npm-stats]\n\u003c/div\u003e\n\n## Introduction\n\nWriting Outlook conditionals in HTML emails is gross:\n\n```html\n\u003c!--[if mso]\u003e\n  \u003cdiv\u003eShow this in all Outlook versions\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\nIt gets even worse when you need to target _specific versions_:\n\n```html\n\u003c!--[if (gt mso 11)\u0026(lte mso 15)]\u003e\n  \u003cdiv\u003eShow in 2007, 2010, 2013\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\nThis PostHTML plugin simplifies the way you write Outlook conditional comments:\n\n```xml\n\u003coutlook\u003e\n  \u003cdiv\u003eShow this in all Outlook versions\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nLike, really simple:\n\n```xml\n\u003coutlook gt=\"2003\" lte=\"2013\"\u003e\n  \u003cdiv\u003eShow in 2007, 2010, 2013\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\n## Install\n\n```\nnpm i posthtml-mso\n```\n\n## Usage\n\n```js\nimport posthtml from 'posthtml'\nimport mso from 'posthtml-mso'\n\nconst options = { /* see options below */ }\n\nposthtml([mso(options)])\n  .process('\u003coutlook only=\"2013\"\u003eShow in Outlook 2013\u003c/outlook\u003e')\n  .then(result =\u003e console.log(result.html))\n\n  // \u003c!--[if mso 15]\u003eShow in Outlook 2013\u003c![endif]--\u003e\n```\n\n## Syntax\n\nThe plugin provides two ([customizable](#options)) tags:\n\n1. `\u003coutlook\u003e`\n2. `\u003cnot-outlook\u003e`\n\n### `\u003coutlook\u003e`\n\nThis will output the content inside it, wrapped in an Outlook conditional comment.\n\nThe conditional is created based on the Outlook version(s) you need to target, which you can define inside special attributes ([documented below](#attributes)).\n\nUsing the tag with no attributes will target all Outlook versions:\n\n```xml\n\u003coutlook\u003e\n  \u003cdiv\u003eShow this in all Outlook versions\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if mso]\u003e\n  \u003cdiv\u003eShow this in all Outlook versions\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\n### `\u003cnot-outlook\u003e`\n\nThis tag will basically hide content from all Outlook versions:\n\n```xml\n\u003cnot-outlook\u003e\n  \u003cdiv\u003eAll Outlooks will ignore this\u003c/div\u003e\n\u003c/not-outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if !mso]\u003e\u003c!--\u003e\n  \u003cdiv\u003eAll Outlooks will ignore this\u003c/div\u003e\n\u003c!--\u003c![endif]--\u003e\n```\n\n### Attributes\n\nTo define which Outlook versions you are targeting, you can use one of the following attributes:\n\n- `only` - show only in these Outlook versions\n- `not` - show in all versions _except_ these\n- `lt` - all versions before this (not including it, i.e. _lower than_)\n- `lte` - all versions before this (including it, i.e. _lower than or equal to_)\n- `gt` - all versions after this (not including it, i.e. _greater than_)\n- `gte` - all versions after this (including it, i.e. _greater than or equal to_)\n\n### `only`\n\nShow the content only in this Outlook version:\n\n```xml\n\u003coutlook only=\"2013\"\u003e\n  \u003cdiv\u003eShow only in Outlook 2013\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if mso 15]\u003e\n  \u003cdiv\u003eShow only in Outlook 2013\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\nIt also supports multiple, comma-separated versions:\n\n```xml\n\u003coutlook only=\"2013,2016\"\u003e\n  \u003cdiv\u003eShow only in Outlook 2013 and 2016\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if (mso 15)|(mso 16)]\u003e\n  \u003cdiv\u003eShow only in Outlook 2013 and 2016\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\nNote: targeting Outlook 2016 will also target Outlook 2019 (see [gotchas](#gotchas)).\n\n### `not`\n\nShow content in all Outlook versions except the ones specified.\n\n```xml\n\u003coutlook not=\"2013\"\u003e\n  \u003cdiv\u003eDon't show in Outlook 2013\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if !mso 15]\u003e\n  \u003cdiv\u003eDon't show in Outlook 2013\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\nYou can also specify a comma-separated list of versions:\n\n```xml\n\u003coutlook not=\"2013,2016\"\u003e\n  \u003cdiv\u003eDon't show in Outlook 2013 and 2016\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if !((mso 15)|(mso 16))]\u003e\n  \u003cdiv\u003eDon't show in Outlook 2013 and 2016\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\n### `lt`\n\nShow in all versions before this one, excluding it:\n\n```xml\n\u003coutlook lt=\"2007\"\u003e\n  \u003cdiv\u003eShow in all Outlooks before 2007, excluding it\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if lt mso 12]\u003e\n  \u003cdiv\u003eShow in all Outlooks before 2007, excluding it\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\n### `lte`\n\nShow in all versions before this one, including it:\n\n```xml\n\u003coutlook lte=\"2007\"\u003e\n  \u003cdiv\u003eShow in all Outlooks before 2007, including it\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if lte mso 12]\u003e\n  \u003cdiv\u003eShow in all Outlooks before 2007, including it\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\n### `gt`\n\nShow in all Outlook versions after this one, excluding it:\n\n```xml\n\u003coutlook gt=\"2007\"\u003e\n  \u003cdiv\u003eShow in Outlook 2010, 2013, 2016, 2019\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if gt mso 12]\u003e\n  \u003cdiv\u003eShow in Outlook 2010, 2013, 2016, 2019\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\n### `gte`\n\nShow in all Outlook versions after this one, excluding it:\n\n```xml\n\u003coutlook gte=\"2007\"\u003e\n  \u003cdiv\u003eShow in Outlook 2007, 2010, 2013, 2016, 2019\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if gte mso 12]\u003e\n  \u003cdiv\u003eShow in Outlook 2007, 2010, 2013, 2016, 2019\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\n## Combining Attributes\n\nYou can combine the `lt`, `gt`, `lte`, and `gte` attributes if you need to target multiple versions with higher accuracy.\n\n```xml\n\u003coutlook gt=\"2003\" lte=\"2013\"\u003e\n  \u003cdiv\u003eShow in 2007, 2010, 2013\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nResult:\n\n```html\n\u003c!--[if (gt mso 11)\u0026(lte mso 15)]\u003e\n  \u003cdiv\u003eShow in 2007, 2010, 2013\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\n## Gotchas\n\nThere are some cases that might not work as you'd expect.\n\n### Outlook 2019\n\nOutlook 2019 uses the same version identifier as Outlook 2016 - `16`.\n\nBecause of this, if you target either of them you will be targeting them both. Currently there is no way around this.\n\n### Duplicate Attributes\n\nConsider this example:\n\n```xml\n\u003coutlook gt=\"2003\" lte=\"2013\" gt=\"2007\"\u003e\n  \u003cdiv\u003eShow in 2007, 2010, 2013\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nSince duplicate attributes are discarded when parsing, `gt=\"2007\"` will not be taken into consideration. \n\nThe result will be:\n\n```html\n\u003c!--[if (gt mso 11)\u0026(lte mso 15)]\u003e\n  \u003cdiv\u003eShow in 2007, 2010, 2013\u003c/div\u003e\n\u003c![endif]--\u003e\n```\n\n### Unknown Versions\n\nMade a typo like this?\n\n```xml\n\u003coutlook lt=\"20007\"\u003e\n  \u003cdiv\u003eTarget Outlooks before 2007\u003c/div\u003e\n\u003c/outlook\u003e\n```\n\nIf an unknown Outlook version is specified, the plugin will skip the tag and return its contents:\n\n```html\n\u003cdiv\u003eTarget Outlooks before 2007\u003c/div\u003e\n```\n\nHopefully, we won't need this plugin by then...\n\n## Options\n\n### `tag`\n\nType: `string`\\\nDefault: `outlook`\n\nThe name of the tag you want the plugin to use. Will be used for both available tags.\n\nFor example:\n\n```js\nimport posthtml from 'posthtml'\nimport mso from 'posthtml-mso'\n\nconst html = `\n  \u003cmso only=\"2013\"\u003eShow in Outlook 2013\u003c/mso\u003e\n  \u003cnot-mso\u003eHide from Outlook\u003c/not-mso\u003e\n`\n\nposthtml([mso({ tag: 'mso' })])\n  .process(html)\n  .then(result =\u003e console.log(result.html))\n\n  // \u003c!--[if mso 15]\u003eShow in Outlook 2013\u003c![endif]--\u003e\n  // \u003c!--[if !mso]\u003e\u003c!--\u003eHide from Outlook\u003c!--\u003c![endif]--\u003e\n```\n\n[npm]: https://www.npmjs.com/package/posthtml-mso\n[npm-version-shield]: https://img.shields.io/npm/v/posthtml-mso.svg\n[npm-stats]: http://npm-stat.com/charts.html?package=posthtml-mso\n[npm-stats-shield]: https://img.shields.io/npm/dt/posthtml-mso.svg\n[github-ci]: https://github.com/posthtml/posthtml-mso/actions\n[github-ci-shield]: https://github.com/posthtml/posthtml-mso/actions/workflows/nodejs.yml/badge.svg\n[license]: ./license\n[license-shield]: https://img.shields.io/npm/l/posthtml-mso.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-mso","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fposthtml-mso","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-mso/lists"}