@magidoc/plugin-fuse-markdown
Advanced tools
Comparing version 4.1.0 to 4.1.1
import Fuse from 'fuse.js'; | ||
import type { Lexer, Slugger } from 'marked'; | ||
import type { Lexer } from 'marked'; | ||
import type Slugger from 'github-slugger'; | ||
import { type TextExtractors } from '../markdown/extract'; | ||
@@ -4,0 +5,0 @@ import type { MarkdownDocument } from './document'; |
@@ -1,2 +0,3 @@ | ||
import type { marked } from 'marked'; | ||
import type { Tokens, Lexer, TokensList } from 'marked'; | ||
import type Slugger from 'github-slugger'; | ||
/** | ||
@@ -43,12 +44,12 @@ * A markdown header | ||
export type IndexableMarkdownPart = IndexableMarkdownSection | IndexableMarkdownHeader; | ||
export type TextExtractor = (token: marked.Tokens.Generic, extract: ExtractFunction) => string; | ||
export type ExtractFunction = (tokens: marked.Tokens.Generic[]) => string; | ||
export type TextExtractors = Record<marked.Token['type'] | string, TextExtractor>; | ||
export type TextExtractor = (token: Tokens.Generic, extract: ExtractFunction) => string; | ||
export type ExtractFunction = (tokens: Tokens.Generic[]) => string; | ||
export type TextExtractors = Record<string, TextExtractor>; | ||
export type Options = { | ||
slugger: marked.Slugger; | ||
lexer: marked.Lexer; | ||
slugger: Slugger; | ||
lexer: Lexer; | ||
extractors: TextExtractors; | ||
}; | ||
export declare function extract(source: string, options: Options): IndexableMarkdownPart[]; | ||
export declare function extractTokens(tokens: marked.TokensList, options: Options): IndexableMarkdownPart[]; | ||
export declare function extractTokens(tokens: TokensList, options: Options): IndexableMarkdownPart[]; | ||
export declare function extractFunction(extractors: TextExtractors): ExtractFunction; |
@@ -19,7 +19,8 @@ var IndexableMarkdownType; | ||
if (token.type === 'heading') { | ||
const id = options.slugger.slug(token.text); | ||
const headding = token; | ||
const id = options.slugger.slug(headding.text); | ||
const header = { | ||
id: id, | ||
depth: token.depth, | ||
text: token.text, | ||
depth: headding.depth, | ||
text: headding.text, | ||
}; | ||
@@ -52,3 +53,3 @@ const newCurrentSection = { | ||
path: newCurrentSection.headers, | ||
title: token.text, | ||
title: headding.text, | ||
}); | ||
@@ -55,0 +56,0 @@ currentSection = newCurrentSection; |
import type { TextExtractor } from './extract'; | ||
import type { marked } from 'marked'; | ||
export declare function defaultExtractors(): Record<marked.Token['type'], TextExtractor>; | ||
import type { Token } from 'marked'; | ||
export declare function defaultExtractors(): Record<Token['type'], TextExtractor>; |
@@ -1,3 +0,4 @@ | ||
import { marked } from 'marked'; | ||
export declare function defaultSlugger(): marked.Slugger; | ||
export declare function defaultLexer(): marked.Lexer; | ||
import { Lexer } from 'marked'; | ||
import Slugger from 'github-slugger'; | ||
export declare function defaultSlugger(): Slugger; | ||
export declare function defaultLexer(): Lexer; |
@@ -1,8 +0,9 @@ | ||
import { marked } from 'marked'; | ||
import { Lexer } from 'marked'; | ||
import Slugger from 'github-slugger'; | ||
function defaultSlugger() { | ||
return new marked.Slugger(); | ||
return new Slugger(); | ||
} | ||
function defaultLexer() { | ||
return new marked.Lexer(); | ||
return new Lexer(); | ||
} | ||
@@ -9,0 +10,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"private": false, | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"type": "module", | ||
@@ -25,13 +25,14 @@ "license": "MIT", | ||
"fuse.js": "^6.6.2", | ||
"marked": "^5.0.2" | ||
"github-slugger": "^2.0.0", | ||
"marked": "^9.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/marked": "^5.0.0", | ||
"@types/node": "^20.4.5", | ||
"@types/prettier": "^2.7.2", | ||
"@vitest/coverage-c8": "^0.31.1", | ||
"rollup": "^3.22.0", | ||
"typescript": "^5.1.6", | ||
"vite": "^4.4.7", | ||
"vitest": "^0.31.1" | ||
"@types/marked": "^6.0.0", | ||
"@types/node": "^20.8.4", | ||
"@types/prettier": "^3.0.0", | ||
"@vitest/coverage-v8": "^0.34.6", | ||
"rollup": "^4.0.2", | ||
"typescript": "^5.2.2", | ||
"vite": "^4.4.11", | ||
"vitest": "^0.34.6" | ||
}, | ||
@@ -38,0 +39,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
20609
332
4
+ Addedgithub-slugger@^2.0.0
+ Addedgithub-slugger@2.0.0(transitive)
+ Addedmarked@9.1.6(transitive)
- Removedmarked@5.1.2(transitive)
Updatedmarked@^9.1.0