find-conditional-comments

Finds all conditional comments in a string

Usage no npm install needed!

<script type="module">
  import findConditionalComments from 'https://cdn.skypack.dev/find-conditional-comments';
</script>

README

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:

open

String

Opening portion of the conditional comment.

close

String

Closing portion of the conditional comment.

downlevel

String

Either hidden or revealed. Learn more.

range

Array

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

Related