@difizen/libro-markdown 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/anchor.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ import type { PluginWithOptions } from 'markdown-it';
2
+ import type State from 'markdown-it/lib/rules_core/state_core.js';
3
+ import type Token from 'markdown-it/lib/token.js';
4
+ export type RenderHref = (slug: string, state: State) => string;
5
+ export type RenderAttrs = (slug: string, state: State) => Record<string, string | number>;
6
+ export interface PermalinkOptions {
7
+ class: string;
8
+ symbol: string;
9
+ renderHref: RenderHref;
10
+ renderAttrs: RenderAttrs;
11
+ space: boolean;
12
+ placement: keyof typeof position;
13
+ ariaHidden: boolean;
14
+ }
15
+ export declare function renderHref(slug: string): string;
16
+ export declare function renderAttrs(slug: string): {};
17
+ declare const position: {
18
+ readonly false: "push";
19
+ readonly true: "unshift";
20
+ readonly after: "push";
21
+ readonly before: "unshift";
22
+ };
23
+ export type PermalinkGenerator = (slug: string, opts: Partial<PermalinkOptions>, state: State, index: number) => void;
24
+ export declare const linkInsideHeader: PermalinkGenerator;
25
+ interface AnchorOptions {
26
+ level: number;
27
+ slugify: (val: string) => string;
28
+ getTokensText(tokens: Token[]): string;
29
+ uniqueSlugStartIndex: number;
30
+ tabIndex: string | false;
31
+ permalink: PermalinkGenerator;
32
+ permalinkOptions: Partial<PermalinkOptions>;
33
+ }
34
+ export declare const slugify: (s: string) => string;
35
+ /**
36
+ * fork from markdown-it-anchor
37
+ * @param md
38
+ * @param options
39
+ */
40
+ export declare const libroAnchor: PluginWithOptions<Partial<AnchorOptions>>;
41
+ export {};
42
+ //# sourceMappingURL=anchor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../src/anchor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,KAAK,MA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CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,OAAO,MAAO,MAAM,WACwC,CAAC;AAiD1E;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,OAAO,CAAC,aAAa,CAAC,CAoDjE,CAAC"}
package/es/anchor.js CHANGED
@@ -15,7 +15,7 @@ export function renderHref(slug) {
15
15
  }
16
16
 
17
17
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
18
- export function renderAttrs(_slug) {
18
+ export function renderAttrs(slug) {
19
19
  return {};
20
20
  }
21
21
  var commonDefaults = {
@@ -127,22 +127,22 @@ export var libroAnchor = function libroAnchor(md, options) {
127
127
 
128
128
  // Aggregate the next token children text.
129
129
  var title = opts.getTokensText((_tokens$children = tokens[idx + 1].children) !== null && _tokens$children !== void 0 ? _tokens$children : []);
130
- var _slug2 = token.attrGet('id');
131
- if (_slug2 === null) {
132
- _slug2 = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex);
130
+ var _slug = token.attrGet('id');
131
+ if (_slug === null) {
132
+ _slug = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex);
133
133
  } else {
134
- _slug2 = uniqueSlug(_slug2, slugs, true, opts.uniqueSlugStartIndex);
134
+ _slug = uniqueSlug(_slug, slugs, true, opts.uniqueSlugStartIndex);
135
135
  }
136
136
  if (cellId) {
137
- token.attrSet('id', "".concat(cellId, "-").concat(_slug2));
137
+ token.attrSet('id', "".concat(cellId, "-").concat(_slug));
138
138
  } else {
139
- token.attrSet('id', _slug2);
139
+ token.attrSet('id', _slug);
140
140
  }
141
141
  if (opts.tabIndex !== false) {
142
142
  token.attrSet('tabindex', "".concat(opts.tabIndex));
143
143
  }
144
144
  if (typeof opts.permalink === 'function') {
145
- opts.permalink(_slug2, opts.permalinkOptions, state, idx);
145
+ opts.permalink(_slug, opts.permalinkOptions, state, idx);
146
146
  }
147
147
 
148
148
  // A permalink renderer could modify the `tokens` array so
package/es/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './anchor.js';
2
+ export * from './markdown-protocol.js';
3
+ export * from './markdown-render.js';
4
+ export * from './module.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,18 @@
1
+ export declare const MarkdownParser: unique symbol;
2
+ export interface MarkdownRenderOption {
3
+ cellId?: string;
4
+ }
5
+ /**
6
+ * The interface for a Markdown parser.
7
+ */
8
+ export interface MarkdownParser {
9
+ /**
10
+ * Render a markdown source.
11
+ *
12
+ * @param source - The string to render.
13
+ * @returns - string.
14
+ */
15
+ render(source: string, options?: MarkdownRenderOption): string;
16
+ slugify: (val: string) => string;
17
+ }
18
+ //# sourceMappingURL=markdown-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-protocol.d.ts","sourceRoot":"","sources":["../src/markdown-protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,eAA2B,CAAC;AAEvD,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAAC;IAE/D,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CAClC"}
@@ -0,0 +1,11 @@
1
+ import MarkdownIt from 'markdown-it';
2
+ import type { MarkdownRenderOption } from './markdown-protocol.js';
3
+ import { MarkdownParser } from './markdown-protocol.js';
4
+ export declare class MarkdownRender implements MarkdownParser {
5
+ protected mkt: MarkdownIt;
6
+ slugify: (s: string) => string;
7
+ enablePermalink: boolean;
8
+ init(): void;
9
+ render(markdownText: string, options?: MarkdownRenderOption): string;
10
+ }
11
+ //# sourceMappingURL=markdown-render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-render.d.ts","sourceRoot":"","sources":["../src/markdown-render.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,aAAa,CAAC;AAGrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,qBACa,cAAe,YAAW,cAAc;IACnD,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;IAC1B,OAAO,wBAAW;IAClB,eAAe,UAAS;IAGxB,IAAI;IAaJ,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,MAAM;CAIrE"}
package/es/module.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+ export declare const MarkdownModule: ManaModule;
3
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,eAAO,MAAM,cAAc,YAG1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-markdown",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
package/src/anchor.ts CHANGED
@@ -23,7 +23,7 @@ export function renderHref(slug: string) {
23
23
  }
24
24
 
25
25
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
- export function renderAttrs(_slug: string) {
26
+ export function renderAttrs(slug: string) {
27
27
  return {};
28
28
  }
29
29
 
package/src/index.spec.ts CHANGED
@@ -1,10 +1,10 @@
1
+ import 'reflect-metadata';
1
2
  import assert from 'assert';
2
3
 
3
- import { MarkdownRender } from './index.js';
4
- import 'reflect-metadata';
4
+ import { MarkdownModule } from './index.js';
5
5
 
6
6
  describe('libro-markdown', () => {
7
7
  it('#import', () => {
8
- assert(MarkdownRender);
8
+ assert(MarkdownModule);
9
9
  });
10
10
  });