Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

find-conditional-comments

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-conditional-comments

Finds all conditional comments in a string

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

find-conditional-comments

Finds all conditional comments in a string

codecov npm package Twitter Follow

Install

$ npm install find-conditional-comments

Usage

const findConditionalComments = require('find-conditional-comments');

const html = `
<!--[if mso]>
Hello, Microsoft Outlook!
<![endif]-->
`

findConditionalComments(html);
//=> [ { open: "<!--[if mso]>", close: "<![endif]-->", range: [1, 63], downlevel: "hidden" } ]

API

findConditionalComments(html)

Returns an Array of Objects for each comment with the following properties:

isComment

boolean

Whether the comment is an HTML comment. This might be false for certain items when downlevel is revealed.

open

String

Opening portion of the conditional comment.

close

String

Closing portion of the conditional comment.

bubble

boolean

Whether the comment "bubbles" around the value.

When true, the comment is visible to all platforms except those that support conditional comments.

<!--[if !mso]>-->
Hello, Not Microsoft Outlook!
<!--<![endif]-->

When false, the comment is hidden from all platforms except those that support conditional comments.

<!--[if mso]>
Hello, Microsoft Outlook!
<![endif]-->
downlevel

String

Either hidden or revealed.

hidden means the comment is hidden from all platforms except those that support conditional comments.

revealed means the comment is visible to all platforms except those that support conditional comments.

This is very similar to the bubble property, but it's not the same.

downlevel always be revealed if bubble is true.

But bubble can be true even if downlevel is hidden when using this syntax:

<![if lt IE 8]>
<p>Please upgrade to Internet Explorer version 8.</p>
<![endif]>

Learn more.

range

Array

A range array containing the start and end indices of the comment.

Keywords

FAQs

Package last updated on 28 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc