@abreen/tada 1.17.0 → 1.18.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.
Files changed (107) hide show
  1. package/README.md +41 -7
  2. package/bin/tada.ts +23 -9
  3. package/bin/validators.ts +34 -1
  4. package/build/branding.ts +41 -0
  5. package/build/build-manifest.ts +10 -5
  6. package/build/{watch/compiler-types.d.ts → build-types.d.ts} +8 -5
  7. package/build/build-validation.ts +176 -0
  8. package/build/bundle.ts +75 -65
  9. package/build/columns-plugin.ts +27 -1
  10. package/build/config-loader.ts +3 -3
  11. package/build/custom-fonts.ts +8 -5
  12. package/build/deflist-id-plugin.ts +2 -2
  13. package/build/generate-favicon.ts +7 -6
  14. package/build/generate-fonts.ts +8 -15
  15. package/build/generate-katex-assets.ts +19 -17
  16. package/build/generate-web-app-manifest.ts +3 -11
  17. package/build/lodash-template.ts +14 -0
  18. package/build/output-publication.ts +238 -0
  19. package/build/pagefind.ts +49 -21
  20. package/build/pdf-text.ts +41 -1
  21. package/build/pipeline.ts +95 -101
  22. package/build/site-assets.ts +46 -0
  23. package/build/site-build.ts +267 -0
  24. package/build/source-model.ts +223 -229
  25. package/build/source-records.ts +69 -81
  26. package/build/template-globals.ts +3 -0
  27. package/build/templates.ts +12 -8
  28. package/build/toc-plugin.ts +21 -21
  29. package/build/types.d.ts +38 -38
  30. package/build/util.ts +0 -4
  31. package/build/utils/code.ts +51 -117
  32. package/build/utils/final-html.ts +171 -47
  33. package/build/utils/jdi-runner/LiterateRunner.java +9 -1
  34. package/build/utils/literate-java.ts +11 -7
  35. package/build/utils/markdown-partials.ts +4 -3
  36. package/build/utils/markdown.ts +6 -17
  37. package/build/utils/paths.ts +3 -0
  38. package/build/utils/plain-text.ts +18 -0
  39. package/build/utils/render.ts +197 -154
  40. package/build/utils/shiki-highlighter.ts +11 -0
  41. package/build/utils/source-template.ts +2 -2
  42. package/build/utils/trace-core.ts +8 -83
  43. package/build/utils/trace.ts +38 -95
  44. package/build/validate-config-links.ts +39 -6
  45. package/build/watch/build-incremental.ts +46 -103
  46. package/build/watch/compiler.ts +158 -37
  47. package/build/watch/engine.ts +207 -162
  48. package/build/watch/index.ts +9 -2
  49. package/build/watch/planner.ts +88 -144
  50. package/build/watch/runtime.ts +21 -34
  51. package/build/watch/types.d.ts +32 -64
  52. package/package.json +4 -5
  53. package/schema/site.schema.json +18 -2
  54. package/src/_content.scss +447 -0
  55. package/src/_fonts.scss +90 -0
  56. package/src/_layout.scss +50 -35
  57. package/src/appearance-picker/{style.scss → _index.scss} +1 -1
  58. package/src/code/{style.scss → _index.scss} +61 -0
  59. package/src/header/{_base.scss → _index.scss} +98 -6
  60. package/src/index.ts +1 -17
  61. package/src/navigate/{style.scss → _index.scss} +20 -0
  62. package/src/navigate/eligible.ts +0 -40
  63. package/src/navigate/index.ts +50 -5
  64. package/src/navigate/lifecycle.ts +19 -2
  65. package/src/navigate/runtime.ts +20 -4
  66. package/src/page-update/index.ts +33 -20
  67. package/src/print/{style.scss → _index.scss} +3 -1
  68. package/src/search/index.ts +30 -2
  69. package/src/slides/{style.scss → _index.scss} +5 -0
  70. package/src/style.scss +24 -536
  71. package/src/timezone/index.ts +29 -3
  72. package/src/timezone/time-format.ts +4 -0
  73. package/src/toc/index.ts +6 -5
  74. package/src/trace/index.ts +11 -1
  75. package/templates/_author.html +2 -2
  76. package/templates/_download.html +1 -1
  77. package/templates/_footer.html +1 -1
  78. package/templates/_heading.html +3 -3
  79. package/templates/_nav.html +2 -2
  80. package/templates/_page-bottom.html +6 -0
  81. package/templates/_top.html +18 -14
  82. package/templates/code.html +22 -21
  83. package/templates/default.html +12 -11
  84. package/templates/literate.html +6 -5
  85. package/build/copy.ts +0 -82
  86. package/build/generate-content-assets.ts +0 -121
  87. package/build/utils/content-files.ts +0 -170
  88. package/build/watch/assets.ts +0 -103
  89. package/build/watch/build-full.ts +0 -97
  90. package/build/watch/build-helpers.ts +0 -66
  91. package/build/watch/build-result.ts +0 -19
  92. package/build/watch/fs-commit.ts +0 -153
  93. package/build/watch/mutations.ts +0 -73
  94. package/build/watch/snapshot.ts +0 -201
  95. package/build/watch/validation.ts +0 -50
  96. package/src/code.scss +0 -60
  97. package/src/critical.scss +0 -5
  98. package/src/header/style.scss +0 -91
  99. /package/src/{literate.scss → _literate.scss} +0 -0
  100. /package/src/{material-symbols.scss → _material-symbols.scss} +0 -0
  101. /package/src/anchor/{style.scss → _index.scss} +0 -0
  102. /package/src/page-update/{style.scss → _index.scss} +0 -0
  103. /package/src/question/{style.scss → _index.scss} +0 -0
  104. /package/src/search/{style.scss → _index.scss} +0 -0
  105. /package/src/timezone/{style.scss → _index.scss} +0 -0
  106. /package/src/toc/{style.scss → _index.scss} +0 -0
  107. /package/src/trace/{style.scss → _index.scss} +0 -0
@@ -7,7 +7,6 @@ import markdownItAnchor from 'markdown-it-anchor';
7
7
  import markdownItFootnote from 'markdown-it-footnote';
8
8
  import markdownItDeflist from 'markdown-it-deflist';
9
9
  import markdownItContainer from 'markdown-it-container';
10
- import textToId, { deduplicateId } from '../text-to-id';
11
10
  import { highlightCode } from './shiki-highlighter';
12
11
  import { isBundledLanguage, isPlainTextLanguage } from '../site-variables';
13
12
  import headingSubtitlePlugin from '../heading-subtitle-plugin';
@@ -28,10 +27,11 @@ interface CreateMarkdownOptions {
28
27
  filePath?: string;
29
28
  slides?: boolean;
30
29
  validatorOptions?: Record<string, unknown>;
31
- literateJavaOutputPaths?: Set<string>;
30
+ literateJavaOutputPaths?: ReadonlySet<string>;
32
31
  sourceUrlPath?: string;
33
- validTargets?: Set<string>;
32
+ validTargets?: ReadonlySet<string>;
34
33
  templateParams?: Record<string, unknown>;
34
+ preserveHtmlComments?: boolean;
35
35
  dependencyCollector?: RenderDependencyCollector;
36
36
  }
37
37
 
@@ -102,6 +102,7 @@ export function createMarkdown(
102
102
  markdown.use(markdownPartialsPlugin, {
103
103
  filePath,
104
104
  templateParams: options.templateParams,
105
+ preserveHtmlComments: options.preserveHtmlComments,
105
106
  dependencyCollector: options.dependencyCollector,
106
107
  });
107
108
  }
@@ -458,18 +459,12 @@ export function createMarkdown(
458
459
  state.tokens = transformedTokens;
459
460
  });
460
461
 
461
- const usedIds = new Map<string, number>();
462
462
  markdown.use(markdownItContainer, 'alert', {
463
463
  marker: '!',
464
464
  validate: function (params: string) {
465
465
  return ALERT_PATTERN.test(params.trim());
466
466
  },
467
- render: function (
468
- tokens: Token[],
469
- idx: number,
470
- _options: unknown,
471
- env: Record<string, unknown>,
472
- ) {
467
+ render: function (tokens: Token[], idx: number) {
473
468
  const matches = tokens[idx].info.trim().match(ALERT_PATTERN);
474
469
 
475
470
  if (tokens[idx].nesting === 1) {
@@ -483,13 +478,7 @@ export function createMarkdown(
483
478
  const displayTitle = title
484
479
  ? markdown.utils.escapeHtml(curlyQuote(title))
485
480
  : capitalize(type || '');
486
- const baseId = textToId(title || type || '');
487
- const titleId = deduplicateId(usedIds, baseId);
488
-
489
- if (!env.alertIds) {
490
- env.alertIds = [];
491
- }
492
- (env.alertIds as string[]).push(titleId);
481
+ const titleId = tokens[idx].attrGet('id')!;
493
482
 
494
483
  let html = `<div class="${classNames.join(' ')}">`;
495
484
  html += `<p class="title" id="${titleId}">${displayTitle}</p>\n`;
@@ -2,6 +2,9 @@ import path from 'path';
2
2
  import { globals } from '../globals';
3
3
  import type { SiteVariables } from '../types';
4
4
 
5
+ /** The search index directory inside the output directory */
6
+ export const SEARCH_INDEX_DIR = 'pagefind';
7
+
5
8
  export function getPackageDir(): string {
6
9
  return path.resolve(import.meta.dir, '..', '..');
7
10
  }
@@ -0,0 +1,18 @@
1
+ import { decodeHTML } from 'entities';
2
+
3
+ /**
4
+ * Converts rendered inline HTML (such as a front matter title rendered as
5
+ * Markdown) into the plain text a reader sees: tags and comments are removed
6
+ * by an HTML parser, and character references are decoded exactly once.
7
+ */
8
+ export function htmlToPlainText(html: string): string {
9
+ let text = '';
10
+ new HTMLRewriter()
11
+ .onDocument({
12
+ text(chunk) {
13
+ text += chunk.text;
14
+ },
15
+ })
16
+ .transform(html);
17
+ return decodeHTML(text);
18
+ }