← Tous les exemples

Action Développeur & QA notion.so

Copier la page en Markdown

Récupère les titres, paragraphes et listes et les copie en Markdown.

Code à copier

(function () {
  try {
    var content = document.querySelector('.notion-page-content');
    if (!content) { alert('No page content found.'); return; }
    var lines = [];
    content.querySelectorAll('.notion-text-block, .notion-header-block, .notion-sub_header-block, .notion-sub_sub_header-block, .notion-bulleted_list-block, .notion-numbered_list-block').forEach(function (b) {
      var t = (b.innerText || '').trim();
      if (!t) return;
      if (b.classList.contains('notion-header-block')) lines.push('# ' + t);
      else if (b.classList.contains('notion-sub_header-block')) lines.push('## ' + t);
      else if (b.classList.contains('notion-sub_sub_header-block')) lines.push('### ' + t);
      else if (b.classList.contains('notion-bulleted_list-block')) lines.push('- ' + t);
      else if (b.classList.contains('notion-numbered_list-block')) lines.push('1. ' + t);
      else lines.push(t);
    });
    var md = lines.join('\n\n');
    if (!md) { alert('No content to copy.'); return; }
    if (navigator.clipboard && navigator.clipboard.writeText) {
      navigator.clipboard.writeText(md).then(function () { alert('Copied page as Markdown.'); });
    } else {
      var ta = document.createElement('textarea');
      ta.value = md; document.body.appendChild(ta); ta.select();
      document.execCommand('copy'); ta.remove();
      alert('Copied page as Markdown.');
    }
  } catch (e) { alert('Could not copy as Markdown: ' + e.message); }
})();

Comment utiliser cet exemple

  1. Copiez le code avec le bouton ci-dessus.
  2. Installez JustZix (2 minutes) et ouvrez l'extension sur la page cible.
  3. Ajoutez une nouvelle règle correspondant à cette page.
  4. Activez le panneau d'actions, ajoutez un bouton dans l'onglet Actions et collez-y le code — lancez-le en un clic.

Notez cet exemple

Aucune note — soyez le premier.

Cet exemple fonctionne-t-il ?

Les snippets sont inutiles sans un endroit où les coller.

JustZix s'installe en 2 minutes et exécute votre code sur chaque page correspondante. Sans compte, sans paiement.

Télécharger gratuitement Voir les cas d'usage