New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

postcss-markdown

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-markdown - npm Package Compare versions

Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2

59

lib/markdown/extract-styles.js
"use strict";
const remarkParse = require("remark-parse");
const unified = require("unified");
const fromMarkdown = require("mdast-util-from-markdown");
const buildSyntaxResolver = require("../syntax/build-syntax-resolver");
const remarkParser = unified().use(remarkParse, {
commonmark: true,
});
function extractStyles(source, opts) {

@@ -16,9 +11,9 @@ const resolveSyntax = buildSyntaxResolver(opts.config);

const ast = remarkParser().parse(source);
const ast = fromMarkdown(source);
const styles = [];
let ignoreState = false;
const ignoreStatus = new Map();
function addStyle(style) {
if (ignoreState) {
function addStyle(style, parent) {
if (ignoreStatus.get(parent)) {
if (style.isMarkdown || /^<style/iu.test(style.content)) {

@@ -31,3 +26,3 @@ return;

function processBlock(block) {
function processBlock(block, parent) {
/** @type {string | null} */

@@ -56,12 +51,15 @@ const lang = block.lang;

}
addStyle({
startIndex,
isMarkdown: true,
content,
lang: lang.toLowerCase(),
syntax,
});
addStyle(
{
startIndex,
isMarkdown: true,
content,
lang: lang.toLowerCase(),
syntax,
},
parent
);
}
function processHtml(node) {
function processHtml(node, parent) {
const syntax = resolveSyntax("html");

@@ -73,9 +71,12 @@ if (!syntax) {

addStyle({
startIndex,
isMarkdown: false,
content: source.slice(startIndex, node.position.end.offset),
lang: "html",
syntax,
});
addStyle(
{
startIndex,
isMarkdown: false,
content: source.slice(startIndex, node.position.end.offset),
lang: "html",
syntax,
},
parent
);
}

@@ -92,3 +93,3 @@

if (commentValue.trim() === "postcss-ignore") {
ignoreState = true;
ignoreStatus.set(parent, true);
return;

@@ -98,3 +99,3 @@ }

if (htmlInMd) {
processHtml(node);
processHtml(node, parent);
}

@@ -104,3 +105,3 @@ }

}
ignoreState = false;
ignoreStatus.delete(parent);
});

@@ -107,0 +108,0 @@

{
"name": "postcss-markdown",
"version": "1.0.0-alpha.1",
"version": "1.0.0-alpha.2",
"publishConfig": {

@@ -57,6 +57,5 @@ "access": "public",

"dependencies": {
"mdast-util-from-markdown": "^0.8.5",
"postcss": "^8.3.9",
"postcss-safe-parser": "^6.0.0",
"remark-parse": "^9.0.0",
"unified": "^9.2.2"
"postcss-safe-parser": "^6.0.0"
},

@@ -83,3 +82,3 @@ "devDependencies": {

"postcss-less": "^5.0.0",
"postcss-scss": "^2.0.0",
"postcss-scss": "^4.0.0",
"postcss-styl": "^0.9.0",

@@ -86,0 +85,0 @@ "prettier": "^2.4.1",

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