New Code Highlighter

  • 0 Replies
  • 2115 Views
*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6860
  • Mostly Harmless
New Code Highlighter
« on: May 14, 2020, 03:12:44 pm »
The old code highlighter broke a while back I noticed, so I have found a new mod to do this.

It seems a lot better than the hit and miss old one and uses a library that is frequently updated.

Also, now when you preview the code it will be colour highlighted - the old method did not do that.

I came up with the colour scheme myself, hope it's acceptable :)

Just testing a few.

PHP:

Code
function randomDigits($numDigits) {
    if ($numDigits <= 0) {
        return '';
    }

    return mt_rand(0, 9) . randomDigits($numDigits - 1);
}

// Or an iterative approach
function randomDigitsLame($numDigits) {
    $digits = '';

    for ($i = 0; $i < $numDigits; ++$i) {
        $digits .= mt_rand(0, 9);
    }

    return $digits;
}

$maxq = 20;

for ($i = 1; $i <= $maxq; $i++) {
    echo $i . "<br>\n";
    echo randomDigits($i) . "<br>\n----<br>\n";
}

HTML:

Code
<div class="topbar-dialog siteSwitcher-dialog dno" role="menu">
        <div class="header">
            <h3>
                <a href="https://stackoverflow.com">current community</a>
            </h3>
        </div>
        <div class="modal-content bg-powder-050">
            <ul class="current-site">
                    <li class="grid">
                            <div class="fl1">
                <a href="https://stackoverflow.com"
       class="current-site-link site-link js-gps-track grid gs8 gsx"
       data-id="1"
       data-gps-track="site_switcher.click({ item_type:3 })">
        <div class="favicon favicon-stackoverflow site-icon grid--cell" title="Stack Overflow"></div>
        <span class="grid--cell fl1">
            Stack Overflow
        </span>
    </a>
</div>

CSS:

Code
html, body {
    height: 100%;
}
.parent {
    width: 100%;
    height: 100%;
    display: table;
    text-align: center;
}
.parent > .child {
    display: table-cell;
    vertical-align: middle;
}

 


Who's the AI?
by frankinstien (Future of AI)
November 04, 2024, 05:45:05 am
Will LLMs ever learn what is ... is?
by frankinstien (Future of AI)
November 03, 2024, 08:11:00 pm
Project Acuitas
by WriterOfMinds (General Project Discussion)
October 27, 2024, 09:17:10 pm
Ai improving AI
by infurl (AI Programming)
October 19, 2024, 03:43:29 am
Atronach's Eye
by WriterOfMinds (Home Made Robots)
October 13, 2024, 09:52:42 pm
Running local AI models
by spydaz (AI Programming)
October 07, 2024, 09:00:53 am
Hi IM BAA---AAACK!!
by MagnusWootton (Home Made Robots)
September 16, 2024, 09:49:10 pm
Attempting Hydraulics
by MagnusWootton (Home Made Robots)
August 19, 2024, 04:03:23 am
LLaMA2 Meta's chatbot released
by spydaz (AI News )
August 24, 2024, 02:58:36 pm
ollama and llama3
by spydaz (AI News )
August 24, 2024, 02:55:13 pm
AI controlled F-16, for real!
by frankinstien (AI News )
June 15, 2024, 05:40:28 am
Open AI GPT-4o - audio, vision, text combined reasoning
by MikeB (AI News )
May 14, 2024, 05:46:48 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am

Users Online

244 Guests, 0 Users

Most Online Today: 357. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles