@diplodoc/transform 4.15.0 → 4.16.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.
@@ -116,7 +116,8 @@ function liquid<
116
116
  }
117
117
 
118
118
  if (conditions) {
119
- output = applyConditions(output, vars, path, {sourceMap});
119
+ const strict = conditions === 'strict';
120
+ output = applyConditions(output, vars, path, {sourceMap, strict});
120
121
  }
121
122
 
122
123
  if (substitutions) {
@@ -1,5 +1,5 @@
1
1
  export type ArgvSettings = {
2
- conditions?: boolean;
2
+ conditions?: boolean | 'strict';
3
3
  conditionsInCode?: boolean;
4
4
  cycles?: boolean;
5
5
  substitutions?: boolean;
@@ -13,12 +13,6 @@ export function prepareSourceMap(sourceMap: object) {
13
13
  return newToOldMap;
14
14
  }
15
15
 
16
- type Options = {
17
- firstLineNumber: number;
18
- lastLineNumber: number;
19
- sourceMap: Record<number, number>;
20
- };
21
-
22
16
  type MoveLinesOptions = {
23
17
  start: number;
24
18
  end: number;
@@ -26,8 +20,9 @@ type MoveLinesOptions = {
26
20
  withReplace?: boolean;
27
21
  };
28
22
 
29
- export function createSourceMapApi({firstLineNumber, lastLineNumber, sourceMap}: Options) {
30
- const isInlineTag = firstLineNumber === lastLineNumber;
23
+ export type SourceMapApi = ReturnType<typeof createSourceMapApi>;
24
+
25
+ export function createSourceMapApi(sourceMap: Record<number, number>) {
31
26
  const newToOldIndexes = invert(sourceMap);
32
27
 
33
28
  const getOriginIndex = (i: number) => Number(newToOldIndexes[i]);
@@ -38,10 +33,6 @@ export function createSourceMapApi({firstLineNumber, lastLineNumber, sourceMap}:
38
33
  const getSourceMapValue = (i: number) => sourceMap[getOriginIndex(i)];
39
34
 
40
35
  const moveLines = ({start, end, offset, withReplace = false}: MoveLinesOptions) => {
41
- if (isInlineTag) {
42
- return;
43
- }
44
-
45
36
  for (let i = start; i <= end; i++) {
46
37
  const newLineNumber = i + offset;
47
38
  setSourceMapValue(i, newLineNumber);
@@ -63,7 +54,6 @@ export function createSourceMapApi({firstLineNumber, lastLineNumber, sourceMap}:
63
54
  };
64
55
 
65
56
  return {
66
- isInlineTag,
67
57
  getSourceMapValue,
68
58
  moveLines,
69
59
  removeLines,
@@ -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({