@diplodoc/transform 4.50.4 → 4.51.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.
@@ -3,13 +3,14 @@ import type {Dictionary} from 'lodash';
3
3
  import {readFileSync, realpathSync, statSync} from 'fs';
4
4
  import escapeRegExp from 'lodash/escapeRegExp';
5
5
  import {join, parse, relative, resolve, sep} from 'path';
6
+ import QuickLRU from 'quick-lru';
6
7
 
7
8
  import liquidSnippet from './liquid';
8
9
  import {StateCore} from './typings';
9
10
  import {defaultTransformLink} from './utils';
10
11
  import {preprocess} from './preprocessors';
11
12
 
12
- const filesCache: Record<string, string> = {};
13
+ const filesCache = new QuickLRU<string, string>({maxSize: 1000});
13
14
 
14
15
  export function isFileExists(file: string) {
15
16
  try {
@@ -62,11 +63,11 @@ export function getFileTokens(
62
63
 
63
64
  // Read the content only if we dont have one in the args
64
65
  if (!content) {
65
- if (filesCache[path]) {
66
- content = filesCache[path];
66
+ if (filesCache.has(path)) {
67
+ content = filesCache.get(path) as string;
67
68
  } else {
68
69
  content = readFileSync(path, 'utf8');
69
- filesCache[path] = content;
70
+ filesCache.set(path, content);
70
71
  }
71
72
  }
72
73
 
@@ -56,7 +56,9 @@ function yfmlint(opts: Options) {
56
56
  lintRules = union(lintRules, customLintRules);
57
57
  }
58
58
 
59
- const plugins = customPlugins && [attrs, ...customPlugins];
59
+ // TODO: set to false in next major
60
+ const {enableMarkdownAttrs = true} = opts;
61
+ const plugins = customPlugins && [...(enableMarkdownAttrs ? [attrs] : []), ...customPlugins];
60
62
  const preparedPlugins = plugins && plugins.map((plugin) => [plugin, pluginOptions]);
61
63
 
62
64
  // Run preprocessor
@@ -16,4 +16,7 @@ export interface Options {
16
16
  lintConfig?: LintConfig;
17
17
  customLintRules?: Rule[];
18
18
  sourceMap?: Dictionary<string>;
19
+ // TODO: set false in next major
20
+ /** @default true */
21
+ enableMarkdownAttrs?: boolean;
19
22
  }