npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mso-conditional-parser

v2.0.1

Published

Parser and translator for MSO (Outlook) conditional comments in HTML email

Readme

mso-conditional-parser

Parser and translator for MSO (Outlook) conditional comments in HTML email.

Parses all real-world MSO comment patterns, validates conditions against known Outlook versions and operators, and translates them into human-readable English.

Used as the core engine by eslint-plugin-mso-email and the MSO Conditional Comments VS Code extension.

Installation

npm install mso-conditional-parser

Requires Node.js 18+. ES module only ("type": "module").

API

parseMsoComment(str)

Parses an MSO conditional comment opener.

Returns a result object or null if the input is not a recognised MSO opener.

import { parseMsoComment } from 'mso-conditional-parser';

parseMsoComment('<!--[if gte mso 16]>');
// {
//   type: 'downlevel-hidden',
//   condition: 'gte mso 16',
//   translation: 'Outlook 2016, 2019, and 365 and newer',
//   isValid: true
// }

parseMsoComment('<!--[if mos]>');
// {
//   type: 'downlevel-hidden',
//   condition: 'mos',
//   translation: 'mos',
//   isValid: false,
//   error: "Use the keyword 'mso', not 'mos'",
//   conditionFix: 'mso'
// }

Supported opener patterns:

| Pattern | Type | |---|---| | <!--[if mso]> | downlevel-hidden | | <!--[if gte mso 16]> | downlevel-hidden | | <!--[if !mso]><!-- | downlevel-revealed | | <![if !mso]> | downlevel-revealed (non-standard) |

Result shape:

| Field | Type | Description | |---|---|---| | type | string | 'downlevel-hidden' or 'downlevel-revealed' | | condition | string | Raw condition string extracted from the comment | | translation | string | Human-readable English translation | | isValid | boolean | true if the condition is syntactically valid | | error | string | Present when isValid is false | | conditionFix | string | Optional replacement condition when a safe autofix exists |


validateCondition(condition)

Returns an error message for an invalid condition string, or null when valid.

import { validateCondition } from 'mso-conditional-parser';

validateCondition('mos'); // "Use the keyword 'mso', not 'mos'"
validateCondition('gte mso 16'); // null

getConditionFix(condition)

Returns a replacement condition string when a deterministic fix exists (for example mosmso), or null otherwise.

import { getConditionFix } from 'mso-conditional-parser';

getConditionFix('mos'); // 'mso'
getConditionFix('gte mso 16'); // null

parseMsoEndComment(str)

Parses an MSO conditional comment closer.

Returns { type, isClosing: true } or null if not recognised.

import { parseMsoEndComment } from 'mso-conditional-parser';

parseMsoEndComment('<![endif]-->');
// { type: 'downlevel-hidden-end', isClosing: true }

parseMsoEndComment('<![endif]>');
// { type: 'downlevel-revealed-end', isClosing: true }

translateCondition(condition)

Translates a raw condition string into English without full parsing.

import { translateCondition } from 'mso-conditional-parser';

translateCondition('gte mso 16');  // 'Outlook 2016, 2019, and 365 and newer'
translateCondition('!mso');        // 'non-Outlook email clients'
translateCondition('mso 12');      // 'Outlook 2007'

isMsoComment(str)

Returns true if the string is any MSO comment — opener or closer.

import { isMsoComment } from 'mso-conditional-parser';

isMsoComment('<!--[if mso]>');   // true
isMsoComment('<![endif]-->');    // true
isMsoComment('<p>hello</p>');    // false

Supported conditions

| Syntax | Example | Meaning | |---|---|---| | mso | <!--[if mso]> | Any Outlook version | | !mso | <!--[if !mso]><!-- | Non-Outlook clients | | mso <version> | <!--[if mso 16]> | Exact Outlook version | | <op> mso <version> | <!--[if gte mso 14]> | Version comparison | | !mso <version> | <!--[if !mso 16]> | Not this version | | IE / !IE | <!--[if IE]> | Legacy Internet Explorer conditions | | <op> IE <version> | <!--[if gte IE 8]> | IE version comparison | | Compound & / \| | <!--[if (gt mso 9)&(lte mso 11)]> | AND / OR |

Valid operators: gte, gt, lte, lt, eq

Valid Outlook versions: 9 (2000), 10 (2002), 11 (2003), 12 (2007), 14 (2010), 15 (2013), 16 (2016/2019/365)

Note: there is no MSO version 13 — Outlook skips from 12 (2007) to 14 (2010).

License

MIT