@nakobase/nakobase-md-html 2.1.0 → 2.2.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAqB1C,eAAO,MAAM,QAAQ,GACnB,UAAU,MAAM,EAChB,UAAU,eAAe,KACxB,MAmCF,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAsB1C,eAAO,MAAM,QAAQ,GACnB,UAAU,MAAM,EAChB,UAAU,eAAe,KACxB,MAyCF,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -18,10 +18,12 @@ const MdItImSize = require('@steelydylan/markdown-it-imsize').default;
18
18
  const MdItInlineComments = require('markdown-it-inline-comments');
19
19
  const MdItContainer = require('markdown-it-container');
20
20
  const MdItTaskLists = require('markdown-it-task-lists');
21
+ const MdItAnchor = require('markdown-it-anchor').default;
21
22
  const mdToHtml = (markdown, options) => {
22
23
  const {
23
24
  codeHighlight,
24
- rich
25
+ rich,
26
+ anchor
25
27
  } = options || {};
26
28
  if (!(markdown && markdown.length)) return '';
27
29
  const md = (0, _markdownIt.default)({
@@ -37,6 +39,11 @@ const mdToHtml = (markdown, options) => {
37
39
  md.use(MdItInlineComments).use(MdItImSize).use(MdItTaskLists, {
38
40
  enabled: true
39
41
  });
42
+ if (anchor) {
43
+ md.use(MdItAnchor, {
44
+ level: [1, 2, 3, 4, 5, 6]
45
+ });
46
+ }
40
47
  if (rich) {
41
48
  md.use(MdItContainer, _constants.CONTAINER_TYPES.DETAILS, _mdContainer.detailsOptions).use(MdItContainer, _constants.CONTAINER_TYPES.BOX, _mdContainer.boxOptions).use(MdItContainer, _constants.CONTAINER_TYPES.BUBBLE, _mdContainer.bubbleOptions).use(MdItContainer, _constants.CONTAINER_TYPES.BUBBLE_IMAGE, _mdContainer.bubbleImageOptions).use(MdItContainer, _constants.CONTAINER_TYPES.HEADING, _mdContainer.headingOptions).use(_mdCustomBlocks.mdCustomBlocks).use(_mdCustomInlines.mdCustomInlines);
42
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../../src/sanitizer.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,MAuBpC,CAAC"}
1
+ {"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../../src/sanitizer.ts"],"names":[],"mappings":"AAsCA,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,MAuBpC,CAAC"}
@@ -21,7 +21,13 @@ const extendedAttributes = {
21
21
  div: ['class'],
22
22
  pre: ['class'],
23
23
  code: [...(_sanitizeHtml.defaults.allowedAttributes.code || []), 'class'],
24
- span: ['class']
24
+ span: ['class'],
25
+ h1: ['id'],
26
+ h2: ['id'],
27
+ h3: ['id'],
28
+ h4: ['id'],
29
+ h5: ['id'],
30
+ h6: ['id']
25
31
  };
26
32
  const sanitize = html => (0, _sanitizeHtml.default)(html, {
27
33
  allowedTags: [..._sanitizeHtml.defaults.allowedTags, ...extendedTags],
@@ -1,5 +1,6 @@
1
1
  export interface MdToHtmlOptions {
2
2
  codeHighlight?: boolean;
3
3
  rich?: boolean;
4
+ anchor?: boolean;
4
5
  }
5
6
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakobase/nakobase-md-html",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Convert Markdown to **sanitized HTML** and apply consistent styles – simple, secure, and styled.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -96,6 +96,7 @@
96
96
  "dependencies": {
97
97
  "@steelydylan/markdown-it-imsize": "^1.0.2",
98
98
  "markdown-it": "^12.3.2",
99
+ "markdown-it-anchor": "^9.2.0",
99
100
  "markdown-it-container": "^2.0.0",
100
101
  "markdown-it-custom-block": "^1.0.0",
101
102
  "markdown-it-inline-comments": "^1.0.1",