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

nue-glow

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

nue-glow - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

2

package.json
{
"name": "nue-glow",
"version": "0.1.2",
"version": "0.1.3",

@@ -5,0 +5,0 @@ "description": "Tiny, pixel-perfect Markdown syntax highlighter",

const MIXED_HTML = ['html', 'jsx', 'php', 'astro', 'nue', 'vue', 'svelte', 'hb']

@@ -33,2 +32,5 @@ const LINE_COMMENT = { clojure: ';;', lua: '--', python: '#' }

// line comment
{ tag: 'sup', re: /# .+/ },
{ tag: 'label', re: /\[([a-z\-]+)/g, lang: ['md', 'toml'], shift: true },

@@ -45,3 +47,3 @@

// ALL CAPS (constants)
{ tag: 'b', re: /\b[A-Z]+\b/g },
{ tag: 'b', re: /\b[A-Z]{2,}\b/g },

@@ -152,6 +154,12 @@ // @special

export function parseRow(row, tags) {
const ret = []
export function parseRow(row, lang) {
const tags = isMD(lang) ? getMDTags(row) : getTags(lang)
const tokens = []
// line comment (language specific)
const re = new RegExp(`${LINE_COMMENT[lang] || '//'} .+`)
tags.unshift({ tag: 'sup', re })
for (const el of tags) {

@@ -166,8 +174,15 @@ const { re, shift } = el

const end = start + match.length
ret.push({ start, end, ...el })
tokens.push({ start, end, ...el })
})
}
return ret.sort((a, b) => a.start - b.start)
return tokens.sort((a, b) => a.start - b.start)
}
function renderString(str) {
return encode(str).replace(/\$?\{([^\}]+)\}/g, function(_, content) {
return elem('i', _.replace(content, elem('b', content)))
})
}
// exported for testing purposes

@@ -177,4 +192,3 @@ export function renderRow(row, lang) {

const tags = isMD(lang) ? getMDTags(row) : getTags(lang)
const els = parseRow(row, tags)
const els = parseRow(row, lang)
const ret = []

@@ -195,3 +209,3 @@ var index = 0

const code = row.substring(start, end)
ret.push(elem(el.tag, el.is_string ? encode(code) : code))
ret.push(elem(el.tag, el.is_string ? renderString(code) : code))

@@ -260,12 +274,3 @@ index = end

function findCommentIndex(line, lang) {
if (isMD(lang)) return -1
for (const prefix of [LINE_COMMENT[lang] || '//', '#']) {
const i = line.indexOf(prefix + ' ')
if (i >= 0) return i
}
return -1
}
// code, { language: 'js', numbered: true }

@@ -292,5 +297,3 @@ export function glow(str, opts={}) {

} else {
const i = findCommentIndex(line, lang)
line = i < 0 ? renderRow(line, lang) :
renderRow(line.slice(0, i), lang) + elem('sup', encode(line.slice(i)))
line = renderRow(line, lang)
}

@@ -297,0 +300,0 @@

@@ -8,13 +8,9 @@

const HTML = `
><figure @name="img" :class="class" :id="id">
<figure @name="img" class=•"baz { foo } \${ bar }"•>
<img loading="lazy" :alt="alt" :src="_ || src">
<!--
Inner comment and another
-->
<!-- HTML comment here -->
<p>I finally made it to the public</p>
+ <figcaption :if="caption">{{ caption }}</figcaption>
- <figcaption :if="caption">{{ caption }}</figcaption>
<figcaption :if="caption">{{ caption }}</figcaption>

@@ -205,10 +201,4 @@ <script>

const n = try parseInt(u32, num, 10);
try list.append(n);
try list.append(n); // EOL comment
}
const expected = [_]u32{ 123, 67, 89, 99 };
for (expected, list.items) |exp, actual| {
try std.testing.expectEqual(exp, actual);
}
}

@@ -707,3 +697,3 @@ `

].filter(el => el.lang == 'html')
] // .filter(el => ['html'].includes(el.lang))

@@ -710,0 +700,0 @@ )

Sorry, the diff of this file is not supported yet

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