New Code Highlighter

  • 0 Replies
  • 556 Views
*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6832
  • 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;
}

 


What's everyone up to ?
by ivan.moony (General Chat)
Today at 04:15:34 am
So what if...
by MagnusWootton (General AI Discussion)
December 06, 2021, 10:07:46 pm
I want one!
by frankinstien (General Chat)
December 03, 2021, 06:57:48 pm
Pattern based NLP
by MikeB (General Project Discussion)
December 03, 2021, 11:19:32 am
New cryopreservation method is much better
by LOCKSUIT (General Chat)
December 02, 2021, 11:42:58 am
Artificial God?
by MagnusWootton (General AI Discussion)
December 01, 2021, 07:02:41 pm
Project Acuitas
by WriterOfMinds (General Project Discussion)
November 29, 2021, 05:31:57 am
java/kotlin to python
by yotamarker (AI Programming)
November 28, 2021, 07:23:54 pm

Users Online

57 Guests, 0 Users

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

Articles