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

micromark

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micromark - npm Package Compare versions

Comparing version 2.6.0 to 2.6.1

66

dist/util/normalize-uri.js
module.exports = normalizeUri
function normalizeUri(url) {
return encodeURI(decodeURI(url))
var asciiAlphanumeric = require('../character/ascii-alphanumeric')
var fromCharCode = require('../constant/from-char-code')
// Encode unsafe characters with percent-encoding, skipping already
// encoded sequences.
function normalizeUri(value) {
var length = value.length
var index = -1
var result = []
var start = 0
var skip = 0
var code
var next
var replace
while (++index < length) {
code = value.charCodeAt(index)
// A correct percent encoded value.
if (
code === 37 &&
asciiAlphanumeric(value.charCodeAt(index + 1)) &&
asciiAlphanumeric(value.charCodeAt(index + 2))
) {
skip = 2
}
// ASCII.
else if (code < 128) {
if (!/[!#$&-;=?-Z_a-z~]/.test(fromCharCode(code))) {
replace = fromCharCode(code)
}
}
// Astral.
else if (code > 55295 && code < 57344) {
next = value.charCodeAt(index + 1)
// A correct surrogate pair.
if (code > 55295 && code < 56320 && next > 56319 && next < 57344) {
replace = fromCharCode(code, next)
skip = 1
}
// Lone surrogate.
else {
replace = fromCharCode(65533)
}
}
// Unicode.
else {
replace = fromCharCode(code)
}
if (replace) {
result.push(value.slice(start, index), encodeURIComponent(replace))
start = index + skip + 1
replace = undefined
}
if (skip) {
index += skip
skip = 0
}
}
return result.join('') + value.slice(start)
}
module.exports = normalizeUri
function normalizeUri(url) {
return encodeURI(decodeURI(url))
var codes = require('../character/codes')
var asciiAlphanumeric = require('../character/ascii-alphanumeric')
var fromCharCode = require('../constant/from-char-code')
// Encode unsafe characters with percent-encoding, skipping already
// encoded sequences.
function normalizeUri(value) {
var length = value.length
var index = -1
var result = []
var start = 0
var skip = 0
var code
var next
var replace
while (++index < length) {
code = value.charCodeAt(index)
// A correct percent encoded value.
if (
code === codes.percentSign &&
asciiAlphanumeric(value.charCodeAt(index + 1)) &&
asciiAlphanumeric(value.charCodeAt(index + 2))
) {
skip = 2
}
// ASCII.
else if (code < 128) {
if (!/[!#$&-;=?-Z_a-z~]/.test(fromCharCode(code))) {
replace = fromCharCode(code)
}
}
// Astral.
else if (code > 55295 && code < 57344) {
next = value.charCodeAt(index + 1)
// A correct surrogate pair.
if (code > 55295 && code < 56320 && next > 56319 && next < 57344) {
replace = fromCharCode(code, next)
skip = 1
}
// Lone surrogate.
else {
replace = fromCharCode(codes.replacementCharacter)
}
}
// Unicode.
else {
replace = fromCharCode(code)
}
if (replace) {
result.push(value.slice(start, index), encodeURIComponent(replace))
start = index + skip + 1
replace = undefined
}
if (skip) {
index += skip
skip = 0
}
}
return result.join('') + value.slice(start)
}

2

package.json
{
"name": "micromark",
"version": "2.6.0",
"version": "2.6.1",
"description": "small commonmark compliant markdown parser with positional info and concrete tokens",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -40,3 +40,6 @@ <h1 align="center">

* [`createSteam(options?)`](#createsteamoptions)
* [List of extensions](#list-of-extensions)
* [Extensions](#extensions)
* [`SyntaxExtension`](#syntaxextension)
* [`HtmlExtension`](#htmlextension)
* [List of extensions](#list-of-extensions)
* [Version](#version)

@@ -57,3 +60,3 @@ * [Security](#security)

[`mdast-util-to-markdown`][to-markdown])
* [ ] [Extensions][]: GFM, directives, MDX
* [ ] [Extensions][]: [GFM][], directives, MDX
* [ ] Integrate into remark

@@ -144,7 +147,9 @@ * [ ] Complementary docs on state machine ([CMSM][]) for parsers in other

Array of syntax extensions (`Array.<SyntaxExtension>`, default: `[]`).
Array of syntax extensions ([`Array.<SyntaxExtension>`][syntax-extension],
default: `[]`).
###### `options.htmlExtensions`
Array of HTML extensions (`Array.<HtmlExtension>`, default: `[]`).
Array of HTML extensions ([`Array.<HtmlExtension>`][html-extension], default:
`[]`).

@@ -162,6 +167,37 @@ ##### Returns

## List of extensions
## Extensions
There are two types of extensions for micromark:
[`SyntaxExtension`][syntax-extension] and [`HtmlExtension`][html-extension].
They can be passed in [`extensions`][option-extensions] or
[`htmlExtensions`][option-htmlextensions], respectively.
### `SyntaxExtension`
A syntax extension is an object whose fields are the names of tokenizers:
`content` (a block of, well, content: definitions and paragraphs), `document`
(containers such as block quotes and lists), `flow` (block constructs such as
ATX and setext headings, HTML, indented and fenced code, thematic breaks),
`string` (things that work in a few places such as destinations, fenced code
info, etc: character escapes and -references), or `text` (rich inline text:
autolinks, character escapes and -references, code, hard breaks, HTML, images,
links, emphasis, strong).
The values at such objects are character codes, mapping to constructs.
The built in [constructs][] are an extension.
See it and the [existing extensions][extensions] for inspiration.
### `HtmlExtension`
An HTML extension is an object whose fields are either `enter` or `exit`
(reflecting whether a token is entered or exited).
The values at such objects are names of tokens mapping to handlers.
See the [existing extensions][extensions] for inspiration.
### List of extensions
* [`micromark/micromark-extension-frontmatter`](https://github.com/micromark/micromark-extension-frontmatter)
— support frontmatter (YAML, TOML, etc)
* [`micromark/micromark-extension-gfm`](https://github.com/micromark/micromark-extension-gfm)
— support GFM (GitHub Flavored Markdown)
* [`micromark/micromark-extension-gfm-autolink-literal`](https://github.com/micromark/micromark-extension-gfm-autolink-literal)

@@ -171,4 +207,8 @@ — support GFM autolink literals

— support GFM strikethrough
* [`micromark/micromark-extension-gfm-table`](https://github.com/micromark/micromark-extension-gfm-table)
— support GFM tables
* [`micromark/micromark-extension-gfm-tagfilter`](https://github.com/micromark/micromark-extension-gfm-tagfilter)
— support GFM tagfilter
* [`micromark/micromark-extension-gfm-task-list-item`](https://github.com/micromark/micromark-extension-gfm-task-list-item)
— support GFM tasklists

@@ -340,2 +380,14 @@ ## Version

[gfm]: https://github.com/micromark/micromark-extension-gfm
[constructs]: lib/constructs.js
[extensions]: #list-of-extensions
[syntax-extension]: #syntaxextension
[html-extension]: #htmlextension
[option-extensions]: #optionsextensions
[option-htmlextensions]: #optionshtmlextensions
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