0

Created by potrace 1.16, written by Peter Selinger 2001-2019

Syntax highlighter test

Let me test the syntax highlighter!


function wrapCodeBlocks(content) {
    const tempDiv = document.createElement('div');
    tempDiv.innerHTML = content;
    const codeBlockContainers = tempDiv.querySelectorAll('.ql-code-block-container');
    codeBlockContainers.forEach(container => {
        const preElement = document.createElement('pre');
        const codeElement = document.createElement('code');
        // Add Prism.js classes for syntax highlighting and line numbers
        preElement.classList.add('line-numbers');
        codeElement.classList.add('language-javascript');  // Change language as needed
        // Move each line of code from div.ql-code-block to the code tag
        container.querySelectorAll('.ql-code-block').forEach(codeLine => {
            codeElement.textContent += codeLine.textContent + '\n';
        });
        preElement.appendChild(codeElement);
        // Replace the container with the new pre/code block
        container.replaceWith(preElement);
    });
    // Trigger Prism.js highlighting
    Prism.highlightAll();
    test();
    return tempDiv.innerHTML;
}


Done!

0

Created by potrace 1.16, written by Peter Selinger 2001-2019

Mohammed Imtiyaz

01 October, 2024

Good Job!

if(!this_works){

Let do_this = "again"; }

Mohammed Imtiyaz

01 October, 2024

 // Trigger Prism.js highlighting
    Prism.highlightAll();
    return tempDiv.innerHTML;

Mohammed Imtiyaz

01 October, 2024

Lets do it again.


0

Created by potrace 1.16, written by Peter Selinger 2001-2019

Mohammed Khaled Khan

01 October, 2024

Let me test as well!

function wrapCodeBlocks(content) {
    const tempDiv = document.createElement('div');
    tempDiv.innerHTML = content;
    const codeBlockContainers = tempDiv.querySelectorAll('.ql-code-block-container');
    codeBlockContainers.forEach(container => {
        const preElement = document.createElement('pre');
        const codeElement = document.createElement('code');
        // Add Prism.js classes for syntax highlighting and line numbers
        preElement.classList.add('line-numbers');
        codeElement.classList.add('language-javascript');  // Change language as needed
        // Move each line of code from div.ql-code-block to the code tag
        container.querySelectorAll('.ql-code-block').forEach(codeLine => {
            codeElement.textContent += codeLine.textContent + '\n';
        });
        preElement.appendChild(codeElement);
        // Replace the container with the new pre/code block
        container.replaceWith(preElement);
    });
    // Trigger Prism.js highlighting
    Prism.highlightAll();
    return tempDiv.innerHTML;
}

Mohammed Khaled Khan

01 October, 2024

hi there


    // Trigger Prism.js highlighting
    Prism.highlightAll();
    return tempDiv.innerHTML;

0

Created by potrace 1.16, written by Peter Selinger 2001-2019

Mohammed Khaled Khan

08 October, 2024

Mohammed Imtiyaz testing comment notification!

0

Created by potrace 1.16, written by Peter Selinger 2001-2019

Mohammed Khaled Khan

09 October, 2024

khaled khan test comment!

0

Created by potrace 1.16, written by Peter Selinger 2001-2019

khaled khan

09 October, 2024

Akram Quraishi test comment mention notification!

0

Created by potrace 1.16, written by Peter Selinger 2001-2019

Mohammed Khaled Khan

09 October, 2024

Mohammed Imtiyaz testing mention!

Related Plugins