podlite 0.0.80 → 0.0.81

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 (54) hide show
  1. package/CHANGELOG.podlite +6 -0
  2. package/esm/lint/grammar/scan.js +3 -0
  3. package/esm/lint/grammar/scan.js.map +1 -1
  4. package/esm/lint/index.d.ts +0 -1
  5. package/esm/lint/index.js +1 -1
  6. package/esm/lint/index.js.map +1 -1
  7. package/esm/lint/rules/index.js +4 -0
  8. package/esm/lint/rules/index.js.map +1 -1
  9. package/esm/lint/rules/link-file-resolves.d.ts +3 -0
  10. package/esm/lint/rules/link-file-resolves.js +58 -0
  11. package/esm/lint/rules/link-file-resolves.js.map +1 -0
  12. package/esm/lint/rules/link-not-empty.d.ts +3 -0
  13. package/esm/lint/rules/link-not-empty.js +15 -0
  14. package/esm/lint/rules/link-not-empty.js.map +1 -0
  15. package/esm/lint/rules/link-target-resolves.js +10 -28
  16. package/esm/lint/rules/link-target-resolves.js.map +1 -1
  17. package/esm/lint/rules/link-targets.d.ts +11 -0
  18. package/esm/lint/rules/link-targets.js +42 -0
  19. package/esm/lint/rules/link-targets.js.map +1 -0
  20. package/esm/lint/rules/unclosed-markup-code.d.ts +4 -0
  21. package/esm/lint/rules/unclosed-markup-code.js +105 -0
  22. package/esm/lint/rules/unclosed-markup-code.js.map +1 -0
  23. package/esm/lint/types.d.ts +1 -0
  24. package/esm/lint/types.js +3 -1
  25. package/esm/lint/types.js.map +1 -1
  26. package/esm/version.d.ts +1 -1
  27. package/esm/version.js +1 -1
  28. package/lib/lint/grammar/scan.js +3 -0
  29. package/lib/lint/grammar/scan.js.map +1 -1
  30. package/lib/lint/index.d.ts +0 -1
  31. package/lib/lint/index.js +3 -3
  32. package/lib/lint/index.js.map +1 -1
  33. package/lib/lint/rules/index.js +4 -0
  34. package/lib/lint/rules/index.js.map +1 -1
  35. package/lib/lint/rules/link-file-resolves.d.ts +3 -0
  36. package/lib/lint/rules/link-file-resolves.js +61 -0
  37. package/lib/lint/rules/link-file-resolves.js.map +1 -0
  38. package/lib/lint/rules/link-not-empty.d.ts +3 -0
  39. package/lib/lint/rules/link-not-empty.js +18 -0
  40. package/lib/lint/rules/link-not-empty.js.map +1 -0
  41. package/lib/lint/rules/link-target-resolves.js +9 -27
  42. package/lib/lint/rules/link-target-resolves.js.map +1 -1
  43. package/lib/lint/rules/link-targets.d.ts +11 -0
  44. package/lib/lint/rules/link-targets.js +47 -0
  45. package/lib/lint/rules/link-targets.js.map +1 -0
  46. package/lib/lint/rules/unclosed-markup-code.d.ts +4 -0
  47. package/lib/lint/rules/unclosed-markup-code.js +109 -0
  48. package/lib/lint/rules/unclosed-markup-code.js.map +1 -0
  49. package/lib/lint/types.d.ts +1 -0
  50. package/lib/lint/types.js +4 -0
  51. package/lib/lint/types.js.map +1 -1
  52. package/lib/version.d.ts +1 -1
  53. package/lib/version.js +1 -1
  54. package/package.json +7 -7
package/CHANGELOG.podlite CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  =head1 Upcoming
4
4
 
5
+ =head1 0.0.81
6
+
7
+ =item podlite lint reports a link whose local file is not there, and a link with no address at all. The file check is a warning, since a document under construction points at files that do not exist yet; the empty link is an error. A target with a scheme other than file, a bare word in a Podlite document, a home-relative path and input read from a pipe are all left alone
8
+
9
+ =item podlite lint adds the unclosed-markup-code rule, which the specification requires of a parser: a markup code terminated by the end of its block rather than by its own bracket is reported, so the line does not go out carrying the opening letter. Closure is counted the way the specification defines it, by matching bracket count or the closing guillemet
10
+
5
11
  =head1 0.0.80
6
12
 
7
13
  =item podlite lint adds the markdown-in-pod rule: a heading written with hashes, a row of bars and dashes, and a pair of asterisks arrive as text inside a pod block, and the message names the Podlite construct to write instead. Blocks that keep their content as written, the separator of a real table, and markup shown inside a code span are left alone
@@ -2,6 +2,7 @@ import { VERBATIM_BLOCKS, isVerbatimBlock } from '@podlite/schema';
2
2
  import { scanTableColumns, tableColumnWidthRule } from '../rules/table-column-width';
3
3
  import { scanAbbreviatedAttrs, abbreviatedAttrsRule } from '../rules/abbreviated-attrs';
4
4
  import { scanMarkdownInPod, markdownInPodRule } from '../rules/markdown-in-pod';
5
+ import { scanUnclosedMarkupCodes, unclosedMarkupCodeRule } from '../rules/unclosed-markup-code';
5
6
  const lintGrammar = require('./lint.js');
6
7
  export const ATTR_NESTED_ANGLE_RULE_ID = 'attr-nested-angle';
7
8
  export const DELIMITED_BLOCK_BALANCE_RULE_ID = 'delimited-block-balance';
@@ -25,6 +26,7 @@ export const SOURCE_RULES = [
25
26
  tableColumnWidthRule,
26
27
  abbreviatedAttrsRule,
27
28
  markdownInPodRule,
29
+ unclosedMarkupCodeRule,
28
30
  ];
29
31
  // The file type decides whether markup of another language is out of place:
30
32
  // in a markdown file markdown is the language, not a stray.
@@ -54,6 +56,7 @@ export function scanSourceRules(content, fileType = 'podlite') {
54
56
  opts.diagnostics.push(...scanAbbreviatedAttrs(content));
55
57
  if (fileType !== 'md')
56
58
  opts.diagnostics.push(...scanMarkdownInPod(content));
59
+ opts.diagnostics.push(...scanUnclosedMarkupCodes(content));
57
60
  return opts.diagnostics;
58
61
  }
59
62
  //# sourceMappingURL=scan.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../src/lint/grammar/scan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAiB,MAAM,iBAAiB,CAAA;AACjF,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AACpF,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE/E,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;AAExC,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAAmB,CAAA;AAC5D,MAAM,CAAC,MAAM,+BAA+B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CAAC"}
@@ -12,7 +12,6 @@ export type LintOptions = {
12
12
  enable?: string[];
13
13
  disable?: string[];
14
14
  };
15
- export declare const STDIN_NAME = "<stdin>";
16
15
  export declare function lintSource(content: string, filePath: string, config: LintConfig): FileReport;
17
16
  export declare function lintFile(filePath: string, config: LintConfig): FileReport;
18
17
  export declare function resolveConfig(files: string[], options: LintOptions): LintConfig;
package/esm/lint/index.js CHANGED
@@ -7,10 +7,10 @@ import { formatText } from './formatters/text';
7
7
  import { formatJson } from './formatters/json';
8
8
  import { scanSourceRules } from './grammar/scan';
9
9
  import { applyConfig, applyRuleFlags, ConfigError, findConfig, readConfig } from './config';
10
+ import { STDIN_NAME } from './types';
10
11
  import { applyMutes } from './mute';
11
12
  export { ConfigError, findConfig, readConfig } from './config';
12
13
  // text handed to the command instead of a path is reported under this name
13
- export const STDIN_NAME = '<stdin>';
14
14
  export function lintSource(content, filePath, config) {
15
15
  const fileType = detectFileType(filePath);
16
16
  const violations = [...applyConfig(scanSourceRules(content, fileType), config)];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lint/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACjE,OAAO,EAAE,UAAU,EAAc,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;A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AAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QAC3C,OAAO,CAAC,CAAA;IACV,CAAC;IAED,MAAM,OAAO,GAAiB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/E,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAA;IACpE,CAAC;IAED,OAAO,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACrC,CAAC"}
@@ -3,6 +3,8 @@ import { headingHierarchyRule } from './heading-hierarchy';
3
3
  import { idUniqueRule } from './id-unique';
4
4
  import { mediaAbsoluteFileRule } from './media-absolute-file';
5
5
  import { linkTargetResolvesRule } from './link-target-resolves';
6
+ import { linkFileResolvesRule } from './link-file-resolves';
7
+ import { linkNotEmptyRule } from './link-not-empty';
6
8
  import { attrValueDroppedRule } from './attr-value-dropped';
7
9
  import { tableShapeRule } from './table-shape';
8
10
  import { deadDefinitionsRule } from './dead-definitions';
@@ -12,6 +14,8 @@ export const DEFAULT_RULES = [
12
14
  idUniqueRule,
13
15
  mediaAbsoluteFileRule,
14
16
  linkTargetResolvesRule,
17
+ linkFileResolvesRule,
18
+ linkNotEmptyRule,
15
19
  attrValueDroppedRule,
16
20
  tableShapeRule,
17
21
  deadDefinitionsRule,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lint/rules/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,eAAe;IACf,oBAAoB;IACpB,YAAY;IACZ,qBAAqB;IACrB,sBAAsB;IACtB,oBAAoB;IACpB,cAAc;IACd,mBAAmB;CACpB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lint/rules/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,eAAe;IACf,oBAAoB;IACpB,YAAY;IACZ,qBAAqB;IACrB,sBAAsB;IACtB,oBAAoB;IACpB,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,mBAAmB;CACpB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Rule } from '../types';
2
+ export declare const LINK_FILE_RESOLVES_RULE_ID = "link-file-resolves";
3
+ export declare const linkFileResolvesRule: Rule;
@@ -0,0 +1,58 @@
1
+ import { existsSync, statSync } from 'fs';
2
+ import { dirname, isAbsolute, resolve } from 'path';
3
+ import { STDIN_NAME } from '../types';
4
+ import { collectLinks, readAddress } from './link-targets';
5
+ export const LINK_FILE_RESOLVES_RULE_ID = 'link-file-resolves';
6
+ // Written with `./` or `../`, the author has declared a path as plainly as a
7
+ // scheme would. A bare word declares nothing in a Podlite document, though in a
8
+ // markdown one it is the ordinary way to write a relative link. A leading slash
9
+ // reads as the root of a site far more often than the root of a disk, so it is
10
+ // left to the author to say `file:` when a disk is what was meant.
11
+ const looksLikePath = (path) => path.startsWith('./') || path.startsWith('../');
12
+ // Relative targets are answered from the directory of the document, so a caller
13
+ // that passed a name rather than a path gets no answer at all: resolving it
14
+ // would silently measure whatever sits in the working directory instead.
15
+ const documentDirectory = (filePath) => {
16
+ if (filePath === STDIN_NAME)
17
+ return null;
18
+ const full = resolve(filePath);
19
+ if (!existsSync(full) || !statSync(full).isFile())
20
+ return null;
21
+ return dirname(full);
22
+ };
23
+ // A home-relative path answers differently on every machine, so a check of it
24
+ // would make the run depend on who is running it.
25
+ const isHomeRelative = (path) => path === '~' || path.startsWith('~/');
26
+ const candidatePath = (target, fileType) => {
27
+ if (!target || target.startsWith('#'))
28
+ return null;
29
+ const { scheme, path } = readAddress(target);
30
+ if (scheme !== null && scheme !== 'file')
31
+ return null;
32
+ if (!path || isHomeRelative(path))
33
+ return null;
34
+ if (scheme === 'file')
35
+ return path;
36
+ if (path.startsWith('/'))
37
+ return null;
38
+ return fileType === 'md' || looksLikePath(path) ? path : null;
39
+ };
40
+ export const linkFileResolvesRule = {
41
+ id: LINK_FILE_RESOLVES_RULE_ID,
42
+ severity: 'warning',
43
+ check: (ast, ctx) => {
44
+ const base = documentDirectory(ctx.filePath);
45
+ if (base === null)
46
+ return [];
47
+ return collectLinks(ast)
48
+ .map(site => ({ site, path: candidatePath(site.target, ctx.fileType) }))
49
+ .filter(({ path }) => path !== null && !existsSync(isAbsolute(path) ? path : resolve(base, path)))
50
+ .map(({ site }) => ({
51
+ rule: LINK_FILE_RESOLVES_RULE_ID,
52
+ severity: 'warning',
53
+ message: `Link target ${site.target} is not there`,
54
+ location: site.at,
55
+ }));
56
+ },
57
+ };
58
+ //# sourceMappingURL=link-file-resolves.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-file-resolves.js","sourceRoot":"","sources":["../../../src/lint/rules/link-file-resolves.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE1D,MAAM,CAAC,MAAM,0BAA0B,GAAG,oBAAoB,CAAA;AAE9D,6EAA6E;AAC7E,gFAAgF;AAChF,gFAAgF;AAChF,+EAA+E;AAC/E,mEAAmE;AACnE,MAAM,aAAa,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAEhG,gFAAgF;AAChF,4EAA4E;AAC5E,yEAAyE;AACzE,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAiB,EAAE;IAC5D,IAAI,QAAQ,KAAK,UAAU;QAAE,OAAO,IAAI,CAAA;IACxC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;QAAE,OAAO,IAAI,CAAA;IAC9D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;AACt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M,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;aACvE,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;aACjG,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YAClB,IAAI,EAAE,0BAA0B;YAChC,QAAQ,EAAE,SAAkB;YAC5B,OAAO,EAAE,eAAe,IAAI,CAAC,MAAM,eAAe;YAClD,QAAQ,EAAE,IAAI,CAAC,EAAE;SAClB,CAAC,CAAC,CAAA;IACP,CAAC;CACF,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Rule } from '../types';
2
+ export declare const LINK_NOT_EMPTY_RULE_ID = "link-not-empty";
3
+ export declare const linkNotEmptyRule: Rule;
@@ -0,0 +1,15 @@
1
+ import { collectLinks } from './link-targets';
2
+ export const LINK_NOT_EMPTY_RULE_ID = 'link-not-empty';
3
+ export const linkNotEmptyRule = {
4
+ id: LINK_NOT_EMPTY_RULE_ID,
5
+ severity: 'error',
6
+ check: (ast, _ctx) => collectLinks(ast)
7
+ .filter(({ target }) => target === '')
8
+ .map(({ at }) => ({
9
+ rule: LINK_NOT_EMPTY_RULE_ID,
10
+ severity: 'error',
11
+ message: 'Link has no address to go to',
12
+ location: at,
13
+ })),
14
+ };
15
+ //# sourceMappingURL=link-not-empty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-not-empty.js","sourceRoot":"","sources":["../../../src/lint/rules/link-not-empty.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAA;AAEtD,MAAM,CAAC,MAAM,gBAAgB,GAAS;IACpC,EAAE,EAAE,sBAAsB;IAC1B,QAAQ,EAAE,OAAO;IACjB,KAAK,EAAE,CAAC,GAAoB,EAAE,IAAiB,EAAe,EAAE,CAC9D,YAAY,CAAC,GAAG,CAAC;SACd,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,EAAE,CAAC;SACrC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAChB,IAAI,EAAE,sBAAsB;QAC5B,QAAQ,EAAE,OAAgB;QAC1B,OAAO,EAAE,8BAA8B;QACvC,QAAQ,EAAE,EAAE;KACb,CAAC,CAAC;CACR,CAAA"}
@@ -1,40 +1,22 @@
1
- import { findAnchor, indexAnchors, toFragment } from '@podlite/schema';
2
- import { collectExplicitIds } from './id-unique';
1
+ import { bindTarget, buildBindingIndex } from '@podlite/schema';
2
+ import { collectLinks } from './link-targets';
3
3
  export const LINK_TARGET_RESOLVES_RULE_ID = 'link-target-resolves';
4
- // A link without display text carries the target in its content instead of meta.
5
- const linkTarget = (node) => {
6
- if (typeof node.meta === 'string')
7
- return node.meta.trim();
8
- const content = Array.isArray(node.content) ? node.content : [];
9
- const first = content[0];
10
- return typeof first === 'string' ? first.trim() : '';
11
- };
12
- // Inline nodes carry no location, so the nearest enclosing block supplies one.
13
- const collectAnchors = (node, at) => {
14
- if (Array.isArray(node))
15
- return node.flatMap(child => collectAnchors(child, at));
16
- if (!node || typeof node !== 'object')
17
- return [];
18
- const n = node;
19
- const here = n.location || at;
20
- const found = n.type === 'fcode' && (n.name === 'L' || n.name === 'W') ? [{ target: linkTarget(n), at: here }] : [];
21
- return [...found, ...collectAnchors(n.content, here)];
22
- };
23
4
  export const linkTargetResolvesRule = {
24
5
  id: LINK_TARGET_RESOLVES_RULE_ID,
25
6
  severity: 'error',
26
7
  check: (ast, _ctx) => {
27
- const anchors = collectAnchors(ast).filter(({ target }) => target.startsWith('#'));
8
+ // A bare # is left alone by the export — it is not a target and not a mistake —
9
+ // so the rule has nothing to say about it either.
10
+ const anchors = collectLinks(ast).filter(({ target }) => target.startsWith('#') && target !== '#');
28
11
  if (anchors.length === 0)
29
12
  return [];
30
13
  // Both ways an anchor can exist: written by the author as :id, or carried by a
31
14
  // heading under its own name. Matched the way the exporter matches them.
32
- const written = new Set(collectExplicitIds(ast).map(entry => toFragment(entry.value)));
33
- const headings = indexAnchors(ast);
34
- const resolves = (target) => {
35
- const name = target.slice(1);
36
- return written.has(toFragment(name)) || findAnchor(name, headings) !== undefined;
37
- };
15
+ // Asked of the same binding the exporters ask, rather than worked out again here.
16
+ // Two answers to one question is how this rule came to call a link sound that the
17
+ // export could not resolve: it shaped both sides itself, and the export did not.
18
+ const index = buildBindingIndex(ast);
19
+ const resolves = (target) => bindTarget(target.slice(1), index).found;
38
20
  return anchors
39
21
  .filter(({ target }) => !resolves(target))
40
22
  .map(({ target, at }) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"link-target-resolves.js","sourceRoot":"","sources":["../../../src/lint/rules/link-target-resolves.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,MAAM,CAAC,MAAM,4BAA4B,GAAG,sBAAsB,CAAA;AASlE,iFAAiF;AACjF,MAAM,UAAU,GAAG,CAAC,IAAc,EAAU,EAAE;IAC5C,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/D,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACxB,OAA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,EAAE,EAAE,4BAA4B;IAChC,QAAQ,EAAE,OAAO;IACjB,KAAK,EAAE,CAAC,GAAoB,EAAE,IAAiB,EAAe,EAAE;QAC9D,gFAAgF;QAChF,kDAAkD;QAClD,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,MAAM,KAAK,GAAG,CAAC,CAAA;QAClG,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAA;QACnC,+EAA+E;QAC/E,yEAAyE;QACzE,kFAAkF;QAClF,kFAAkF;QAClF,iFAAiF;QACjF,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAA;QACpC,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAA;QACtF,OAAO,OAAO;aACX,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;aACzC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YACxB,IAAI,EAAE,4BAA4B;YAClC,QAAQ,EAAE,OAAgB;YAC1B,OAAO,EAAE,eAAe,MAAM,gCAAgC;YAC9D,QAAQ,EAAE,EAAE;SACb,CAAC,CAAC,CAAA;IACP,CAAC;CACF,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { Violation } from '../types';
2
+ export type LinkSite = {
3
+ target: string;
4
+ at?: Violation['location'];
5
+ };
6
+ export declare const collectLinks: (node: unknown, at?: Violation["location"]) => LinkSite[];
7
+ export type LinkAddress = {
8
+ scheme: string | null;
9
+ path: string;
10
+ };
11
+ export declare const readAddress: (target: string) => LinkAddress;
@@ -0,0 +1,42 @@
1
+ // Content is a bare string before the tree is processed and a node after it.
2
+ const textOf = (value) => {
3
+ if (typeof value === 'string')
4
+ return value;
5
+ if (value && typeof value === 'object' && 'value' in value && typeof value.value === 'string')
6
+ return value.value;
7
+ return '';
8
+ };
9
+ // A link without display text carries the target in its content instead of meta.
10
+ const linkTarget = (node) => {
11
+ if (typeof node.meta === 'string')
12
+ return node.meta.trim();
13
+ const content = Array.isArray(node.content) ? node.content : [];
14
+ return textOf(content[0]).trim();
15
+ };
16
+ const isLink = (node) => node.type === 'fcode' && (node.name === 'L' || node.name === 'W');
17
+ // Inline nodes carry no location, so the nearest enclosing block supplies one.
18
+ export const collectLinks = (node, at) => {
19
+ if (Array.isArray(node))
20
+ return node.flatMap(child => collectLinks(child, at));
21
+ if (!node || typeof node !== 'object')
22
+ return [];
23
+ const n = node;
24
+ const here = n.location || at;
25
+ const found = isLink(n) ? [{ target: linkTarget(n), at: here }] : [];
26
+ return [...found, ...collectLinks(n.content, here)];
27
+ };
28
+ const SCHEME = /^([a-zA-Z][a-zA-Z0-9+.-]*):(.*)$/;
29
+ // A single letter before the colon is a Windows drive, but only where something
30
+ // else says Windows: a separator, or a backslash further along. Without one,
31
+ // `a:b` is a scheme and reading it as a path would warn about a target that is
32
+ // not on this disk at all.
33
+ const DRIVE = /^[a-zA-Z]:([\\/]|[^\\]*\\)/;
34
+ // The specification separates the internal address from the external one with a
35
+ // `#`, so what is left of it is the part a filesystem can answer for.
36
+ export const readAddress = (target) => {
37
+ const matched = DRIVE.test(target) ? null : SCHEME.exec(target);
38
+ const scheme = matched ? matched[1].toLowerCase() : null;
39
+ const rest = matched ? matched[2] : target;
40
+ return { scheme, path: rest.split('#')[0].split('?')[0] };
41
+ };
42
+ //# sourceMappingURL=link-targets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-targets.js","sourceRoot":"","sources":["../../../src/lint/rules/link-targets.ts"],"names":[],"mappings":"AAcA,6EAA6E;AAC7E,MAAM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"unclosed-markup-code";
3
+ export declare const unclosedMarkupCodeRule: SourceRule;
4
+ export declare function scanUnclosedMarkupCodes(content: string): Violation[];
@@ -0,0 +1,105 @@
1
+ import { isVerbatimBlock } from '@podlite/schema';
2
+ export const UNCLOSED_MARKUP_CODE_RULE_ID = 'unclosed-markup-code';
3
+ export const unclosedMarkupCodeRule = {
4
+ id: UNCLOSED_MARKUP_CODE_RULE_ID,
5
+ severity: 'warning',
6
+ };
7
+ // The specification leaves the parser no choice: a markup code that ends at the
8
+ // end of its block rather than at its own delimiter is to be reported. The
9
+ // parser instead drops such a code and the text goes out carrying the opening
10
+ // letter, so the whole line reads as written rather than as marked up.
11
+ //
12
+ // Closure is counted the way the specification defines it: a code opened with N
13
+ // angle brackets is closed by N of them together, and one opened with a
14
+ // guillemet by the closing guillemet. Counting rather than asking the parser
15
+ // keeps the doubled forms out of the report — C<< text >> is closed, and the
16
+ // parser drops it for reasons of its own when it sits inside another code.
17
+ //
18
+ // One case stays out of reach: an outer code opened with a single bracket whose
19
+ // inner code closes with its own. The count sees that bracket and calls the
20
+ // outer one closed. Asking the parser instead catches it, but then every single
21
+ // code written inside a doubled one reads as unclosed, and correct markup gets
22
+ // reported — the worse of the two.
23
+ const OPENER = /(^|[^A-Za-z])([A-Z])(<+|«)/g;
24
+ const unclosed = (text) => {
25
+ const missing = [];
26
+ let match;
27
+ OPENER.lastIndex = 0;
28
+ while ((match = OPENER.exec(text)) !== null) {
29
+ const [whole, before, name, open] = match;
30
+ const rest = text.slice(match.index + whole.length);
31
+ const closed = open === '«' ? rest.includes('»') : rest.includes('>'.repeat(open.length));
32
+ if (!closed) {
33
+ missing.push({ name, at: match.index + before.length });
34
+ }
35
+ }
36
+ return missing;
37
+ };
38
+ export function scanUnclosedMarkupCodes(content) {
39
+ const lines = content.split(/\r?\n/);
40
+ const open = [];
41
+ const violations = [];
42
+ let chunk = null;
43
+ let inAbbreviatedVerbatim = false;
44
+ const close = () => {
45
+ if (!chunk)
46
+ return;
47
+ const at = chunk;
48
+ for (const found of unclosed(at.text)) {
49
+ const name = found.name;
50
+ const line = at.line + at.text.slice(0, found.at).split('\n').length - 1;
51
+ violations.push({
52
+ rule: UNCLOSED_MARKUP_CODE_RULE_ID,
53
+ severity: 'warning',
54
+ message: `${name}<> is closed by the end of the block, not by its own bracket; the text goes out as written`,
55
+ location: {
56
+ start: { line, column: 1, offset: 0 },
57
+ end: { line, column: 1, offset: 0 },
58
+ },
59
+ });
60
+ }
61
+ chunk = null;
62
+ };
63
+ for (let i = 0; i < lines.length; i++) {
64
+ const line = lines[i];
65
+ if (/^\s*=end\s+[\w-]+/.test(line)) {
66
+ close();
67
+ inAbbreviatedVerbatim = false;
68
+ open.pop();
69
+ continue;
70
+ }
71
+ const begin = line.match(/^\s*=begin\s+([\w-]+)/);
72
+ if (begin) {
73
+ close();
74
+ inAbbreviatedVerbatim = false;
75
+ open.push(begin[1]);
76
+ continue;
77
+ }
78
+ if (open.some(isVerbatimBlock))
79
+ continue;
80
+ // a directive starts a chunk of its own; a blank line ends the one running
81
+ if (/^\s*=/.test(line)) {
82
+ close();
83
+ const named = line.match(/^\s*=(?:for\s+)?([\w-]+)/);
84
+ // the short forms carry verbatim text just as the paired ones do
85
+ inAbbreviatedVerbatim = Boolean(named && isVerbatimBlock(named[1]));
86
+ if (!inAbbreviatedVerbatim)
87
+ chunk = { text: line, line: i + 1 };
88
+ continue;
89
+ }
90
+ if (line.trim() === '') {
91
+ close();
92
+ inAbbreviatedVerbatim = false;
93
+ continue;
94
+ }
95
+ if (inAbbreviatedVerbatim)
96
+ continue;
97
+ if (chunk)
98
+ chunk.text += '\n' + line;
99
+ else
100
+ chunk = { text: line, line: i + 1 };
101
+ }
102
+ close();
103
+ return violations;
104
+ }
105
+ //# sourceMappingURL=unclosed-markup-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unclosed-markup-code.js","sourceRoot":"","sources":["../../../src/lint/rules/unclosed-markup-code.ts"],"names":[],"mappings":"AAAA,OA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AAA;;YAC/B,KAAK,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAA;IAC1C,CAAC;IACD,KAAK,EAAE,CAAA;IAEP,OAAO,UAAU,CAAA;AACnB,CAAC"}
@@ -5,6 +5,7 @@ export type RuleSetting = 'off' | Severity;
5
5
  export type LintConfig = {
6
6
  rules?: Record<string, RuleSetting>;
7
7
  };
8
+ export declare const STDIN_NAME = "<stdin>";
8
9
  export type LintContext = {
9
10
  filePath: string;
10
11
  fileType: FileType;
package/esm/lint/types.js CHANGED
@@ -1,2 +1,4 @@
1
- export {};
1
+ // The name a report carries when the document came from a pipe: there is no
2
+ // directory to resolve a relative path against.
3
+ export const STDIN_NAME = '<stdin>';
2
4
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lint/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lint/types.ts"],"names":[],"mappings":"AAYA,4EAA4E;AAC5E,gDAAgD;AAChD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAA"}
package/esm/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "0.0.80";
1
+ export declare const version = "0.0.81";
package/esm/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // generated by scripts/inject-version.mjs — do not edit by hand
2
- export const version = '0.0.80';
2
+ export const version = '0.0.81';
3
3
  //# sourceMappingURL=version.js.map
@@ -6,6 +6,7 @@ const schema_1 = require("@podlite/schema");
6
6
  const table_column_width_1 = require("../rules/table-column-width");
7
7
  const abbreviated_attrs_1 = require("../rules/abbreviated-attrs");
8
8
  const markdown_in_pod_1 = require("../rules/markdown-in-pod");
9
+ const unclosed_markup_code_1 = require("../rules/unclosed-markup-code");
9
10
  const lintGrammar = require('./lint.js');
10
11
  exports.ATTR_NESTED_ANGLE_RULE_ID = 'attr-nested-angle';
11
12
  exports.DELIMITED_BLOCK_BALANCE_RULE_ID = 'delimited-block-balance';
@@ -29,6 +30,7 @@ exports.SOURCE_RULES = [
29
30
  table_column_width_1.tableColumnWidthRule,
30
31
  abbreviated_attrs_1.abbreviatedAttrsRule,
31
32
  markdown_in_pod_1.markdownInPodRule,
33
+ unclosed_markup_code_1.unclosedMarkupCodeRule,
32
34
  ];
33
35
  // The file type decides whether markup of another language is out of place:
34
36
  // in a markdown file markdown is the language, not a stray.
@@ -58,6 +60,7 @@ function scanSourceRules(content, fileType = 'podlite') {
58
60
  opts.diagnostics.push(...(0, abbreviated_attrs_1.scanAbbreviatedAttrs)(content));
59
61
  if (fileType !== 'md')
60
62
  opts.diagnostics.push(...(0, markdown_in_pod_1.scanMarkdownInPod)(content));
63
+ opts.diagnostics.push(...(0, unclosed_markup_code_1.scanUnclosedMarkupCodes)(content));
61
64
  return opts.diagnostics;
62
65
  }
63
66
  //# sourceMappingURL=scan.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../src/lint/grammar/scan.ts"],"names":[],"mappings":";;;AA+CA,0CAyBC;AAvED,4CAAiF;AACjF,oEAAoF;AACpF,kEAAuF;AACvF,8DAA+E;AAE/E,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;AAE3B,QAAA,yBAAyB,GAAG,mBAAmB,CAAA;AAC/C,QAAA,+BAA+B,GAAG,yBAAyB,CAAA;AAC3D,QAAA,iCAAiC,GAAG,2BAA2B,CAAA;AAE/D,QAAA,mBAAmB,GAAe;IAC7C,EAAE,EAAE,iCAAyB;IAC7B,QAAQ,EAAE,OAAO;CAClB,CAAA;AAEY,QAAA,yBAAyB,GAAe;IACnD,EAAE,EAAE,uCAA+B;IACnC,QAAQ,EAAE,OAAO;CAClB,CAAA;AAEY,QAAA,2BAA2B,GAAe;IACrD,EAAE,EAAE,yCAAiC;IACrC,QAAQ,EAAE,SAAS;CACpB,CAAA;AAEY,QAAA,YAAY,GAAiB;IAC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IAAI,mCAAmC;YAC/D,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAA,qCAAgB,EAAC,OAAO,CAAC,CAAC,CAAA;IACnD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAA,wCAAoB,EAAC,OAAO,CAAC,CAAC,CAAA;IACvD,IAAI,QAAQ,KAAK,IAAI;QAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAA,mCAAiB,EAAC,OAAO,CAAC,CAAC,CAAA;IAC3E,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAA,8CAAuB,EAAC,OAAO,CAAC,CAAC,CAAA;IAC1D,OAAO,IAAI,CAAC,WAAW,CAAA;AACzB,CAAC"}
@@ -12,7 +12,6 @@ export type LintOptions = {
12
12
  enable?: string[];
13
13
  disable?: string[];
14
14
  };
15
- export declare const STDIN_NAME = "<stdin>";
16
15
  export declare function lintSource(content: string, filePath: string, config: LintConfig): FileReport;
17
16
  export declare function lintFile(filePath: string, config: LintConfig): FileReport;
18
17
  export declare function resolveConfig(files: string[], options: LintOptions): LintConfig;
package/lib/lint/index.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.STDIN_NAME = exports.readConfig = exports.findConfig = exports.ConfigError = void 0;
36
+ exports.readConfig = exports.findConfig = exports.ConfigError = void 0;
37
37
  exports.lintSource = lintSource;
38
38
  exports.lintFile = lintFile;
39
39
  exports.resolveConfig = resolveConfig;
@@ -48,13 +48,13 @@ const text_1 = require("./formatters/text");
48
48
  const json_1 = require("./formatters/json");
49
49
  const scan_1 = require("./grammar/scan");
50
50
  const config_1 = require("./config");
51
+ const types_1 = require("./types");
51
52
  const mute_1 = require("./mute");
52
53
  var config_2 = require("./config");
53
54
  Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return config_2.ConfigError; } });
54
55
  Object.defineProperty(exports, "findConfig", { enumerable: true, get: function () { return config_2.findConfig; } });
55
56
  Object.defineProperty(exports, "readConfig", { enumerable: true, get: function () { return config_2.readConfig; } });
56
57
  // text handed to the command instead of a path is reported under this name
57
- exports.STDIN_NAME = '<stdin>';
58
58
  function lintSource(content, filePath, config) {
59
59
  const fileType = (0, loader_1.detectFileType)(filePath);
60
60
  const violations = [...(0, config_1.applyConfig)((0, scan_1.scanSourceRules)(content, fileType), config)];
@@ -122,7 +122,7 @@ function runLint(files, options) {
122
122
  }
123
123
  const reports = files.map(filePath => lintFile(filePath, config));
124
124
  if (options.stdinContent !== undefined) {
125
- reports.push(lintSource(options.stdinContent, exports.STDIN_NAME, config));
125
+ reports.push(lintSource(options.stdinContent, types_1.STDIN_NAME, config));
126
126
  }
127
127
  return reportLint(reports, options);
128
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lint/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,gCAaC;AAED,4BAiBC;AAID,sCAIC;AAED,gCAWC;AAED,0BAgBC;AAvGD,2CAA4B;AAE5B,uDAA0D;AAC1D,mCAAuC;AACvC,qCAAmC;AACnC,qCAAiE;AACjE,4CAA0D;AAC1D,4CAA8C;AAC9C,yCAAgD;AAChD,qCAA2F;AAC3F,iCAAmC;AAMnC,mCAA8D;AAArD,qGAAA,WAAW,OAAA;AAAE,oGAAA,UAAU,OAAA;AAAE,oGAAA,UAAU,OAAA;AAa5C,2EAA2E;AAC9D,QAAA,UAAU,GAAG,SAAS,CAAA;AAEnC,SAAgB,UAAU,CAAC,OAAe,EAAE,QAAgB,EAAE,MAAkB;IAC9E,MAAM,QAAQ,GAAG,IAAA,uBAAc,EAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,UAAU,GAAgB,CAAC,GAAG,IAA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require("./id-unique");
7
7
  const media_absolute_file_1 = require("./media-absolute-file");
8
8
  const link_target_resolves_1 = require("./link-target-resolves");
9
+ const link_file_resolves_1 = require("./link-file-resolves");
10
+ const link_not_empty_1 = require("./link-not-empty");
9
11
  const attr_value_dropped_1 = require("./attr-value-dropped");
10
12
  const table_shape_1 = require("./table-shape");
11
13
  const dead_definitions_1 = require("./dead-definitions");
@@ -15,6 +17,8 @@ exports.DEFAULT_RULES = [
15
17
  id_unique_1.idUniqueRule,
16
18
  media_absolute_file_1.mediaAbsoluteFileRule,
17
19
  link_target_resolves_1.linkTargetResolvesRule,
20
+ link_file_resolves_1.linkFileResolvesRule,
21
+ link_not_empty_1.linkNotEmptyRule,
18
22
  attr_value_dropped_1.attrValueDroppedRule,
19
23
  table_shape_1.tableShapeRule,
20
24
  dead_definitions_1.deadDefinitionsRule,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lint/rules/index.ts"],"names":[],"mappings":";;;AACA,iDAAgD;AAChD,2DAA0D;AAC1D,2CAA0C;AAC1C,+DAA6D;AAC7D,iEAA+D;AAC/D,6DAA2D;AAC3D,+CAA8C;AAC9C,yDAAwD;AAE3C,QAAA,aAAa,GAAW;IACnC,8BAAe;IACf,wCAAoB;IACpB,wBAAY;IACZ,2CAAqB;IACrB,6CAAsB;IACtB,yCAAoB;IACpB,4BAAc;IACd,sCAAmB;CACpB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lint/rules/index.ts"],"names":[],"mappings":";;;AACA,iDAAgD;AAChD,2DAA0D;AAC1D,2CAA0C;AAC1C,+DAA6D;AAC7D,iEAA+D;AAC/D,6DAA2D;AAC3D,qDAAmD;AACnD,6DAA2D;AAC3D,+CAA8C;AAC9C,yDAAwD;AAE3C,QAAA,aAAa,GAAW;IACnC,8BAAe;IACf,wCAAoB;IACpB,wBAAY;IACZ,2CAAqB;IACrB,6CAAsB;IACtB,yCAAoB;IACpB,iCAAgB;IAChB,yCAAoB;IACpB,4BAAc;IACd,sCAAmB;CACpB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Rule } from '../types';
2
+ export declare const LINK_FILE_RESOLVES_RULE_ID = "link-file-resolves";
3
+ export declare const linkFileResolvesRule: Rule;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.linkFileResolvesRule = exports.LINK_FILE_RESOLVES_RULE_ID = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const types_1 = require("../types");
7
+ const link_targets_1 = require("./link-targets");
8
+ exports.LINK_FILE_RESOLVES_RULE_ID = 'link-file-resolves';
9
+ // Written with `./` or `../`, the author has declared a path as plainly as a
10
+ // scheme would. A bare word declares nothing in a Podlite document, though in a
11
+ // markdown one it is the ordinary way to write a relative link. A leading slash
12
+ // reads as the root of a site far more often than the root of a disk, so it is
13
+ // left to the author to say `file:` when a disk is what was meant.
14
+ const looksLikePath = (path) => path.startsWith('./') || path.startsWith('../');
15
+ // Relative targets are answered from the directory of the document, so a caller
16
+ // that passed a name rather than a path gets no answer at all: resolving it
17
+ // would silently measure whatever sits in the working directory instead.
18
+ const documentDirectory = (filePath) => {
19
+ if (filePath === types_1.STDIN_NAME)
20
+ return null;
21
+ const full = (0, path_1.resolve)(filePath);
22
+ if (!(0, fs_1.existsSync)(full) || !(0, fs_1.statSync)(full).isFile())
23
+ return null;
24
+ return (0, path_1.dirname)(full);
25
+ };
26
+ // A home-relative path answers differently on every machine, so a check of it
27
+ // would make the run depend on who is running it.
28
+ const isHomeRelative = (path) => path === '~' || path.startsWith('~/');
29
+ const candidatePath = (target, fileType) => {
30
+ if (!target || target.startsWith('#'))
31
+ return null;
32
+ const { scheme, path } = (0, link_targets_1.readAddress)(target);
33
+ if (scheme !== null && scheme !== 'file')
34
+ return null;
35
+ if (!path || isHomeRelative(path))
36
+ return null;
37
+ if (scheme === 'file')
38
+ return path;
39
+ if (path.startsWith('/'))
40
+ return null;
41
+ return fileType === 'md' || looksLikePath(path) ? path : null;
42
+ };
43
+ exports.linkFileResolvesRule = {
44
+ id: exports.LINK_FILE_RESOLVES_RULE_ID,
45
+ severity: 'warning',
46
+ check: (ast, ctx) => {
47
+ const base = documentDirectory(ctx.filePath);
48
+ if (base === null)
49
+ return [];
50
+ return (0, link_targets_1.collectLinks)(ast)
51
+ .map(site => ({ site, path: candidatePath(site.target, ctx.fileType) }))
52
+ .filter(({ path }) => path !== null && !(0, fs_1.existsSync)((0, path_1.isAbsolute)(path) ? path : (0, path_1.resolve)(base, path)))
53
+ .map(({ site }) => ({
54
+ rule: exports.LINK_FILE_RESOLVES_RULE_ID,
55
+ severity: 'warning',
56
+ message: `Link target ${site.target} is not there`,
57
+ location: site.at,
58
+ }));
59
+ },
60
+ };
61
+ //# sourceMappingURL=link-file-resolves.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-file-resolves.js","sourceRoot":"","sources":["../../../src/lint/rules/link-file-resolves.ts"],"names":[],"mappings":";;;AAAA,2BAAyC;AACzC,+BAAmD;AAEnD,oCAAqC;AAErC,iDAA0D;AAE7C,QAAA,0BAA0B,GAAG,oBAAoB,CAAA;AAE9D,6EAA6E;AAC7E,gFAAgF;AAChF,gFAAgF;AAChF,+EAA+E;AAC/E,mEAAmE;AACnE,MAAM,aAAa,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAEhG,gFAAgF;AAChF,4EAA4E;AAC5E,yEAAyE;AACzE,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAiB,EAAE;IAC5D,IAAI,QAAQ,KAAK,kBAAU;QAAE,OAAO,IAAI,CAAA;IACxC,MAAM,IAAI,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAA;IAC9B,IAAI,CAAC,IAAA,eAAU,EAAC,IAAI,CAAC,IAAI,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AAA,2BAAY,EAAC,GAAG,CAAC;aACrB,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;aACvE,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,IAAA,eAAU,EAAC,IAAA,iBAAU,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;aACjG,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YAClB,IAAI,EAAE,kCAA0B;YAChC,QAAQ,EAAE,SAAkB;YAC5B,OAAO,EAAE,eAAe,IAAI,CAAC,MAAM,eAAe;YAClD,QAAQ,EAAE,IAAI,CAAC,EAAE;SAClB,CAAC,CAAC,CAAA;IACP,CAAC;CACF,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Rule } from '../types';
2
+ export declare const LINK_NOT_EMPTY_RULE_ID = "link-not-empty";
3
+ export declare const linkNotEmptyRule: Rule;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.linkNotEmptyRule = exports.LINK_NOT_EMPTY_RULE_ID = void 0;
4
+ const link_targets_1 = require("./link-targets");
5
+ exports.LINK_NOT_EMPTY_RULE_ID = 'link-not-empty';
6
+ exports.linkNotEmptyRule = {
7
+ id: exports.LINK_NOT_EMPTY_RULE_ID,
8
+ severity: 'error',
9
+ check: (ast, _ctx) => (0, link_targets_1.collectLinks)(ast)
10
+ .filter(({ target }) => target === '')
11
+ .map(({ at }) => ({
12
+ rule: exports.LINK_NOT_EMPTY_RULE_ID,
13
+ severity: 'error',
14
+ message: 'Link has no address to go to',
15
+ location: at,
16
+ })),
17
+ };
18
+ //# sourceMappingURL=link-not-empty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-not-empty.js","sourceRoot":"","sources":["../../../src/lint/rules/link-not-empty.ts"],"names":[],"mappings":";;;AAEA,iDAA6C;AAEhC,QAAA,sBAAsB,GAAG,gBAAgB,CAAA;AAEzC,QAAA,gBAAgB,GAAS;IACpC,EAAE,EAAE,8BAAsB;IAC1B,QAAQ,EAAE,OAAO;IACjB,KAAK,EAAE,CAAC,GAAoB,EAAE,IAAiB,EAAe,EAAE,CAC9D,IAAA,2BAAY,EAAC,GAAG,CAAC;SACd,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,EAAE,CAAC;SACrC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAChB,IAAI,EAAE,8BAAsB;QAC5B,QAAQ,EAAE,OAAgB;QAC1B,OAAO,EAAE,8BAA8B;QACvC,QAAQ,EAAE,EAAE;KACb,CAAC,CAAC;CACR,CAAA"}
@@ -2,42 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.linkTargetResolvesRule = exports.LINK_TARGET_RESOLVES_RULE_ID = void 0;
4
4
  const schema_1 = require("@podlite/schema");
5
- const id_unique_1 = require("./id-unique");
5
+ const link_targets_1 = require("./link-targets");
6
6
  exports.LINK_TARGET_RESOLVES_RULE_ID = 'link-target-resolves';
7
- // A link without display text carries the target in its content instead of meta.
8
- const linkTarget = (node) => {
9
- if (typeof node.meta === 'string')
10
- return node.meta.trim();
11
- const content = Array.isArray(node.content) ? node.content : [];
12
- const first = content[0];
13
- return typeof first === 'string' ? first.trim() : '';
14
- };
15
- // Inline nodes carry no location, so the nearest enclosing block supplies one.
16
- const collectAnchors = (node, at) => {
17
- if (Array.isArray(node))
18
- return node.flatMap(child => collectAnchors(child, at));
19
- if (!node || typeof node !== 'object')
20
- return [];
21
- const n = node;
22
- const here = n.location || at;
23
- const found = n.type === 'fcode' && (n.name === 'L' || n.name === 'W') ? [{ target: linkTarget(n), at: here }] : [];
24
- return [...found, ...collectAnchors(n.content, here)];
25
- };
26
7
  exports.linkTargetResolvesRule = {
27
8
  id: exports.LINK_TARGET_RESOLVES_RULE_ID,
28
9
  severity: 'error',
29
10
  check: (ast, _ctx) => {
30
- const anchors = collectAnchors(ast).filter(({ target }) => target.startsWith('#'));
11
+ // A bare # is left alone by the export — it is not a target and not a mistake —
12
+ // so the rule has nothing to say about it either.
13
+ const anchors = (0, link_targets_1.collectLinks)(ast).filter(({ target }) => target.startsWith('#') && target !== '#');
31
14
  if (anchors.length === 0)
32
15
  return [];
33
16
  // Both ways an anchor can exist: written by the author as :id, or carried by a
34
17
  // heading under its own name. Matched the way the exporter matches them.
35
- const written = new Set((0, id_unique_1.collectExplicitIds)(ast).map(entry => (0, schema_1.toFragment)(entry.value)));
36
- const headings = (0, schema_1.indexAnchors)(ast);
37
- const resolves = (target) => {
38
- const name = target.slice(1);
39
- return written.has((0, schema_1.toFragment)(name)) || (0, schema_1.findAnchor)(name, headings) !== undefined;
40
- };
18
+ // Asked of the same binding the exporters ask, rather than worked out again here.
19
+ // Two answers to one question is how this rule came to call a link sound that the
20
+ // export could not resolve: it shaped both sides itself, and the export did not.
21
+ const index = (0, schema_1.buildBindingIndex)(ast);
22
+ const resolves = (target) => (0, schema_1.bindTarget)(target.slice(1), index).found;
41
23
  return anchors
42
24
  .filter(({ target }) => !resolves(target))
43
25
  .map(({ target, at }) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"link-target-resolves.js","sourceRoot":"","sources":["../../../src/lint/rules/link-target-resolves.ts"],"names":[],"mappings":";;;AAAA,4CAAuF;AAEvF,2CAAgD;AAEnC,QAAA,4BAA4B,GAAG,sBAAsB,CAAA;AASlE,iFAAiF;AACjF,MAAM,UAAU,GAAG,CAAC,IAAc,EAAU,EAAE;IAC5C,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,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 import type { Violation } from '../types';
2
+ export type LinkSite = {
3
+ target: string;
4
+ at?: Violation['location'];
5
+ };
6
+ export declare const collectLinks: (node: unknown, at?: Violation["location"]) => LinkSite[];
7
+ export type LinkAddress = {
8
+ scheme: string | null;
9
+ path: string;
10
+ };
11
+ export declare const readAddress: (target: string) => LinkAddress;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readAddress = exports.collectLinks = void 0;
4
+ // Content is a bare string before the tree is processed and a node after it.
5
+ const textOf = (value) => {
6
+ if (typeof value === 'string')
7
+ return value;
8
+ if (value && typeof value === 'object' && 'value' in value && typeof value.value === 'string')
9
+ return value.value;
10
+ return '';
11
+ };
12
+ // A link without display text carries the target in its content instead of meta.
13
+ const linkTarget = (node) => {
14
+ if (typeof node.meta === 'string')
15
+ return node.meta.trim();
16
+ const content = Array.isArray(node.content) ? node.content : [];
17
+ return textOf(content[0]).trim();
18
+ };
19
+ const isLink = (node) => node.type === 'fcode' && (node.name === 'L' || node.name === 'W');
20
+ // Inline nodes carry no location, so the nearest enclosing block supplies one.
21
+ const collectLinks = (node, at) => {
22
+ if (Array.isArray(node))
23
+ return node.flatMap(child => (0, exports.collectLinks)(child, at));
24
+ if (!node || typeof node !== 'object')
25
+ return [];
26
+ const n = node;
27
+ const here = n.location || at;
28
+ const found = isLink(n) ? [{ target: linkTarget(n), at: here }] : [];
29
+ return [...found, ...(0, exports.collectLinks)(n.content, here)];
30
+ };
31
+ exports.collectLinks = collectLinks;
32
+ const SCHEME = /^([a-zA-Z][a-zA-Z0-9+.-]*):(.*)$/;
33
+ // A single letter before the colon is a Windows drive, but only where something
34
+ // else says Windows: a separator, or a backslash further along. Without one,
35
+ // `a:b` is a scheme and reading it as a path would warn about a target that is
36
+ // not on this disk at all.
37
+ const DRIVE = /^[a-zA-Z]:([\\/]|[^\\]*\\)/;
38
+ // The specification separates the internal address from the external one with a
39
+ // `#`, so what is left of it is the part a filesystem can answer for.
40
+ const readAddress = (target) => {
41
+ const matched = DRIVE.test(target) ? null : SCHEME.exec(target);
42
+ const scheme = matched ? matched[1].toLowerCase() : null;
43
+ const rest = matched ? matched[2] : target;
44
+ return { scheme, path: rest.split('#')[0].split('?')[0] };
45
+ };
46
+ exports.readAddress = readAddress;
47
+ //# sourceMappingURL=link-targets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-targets.js","sourceRoot":"","sources":["../../../src/lint/rules/link-targets.ts"],"names":[],"mappings":";;;AAcA,6EAA6E;AAC7E,MAAM,MAAM,GAAG,CAAC,KAAc,EAAU,EAAE;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,KAAK,CAAA;IACjH,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAED,iFAAiF;AACjF,MAAM,UAAU,GAAG,CAAC,IAAc,EAAU,EAAE;IAC5C,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/D,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAClC,CAAC,CAAA;AAED,MAAM,MAAM,GAAG,CAAC,IAAkC,EAAW,EAAE,CAC7D,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,CAAA;AAEnE,+EAA+E;AACx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,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IAC1C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAC3D,CAAC,CAAA;AALY,QAAA,WAAW,eAKvB"}
@@ -0,0 +1,4 @@
1
+ import type { Violation, SourceRule } from '../types';
2
+ export declare const UNCLOSED_MARKUP_CODE_RULE_ID = "unclosed-markup-code";
3
+ export declare const unclosedMarkupCodeRule: SourceRule;
4
+ export declare function scanUnclosedMarkupCodes(content: string): Violation[];
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unclosedMarkupCodeRule = exports.UNCLOSED_MARKUP_CODE_RULE_ID = void 0;
4
+ exports.scanUnclosedMarkupCodes = scanUnclosedMarkupCodes;
5
+ const schema_1 = require("@podlite/schema");
6
+ exports.UNCLOSED_MARKUP_CODE_RULE_ID = 'unclosed-markup-code';
7
+ exports.unclosedMarkupCodeRule = {
8
+ id: exports.UNCLOSED_MARKUP_CODE_RULE_ID,
9
+ severity: 'warning',
10
+ };
11
+ // The specification leaves the parser no choice: a markup code that ends at the
12
+ // end of its block rather than at its own delimiter is to be reported. The
13
+ // parser instead drops such a code and the text goes out carrying the opening
14
+ // letter, so the whole line reads as written rather than as marked up.
15
+ //
16
+ // Closure is counted the way the specification defines it: a code opened with N
17
+ // angle brackets is closed by N of them together, and one opened with a
18
+ // guillemet by the closing guillemet. Counting rather than asking the parser
19
+ // keeps the doubled forms out of the report — C<< text >> is closed, and the
20
+ // parser drops it for reasons of its own when it sits inside another code.
21
+ //
22
+ // One case stays out of reach: an outer code opened with a single bracket whose
23
+ // inner code closes with its own. The count sees that bracket and calls the
24
+ // outer one closed. Asking the parser instead catches it, but then every single
25
+ // code written inside a doubled one reads as unclosed, and correct markup gets
26
+ // reported — the worse of the two.
27
+ const OPENER = /(^|[^A-Za-z])([A-Z])(<+|«)/g;
28
+ const unclosed = (text) => {
29
+ const missing = [];
30
+ let match;
31
+ OPENER.lastIndex = 0;
32
+ while ((match = OPENER.exec(text)) !== null) {
33
+ const [whole, before, name, open] = match;
34
+ const rest = text.slice(match.index + whole.length);
35
+ const closed = open === '«' ? rest.includes('»') : rest.includes('>'.repeat(open.length));
36
+ if (!closed) {
37
+ missing.push({ name, at: match.index + before.length });
38
+ }
39
+ }
40
+ return missing;
41
+ };
42
+ function scanUnclosedMarkupCodes(content) {
43
+ const lines = content.split(/\r?\n/);
44
+ const open = [];
45
+ const violations = [];
46
+ let chunk = null;
47
+ let inAbbreviatedVerbatim = false;
48
+ const close = () => {
49
+ if (!chunk)
50
+ return;
51
+ const at = chunk;
52
+ for (const found of unclosed(at.text)) {
53
+ const name = found.name;
54
+ const line = at.line + at.text.slice(0, found.at).split('\n').length - 1;
55
+ violations.push({
56
+ rule: exports.UNCLOSED_MARKUP_CODE_RULE_ID,
57
+ severity: 'warning',
58
+ message: `${name}<> is closed by the end of the block, not by its own bracket; the text goes out as written`,
59
+ location: {
60
+ start: { line, column: 1, offset: 0 },
61
+ end: { line, column: 1, offset: 0 },
62
+ },
63
+ });
64
+ }
65
+ chunk = null;
66
+ };
67
+ for (let i = 0; i < lines.length; i++) {
68
+ const line = lines[i];
69
+ if (/^\s*=end\s+[\w-]+/.test(line)) {
70
+ close();
71
+ inAbbreviatedVerbatim = false;
72
+ open.pop();
73
+ continue;
74
+ }
75
+ const begin = line.match(/^\s*=begin\s+([\w-]+)/);
76
+ if (begin) {
77
+ close();
78
+ inAbbreviatedVerbatim = false;
79
+ open.push(begin[1]);
80
+ continue;
81
+ }
82
+ if (open.some(schema_1.isVerbatimBlock))
83
+ continue;
84
+ // a directive starts a chunk of its own; a blank line ends the one running
85
+ if (/^\s*=/.test(line)) {
86
+ close();
87
+ const named = line.match(/^\s*=(?:for\s+)?([\w-]+)/);
88
+ // the short forms carry verbatim text just as the paired ones do
89
+ inAbbreviatedVerbatim = Boolean(named && (0, schema_1.isVerbatimBlock)(named[1]));
90
+ if (!inAbbreviatedVerbatim)
91
+ chunk = { text: line, line: i + 1 };
92
+ continue;
93
+ }
94
+ if (line.trim() === '') {
95
+ close();
96
+ inAbbreviatedVerbatim = false;
97
+ continue;
98
+ }
99
+ if (inAbbreviatedVerbatim)
100
+ continue;
101
+ if (chunk)
102
+ chunk.text += '\n' + line;
103
+ else
104
+ chunk = { text: line, line: i + 1 };
105
+ }
106
+ close();
107
+ return violations;
108
+ }
109
+ //# sourceMappingURL=unclosed-markup-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unclosed-markup-code.js","sourceRoot":"","sources":["../../../src/lint/rules/unclosed-markup-code.ts"],"names":[],"mappings":";;;AA6CA,0DAiEC;AA9GD,4CAAiD;AAGpC,QAAA,4BAA4B,GAAG,sBAAsB,CAAA;AAErD,QAAA,sBAAsB,GAAe;IAChD,EAAE,EAAE,oCAA4B;IAChC,QAAQ,EAAE,SAAS;CACpB,CAAA;AAED,gFAAgF;AAChF,2EAA2E;AAC3E,8EAA8E;AAC9E,uEAAuE;AACvE,EAAE;AACF,gFAAgF;AAChF,wEAAwE;AACxE,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,EAAE;AACF,gFAAgF;AAChF,4EAA4E;AAC5E,gFAAgF;AAChF,+EAA+E;AAC/E,mCAAmC;AACnC,MAAM,MAAM,GAAG,6BAA6B,CAAA;AAE5C,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAuC,EAAE;IACrE,MAAM,OAAO,GAAwC,EAAE,CAAA;IACvD,IAAI,KAA6B,CAAA;IACjC,MAAM,CAAC,SAAS,GAAG,CAAC,CAAA;IACpB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,C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A0B,CAAC,CAAA;YACpD,iEAAiE;YACjE,qBAAqB,GAAG,OAAO,CAAC,KAAK,IAAI,IAAA,wBAAe,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YACnE,IAAI,CAAC,qBAAqB;gBAAE,KAAK,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAA;YAC/D,SAAQ;QACV,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACvB,KAAK,EAAE,CAAA;YACP,qBAAqB,GAAG,KAAK,CAAA;YAC7B,SAAQ;QACV,CAAC;QACD,IAAI,qBAAqB;YAAE,SAAQ;QACnC,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,IAAI,IAAI,GAAG,IAAI,CAAA;;YAC/B,KAAK,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAA;IAC1C,CAAC;IACD,KAAK,EAAE,CAAA;IAEP,OAAO,UAAU,CAAA;AACnB,CAAC"}
@@ -5,6 +5,7 @@ export type RuleSetting = 'off' | Severity;
5
5
  export type LintConfig = {
6
6
  rules?: Record<string, RuleSetting>;
7
7
  };
8
+ export declare const STDIN_NAME = "<stdin>";
8
9
  export type LintContext = {
9
10
  filePath: string;
10
11
  fileType: FileType;
package/lib/lint/types.js CHANGED
@@ -1,3 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STDIN_NAME = void 0;
4
+ // The name a report carries when the document came from a pipe: there is no
5
+ // directory to resolve a relative path against.
6
+ exports.STDIN_NAME = '<stdin>';
3
7
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lint/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lint/types.ts"],"names":[],"mappings":";;;AAYA,4EAA4E;AAC5E,gDAAgD;AACnC,QAAA,UAAU,GAAG,SAAS,CAAA"}
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "0.0.80";
1
+ export declare const version = "0.0.81";
package/lib/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // generated by scripts/inject-version.mjs — do not edit by hand
5
- exports.version = '0.0.80';
5
+ exports.version = '0.0.81';
6
6
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "podlite",
3
- "version": "0.0.80",
3
+ "version": "0.0.81",
4
4
  "description": "Podlite markup language parser — Markdown-compatible, with native support for diagrams, formulas, and custom blocks",
5
5
  "homepage": "https://podlite.org",
6
6
  "repository": {
@@ -80,12 +80,12 @@
80
80
  "url": "https://github.com/podlite/podlite/issues"
81
81
  },
82
82
  "dependencies": {
83
- "@podlite/diagram": "^0.0.71",
84
- "@podlite/formula": "0.0.49",
85
- "@podlite/image": "^0.0.66",
86
- "@podlite/markdown": "0.0.60",
87
- "@podlite/schema": "^0.0.67",
88
- "@podlite/toc": "0.0.60",
83
+ "@podlite/diagram": "^0.0.72",
84
+ "@podlite/formula": "0.0.50",
85
+ "@podlite/image": "^0.0.67",
86
+ "@podlite/markdown": "0.0.61",
87
+ "@podlite/schema": "^0.0.68",
88
+ "@podlite/toc": "0.0.61",
89
89
  "nanoid": "3.1.30"
90
90
  },
91
91
  "devDependencies": {