@diplodoc/transform 4.15.0 → 4.16.1

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.
Files changed (43) hide show
  1. package/dist/css/print.css.map +1 -1
  2. package/dist/css/yfm.css.map +1 -1
  3. package/dist/css/yfm.min.css.map +1 -1
  4. package/lib/getObject.d.ts +1 -1
  5. package/lib/getObject.js +10 -7
  6. package/lib/getObject.js.map +1 -1
  7. package/lib/liquid/conditions.d.ts +2 -1
  8. package/lib/liquid/conditions.js +141 -116
  9. package/lib/liquid/conditions.js.map +1 -1
  10. package/lib/liquid/cycles.js +2 -5
  11. package/lib/liquid/cycles.js.map +1 -1
  12. package/lib/liquid/evaluation.d.ts +3 -2
  13. package/lib/liquid/evaluation.js +25 -20
  14. package/lib/liquid/evaluation.js.map +1 -1
  15. package/lib/liquid/index.js +2 -1
  16. package/lib/liquid/index.js.map +1 -1
  17. package/lib/liquid/services/argv.d.ts +1 -1
  18. package/lib/liquid/sourceMap.d.ts +2 -7
  19. package/lib/liquid/sourceMap.js +1 -6
  20. package/lib/liquid/sourceMap.js.map +1 -1
  21. package/lib/md.js +2 -3
  22. package/lib/md.js.map +1 -1
  23. package/lib/plugins/anchors/index.d.ts +1 -1
  24. package/lib/plugins/anchors/index.js +2 -2
  25. package/lib/plugins/anchors/index.js.map +1 -1
  26. package/lib/plugins/links/index.js +1 -1
  27. package/lib/plugins/links/index.js.map +1 -1
  28. package/lib/utils.d.ts +0 -4
  29. package/lib/utils.js +1 -9
  30. package/lib/utils.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/.eslintrc.js +9 -0
  33. package/src/transform/getObject.ts +14 -7
  34. package/src/transform/liquid/conditions.ts +184 -155
  35. package/src/transform/liquid/cycles.ts +2 -5
  36. package/src/transform/liquid/evaluation.ts +44 -25
  37. package/src/transform/liquid/index.ts +2 -1
  38. package/src/transform/liquid/services/argv.ts +1 -1
  39. package/src/transform/liquid/sourceMap.ts +3 -13
  40. package/src/transform/md.ts +2 -3
  41. package/src/transform/plugins/anchors/index.ts +4 -10
  42. package/src/transform/plugins/links/index.ts +2 -1
  43. package/src/transform/utils.ts +0 -16
@@ -1,7 +1,7 @@
1
1
  import {bold} from 'chalk';
2
2
  import GithubSlugger from 'github-slugger';
3
3
 
4
- import {getDefaultPublicPath, headingInfo} from '../../utils';
4
+ import {headingInfo} from '../../utils';
5
5
  import {CUSTOM_ID_EXCEPTION, CUSTOM_ID_REGEXP} from './constants';
6
6
  import StateCore from 'markdown-it/lib/rules_core/state_core';
7
7
  import Token from 'markdown-it/lib/token';
@@ -76,17 +76,11 @@ interface Options {
76
76
  extractTitle?: boolean;
77
77
  supportGithubAnchors?: boolean;
78
78
  transformLink: (v: string) => string;
79
- getPublicPath: (options: Options, v?: string) => string;
79
+ getPublicPath?: (options: Options, v?: string) => string;
80
80
  }
81
81
 
82
82
  const index: MarkdownItPluginCb<Options> = (md, options) => {
83
- const {
84
- extractTitle,
85
- path,
86
- log,
87
- supportGithubAnchors,
88
- getPublicPath = getDefaultPublicPath,
89
- } = options;
83
+ const {extractTitle, path, log, supportGithubAnchors, getPublicPath} = options;
90
84
 
91
85
  const plugin = (state: StateCore) => {
92
86
  /* Do not use the plugin if it is included in the file */
@@ -94,7 +88,7 @@ const index: MarkdownItPluginCb<Options> = (md, options) => {
94
88
  return;
95
89
  }
96
90
 
97
- const href = getPublicPath(options, state.env.path);
91
+ const href = getPublicPath ? getPublicPath(options, state.env.path) : '';
98
92
 
99
93
  const ids: Record<string, number> = {};
100
94
  const tokens = state.tokens;
@@ -184,7 +184,8 @@ function processLink(state: StateCore, tokens: Token[], idx: number, opts: ProcO
184
184
  }
185
185
 
186
186
  let newPathname = '';
187
- if (!isAbsolute(href)) {
187
+
188
+ if (!isAbsolute(href) && !href.includes('//')) {
188
189
  newPathname = getPublicPath(opts, file);
189
190
 
190
191
  href = url.format({
@@ -102,19 +102,3 @@ export function defaultTransformLink(href: string) {
102
102
 
103
103
  return href;
104
104
  }
105
-
106
- export function getDefaultPublicPath(
107
- {
108
- path,
109
- transformLink,
110
- }: {
111
- path?: string;
112
- transformLink?: (href: string) => string;
113
- },
114
- input?: string | null,
115
- ) {
116
- const currentPath = input || path || '';
117
- const transformer = transformLink || defaultTransformLink;
118
- const href = transformer?.(currentPath) ?? currentPath;
119
- return href;
120
- }