@podlite/schema 0.0.17 → 0.0.18

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,8 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.cleanLocalHrefs = exports.frozenIds = exports.slugifyText = exports.cleanIds = void 0;
4
7
  const __1 = require("..");
5
8
  const nanoid_1 = require("nanoid");
9
+ const slugify_1 = __importDefault(require("slugify"));
6
10
  /**
7
11
  * Clean ids from tree
8
12
  * @returns
@@ -25,12 +29,7 @@ const cleanIds = (src = { skipChain: 0, podMode: 1 }) => tree => {
25
29
  exports.cleanIds = cleanIds;
26
30
  // TODO: refactor linking for blocks
27
31
  const slugifyText = (text) => {
28
- // https://github.com/microsoft/vscode/blob/master/extensions/markdown-language-features/src/slugify.ts
29
- return text.trim()
30
- // .toLowerCase()
31
- .replace(/\s+/g, '-')
32
- .replace(/[\]\[\!\/\'\"\#\$\%\&\(\)\*\+\,\.\/\:\;\<\=\>\?\@\\\^\{\|\}\~\`。,、;:?!…—·ˉ¨‘’“”々~‖∶"'`|〃〔〕〈〉《》「」『』.〖〗【】()[]{}]/g, '')
33
- .replace(/^\-+/, '');
32
+ return (0, slugify_1.default)(text.trim(), {});
34
33
  };
35
34
  exports.slugifyText = slugifyText;
36
35
  /**
@@ -51,25 +51,29 @@ const middle = () => tree => {
51
51
  const isDataBlock = 'name' in n && n.name === 'data';
52
52
  const isMarkdownBlock = 'name' in n && n.name === 'markdown';
53
53
  const isPictureBlock = 'name' in n && n.name === 'picture';
54
- const allowValues = conf.getAllValues('allow');
54
+ const allowValues = [...conf.getAllValues('allow'), ...(isCodeBlock ? ['NONE'] : [])];
55
+ if ((0, makeTransformer_2.isNamedBlock)(n.name))
56
+ return n;
55
57
  // for code block not parse content by default
56
58
  if ((isCodeBlock || isDataBlock || isMarkdownBlock || isPictureBlock) && allowValues.length == 0)
57
59
  return n;
58
60
  const allowed = allowValues.sort();
59
61
  const transformer = (0, makeTransformer_1.default)({
60
62
  ':verbatim': (n, ctx) => {
63
+ // special case for code block, 'NONE' - flag disabled all markup codes
64
+ // do not parse content by default
65
+ if (allowed.length == 1 && allowed.includes('NONE'))
66
+ return n;
61
67
  return fcparser.parse(n.value, { allowed });
62
68
  },
63
69
  ':text': (n, ctx) => {
64
70
  return fcparser.parse(n.value, { allowed });
65
71
  },
66
72
  ':block': (n, ctx) => {
67
- if ((0, makeTransformer_2.isNamedBlock)(n.name))
68
- return n;
69
- return { ...n, content: transformer(n.content, { ...ctx }) };
73
+ return transformerBlocks(n, { ...ctx });
70
74
  },
71
75
  });
72
- return transformer(n, { ...ctx });
76
+ return { ...n, content: transformer(n.content, { ...ctx }) };
73
77
  },
74
78
  });
75
79
  return transformerBlocks(tree, {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podlite/schema",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "AST tools for Podlite markup language",
5
5
  "main": "lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -43,7 +43,8 @@
43
43
  "ajv": "^7.2.3",
44
44
  "events": "^3.1.0",
45
45
  "json-pointer": "^0.6.1",
46
- "nanoid": "3.1.30"
46
+ "nanoid": "3.1.30",
47
+ "slugify": "^1.6.6"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@types/node": "^17.0.7",