tfrere HF Staff commited on
Commit
7b02d08
·
1 Parent(s): 612e4e7

fix embeds

Browse files
app/scripts/notion-importer/mdx-converter.mjs CHANGED
@@ -485,14 +485,36 @@ tableOfContentsAutoCollapse: true
485
 
486
 
487
  /**
488
- * Add a blank line after each markdown table
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  * @param {string} content - MDX content
490
- * @returns {string} - Content with blank lines after tables
491
  */
492
- function addBlankLineAfterTables(content) {
493
- console.log(' 📋 Adding blank lines after tables...');
494
 
495
- let addedCount = 0;
 
496
  const lines = content.split('\n');
497
  const result = [];
498
 
@@ -500,18 +522,18 @@ function addBlankLineAfterTables(content) {
500
  result.push(lines[i]);
501
 
502
  // Check if current line is the end of a table
503
- if (lines[i].trim().startsWith('|') && lines[i].trim().endsWith('|')) {
504
  // Look ahead to see if this is the last line of a table
505
  let isLastTableLine = false;
506
 
507
  // Check if next line is empty or doesn't start with |
508
  if (i + 1 >= lines.length ||
509
  lines[i + 1].trim() === '' ||
510
- !lines[i + 1].trim().startsWith('|')) {
511
 
512
  // Look back to find if we're actually inside a table
513
  let tableLineCount = 0;
514
- for (let j = i; j >= 0 && lines[j].trim().startsWith('|') && lines[j].trim().endsWith('|'); j--) {
515
  tableLineCount++;
516
  }
517
 
@@ -522,16 +544,33 @@ function addBlankLineAfterTables(content) {
522
  }
523
 
524
  if (isLastTableLine) {
525
- addedCount++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
526
  result.push(''); // Add blank line
527
  }
528
  }
529
  }
530
 
531
- if (addedCount > 0) {
532
- console.log(` ✅ Added blank line after ${addedCount} table(s)`);
533
  } else {
534
- console.log(' ℹ️ No tables found to process');
535
  }
536
 
537
  return result.join('\n');
@@ -703,8 +742,8 @@ async function processMdxContent(content, pageId = null, notionToken = null, out
703
  // Apply essential steps only
704
  processedContent = await ensureFrontmatter(processedContent, pageId, notionToken);
705
 
706
- // Add blank lines after tables
707
- processedContent = addBlankLineAfterTables(processedContent);
708
 
709
  // Transform markdown images to Image components
710
  processedContent = transformMarkdownImages(processedContent);
 
485
 
486
 
487
  /**
488
+ * Check if a line is a table line
489
+ * @param {string} line - Line to check
490
+ * @returns {boolean} - True if it's a table line
491
+ */
492
+ function isTableLine(line) {
493
+ const trimmed = line.trim();
494
+ return trimmed.startsWith('|') && trimmed.endsWith('|');
495
+ }
496
+
497
+ /**
498
+ * Check if a line is a list item
499
+ * @param {string} line - Line to check
500
+ * @returns {boolean} - True if it's a list item
501
+ */
502
+ function isListItem(line) {
503
+ const trimmed = line.trim();
504
+ // Match: * -, + (bullet points) or 1. 2. 3. (numbered lists)
505
+ return /^\s*[\*\-\+]\s/.test(trimmed) || /^\s*\d+\.\s/.test(trimmed);
506
+ }
507
+
508
+ /**
509
+ * Add a blank line after each markdown table and list
510
  * @param {string} content - MDX content
511
+ * @returns {string} - Content with blank lines after tables and lists
512
  */
513
+ function addBlankLineAfterTablesAndLists(content) {
514
+ console.log(' 📋 Adding blank lines after tables and lists...');
515
 
516
+ let addedTableCount = 0;
517
+ let addedListCount = 0;
518
  const lines = content.split('\n');
519
  const result = [];
520
 
 
522
  result.push(lines[i]);
523
 
524
  // Check if current line is the end of a table
525
+ if (isTableLine(lines[i])) {
526
  // Look ahead to see if this is the last line of a table
527
  let isLastTableLine = false;
528
 
529
  // Check if next line is empty or doesn't start with |
530
  if (i + 1 >= lines.length ||
531
  lines[i + 1].trim() === '' ||
532
+ !isTableLine(lines[i + 1])) {
533
 
534
  // Look back to find if we're actually inside a table
535
  let tableLineCount = 0;
536
+ for (let j = i; j >= 0 && isTableLine(lines[j]); j--) {
537
  tableLineCount++;
538
  }
539
 
 
544
  }
545
 
546
  if (isLastTableLine) {
547
+ addedTableCount++;
548
+ result.push(''); // Add blank line
549
+ }
550
+ }
551
+ // Check if current line is the end of a list
552
+ else if (isListItem(lines[i])) {
553
+ // Look ahead to see if this is the last line of a list
554
+ let isLastListItem = false;
555
+
556
+ // Check if next line is empty or doesn't start with list marker
557
+ if (i + 1 >= lines.length ||
558
+ lines[i + 1].trim() === '' ||
559
+ !isListItem(lines[i + 1])) {
560
+ isLastListItem = true;
561
+ }
562
+
563
+ if (isLastListItem) {
564
+ addedListCount++;
565
  result.push(''); // Add blank line
566
  }
567
  }
568
  }
569
 
570
+ if (addedTableCount > 0 || addedListCount > 0) {
571
+ console.log(` ✅ Added blank line after ${addedTableCount} table(s) and ${addedListCount} list(s)`);
572
  } else {
573
+ console.log(' ℹ️ No tables or lists found to process');
574
  }
575
 
576
  return result.join('\n');
 
742
  // Apply essential steps only
743
  processedContent = await ensureFrontmatter(processedContent, pageId, notionToken);
744
 
745
+ // Add blank lines after tables and lists
746
+ processedContent = addBlankLineAfterTablesAndLists(processedContent);
747
 
748
  // Transform markdown images to Image components
749
  processedContent = transformMarkdownImages(processedContent);
app/scripts/notion-importer/test-comment-fix-processed.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Test des Commentaires Notion
2
+
3
+ Ce fichier contient des exemples de commentaires Notion mal formatés qui génèrent des ` ` bizarres.
4
+
5
+ ### Exemples de Problèmes
6
+
7
+ #### Commentaire standalone mal formaté
8
+ [^comment]: Ceci est un commentaire qui devrait être converti en note de bas de page
9
+
10
+ #### Commentaire inline mal formaté
11
+ Voici du texte normal avec un commentaire inline[^comment] qui traînent dans le contenu.
12
+
13
+ #### Formatage gras corrompu *Texte en gras * qui a été corrompu par les commentaires.
14
+
15
+ [^comment] qui devrait rester en gras.
16
+
17
+ #### Cas qui ne doivent PAS être modifiés TITRE EN GRAS - Ceci doit rester en gras car c'est un titre.
18
+
19
+ [^comment] - Ceci doit rester en gras car c'est court et important.
20
+
21
+ [Lien](https://example.com) - Ceci contient des liens et ne doit pas être modifié. 123 - Ceci ne doit pas être modifié car c'est juste des chiffres.
22
+
23
+ ### Résultat Attendu
24
+
25
+ Après traitement, les commentaires devraient être convertis en notes de bas de page :
26
+
27
+ - `[^comment]` → `[^comment]: Ceci est un commentaire`
28
+ - `texte [^comment] suite` → `texte[^comment] suite`
29
+ - Les astérisques orphelins devraient être supprimés
30
+ - Le formatage gras légitime devrait être préservé
app/src/content/embeds/gpu-sm-architecture.html CHANGED
@@ -67,10 +67,10 @@
67
  const getColors = () => {
68
  try {
69
  if (window.ColorPalettes && typeof window.ColorPalettes.getColors === 'function') {
70
- return window.ColorPalettes.getColors('categorical', 5);
71
  }
72
  } catch (_) { }
73
- return ['#64748b', '#94a3b8', '#cbd5e1', '#e2e8f0', '#f1f5f9'];
74
  };
75
 
76
  const colors = getColors();
@@ -78,10 +78,10 @@
78
  // Background colors - gray tones like training compass
79
  const bgColors = {
80
  sm: 'var(--surface-bg)', // Dark mode ready SM background
81
- control: colors[1], // Keep categorical colors for components
82
- registers: colors[2],
83
- cores: colors[3],
84
- cache: colors[4]
85
  };
86
 
87
  // Create diagram container
 
67
  const getColors = () => {
68
  try {
69
  if (window.ColorPalettes && typeof window.ColorPalettes.getColors === 'function') {
70
+ return window.ColorPalettes.getColors('categorical', 4);
71
  }
72
  } catch (_) { }
73
+ return ['#64748b', '#94a3b8', '#cbd5e1', '#e2e8f0'];
74
  };
75
 
76
  const colors = getColors();
 
78
  // Background colors - gray tones like training compass
79
  const bgColors = {
80
  sm: 'var(--surface-bg)', // Dark mode ready SM background
81
+ control: colors[0], // Keep categorical colors for components
82
+ registers: colors[1],
83
+ cores: colors[2],
84
+ cache: colors[3]
85
  };
86
 
87
  // Create diagram container
app/src/styles/components/_mermaid.css CHANGED
@@ -2,6 +2,32 @@
2
  color: black !important;
3
  }
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  /* Masquer le flicker pendant la conversion */
6
  .mermaid-zoom-wrapper.converting {
7
  opacity: 0.7;
 
2
  color: black !important;
3
  }
4
 
5
+ .mermaid .cluster-label .nodeLabel {
6
+ color: var(--text-color) !important;
7
+ }
8
+
9
+ /* Styles pour le texte des subgraphs/clusters - gérer les foreignObject */
10
+ .mermaid .cluster-label text,
11
+ .mermaid .cluster-label .nodeLabel text,
12
+ .mermaid .cluster-label foreignObject,
13
+ .mermaid .cluster-label foreignObject div,
14
+ .mermaid .cluster-label foreignObject span {
15
+ color: var(--text-color) !important;
16
+ fill: var(--text-color) !important;
17
+ }
18
+
19
+ /* Styles spécifiques pour les clusters/subgraphs */
20
+ .mermaid .cluster rect {
21
+ fill: transparent !important;
22
+ stroke: var(--border-color) !important;
23
+ stroke-width: 1px !important;
24
+ }
25
+
26
+ .mermaid .cluster-label {
27
+ color: var(--text-color) !important;
28
+ fill: var(--text-color) !important;
29
+ }
30
+
31
  /* Masquer le flicker pendant la conversion */
32
  .mermaid-zoom-wrapper.converting {
33
  opacity: 0.7;