rehype-attr
Advanced tools
Comparing version 2.1.2 to 2.1.3
import { Comment, Literal, ElementContent, RootContent, Properties } from 'hast'; | ||
import { RehypeAttrsOptions } from './'; | ||
export declare const getURLParameters: (url: string) => Record<string, string | number | boolean>; | ||
export declare const getURLParameters: (url?: string) => Record<string, string | number | boolean>; | ||
export declare const prevChild: (data: Literal[] | undefined, index: number) => Comment | undefined; | ||
@@ -5,0 +5,0 @@ export declare const nextChild: (data: RootContent[] | ElementContent[] | undefined, index: number, tagName?: string, codeBlockParames?: boolean) => ElementContent | undefined; |
@@ -1,2 +0,2 @@ | ||
export const getURLParameters = (url) => (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce((a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {}); | ||
export const getURLParameters = (url = '') => (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce((a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {}); | ||
export const prevChild = (data = [], index) => { | ||
@@ -32,4 +32,4 @@ let i = index; | ||
return; | ||
if (/^(comment|raw)$/ig.test(element?.type)) { | ||
if (!/^rehype:/.test(element.value?.replace(/^(\s+)?<!--(.*?)-->/, '$2') || '')) { | ||
if (element.type && /^(comment|raw)$/ig.test(element.type)) { | ||
if (element.value && !/^rehype:/.test(element.value.replace(/^(\s+)?<!--(.*?)-->/, '$2') || '')) { | ||
return; | ||
@@ -36,0 +36,0 @@ } |
{ | ||
"name": "rehype-attr", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "New syntax to add attributes to Markdown.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://jaywcjlove.github.io/rehype-attr", |
import { Element, Comment, Literal, ElementContent, RootContent, Properties } from 'hast'; | ||
import { RehypeAttrsOptions } from './'; | ||
export const getURLParameters = (url: string): Record<string, string | number | boolean> => | ||
(url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce( | ||
(a: Record<string, string | number>, v: string) => ( | ||
(a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a | ||
), | ||
{}, | ||
); | ||
export const getURLParameters = (url: string = '') => | ||
((url.match(/([^?=&]+)(=([^&]*))/g) || []) as string[]).reduce( | ||
(a: Record<string, string | number | boolean>, v: string) => ( | ||
(a[v.slice(0, v.indexOf('=')) as keyof typeof a] = v.slice(v.indexOf('=') + 1)), a | ||
), | ||
{} | ||
) | ||
@@ -38,4 +38,4 @@ export const prevChild = (data: Literal[] = [], index: number): Comment | undefined => { | ||
if (element.type === 'text' && element.value.replace(/(\n|\s)/g, '') !== '') return; | ||
if (/^(comment|raw)$/ig.test(element?.type)) { | ||
if (!/^rehype:/.test(element.value?.replace(/^(\s+)?<!--(.*?)-->/, '$2') || '')) { | ||
if (element.type && /^(comment|raw)$/ig.test(element.type)) { | ||
if (element.value && !/^rehype:/.test(element.value.replace(/^(\s+)?<!--(.*?)-->/, '$2') || '')) { | ||
return | ||
@@ -42,0 +42,0 @@ }; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28245