Fixed [code=xml] tag syntax highlighting is unusable

    Joined
    Jun 27, 2013
    Messages
    896
    Reaction score
    166
    What the title says...
    XML:
    <tag>can you read the tag's name?</tag>
    vs.
    Code:
    <tag>can you read the tag's name?</tag>
    vs.
    PHP:
    <tag>can you read the tag's name?</tag>
    (looks a bit unhealthy as well...)
    vs.
    HTML:
    <tag>can you read the tag's name?</tag>
     
    Joined
    Jun 27, 2013
    Messages
    896
    Reaction score
    166
    Ahem...

    I have no idea how much effort it would take to modify the respective configurations, but it would be really helpful. The syntax highlighting really helps in my opinion, especially for people who aren't too familiar with a language.
     
    Joined
    Jun 27, 2013
    Messages
    896
    Reaction score
    166
    Black text on dark grey -
    Time passes, my eyesight fades.
    Still no dev input?
     

    DukeofRealms

    Count Duku
    Joined
    Sep 4, 2013
    Messages
    1,477
    Reaction score
    1,617
    • Schine
    Unfortunately, GeSHi doesn't have an easy way to change the colours. They have to be changed manually in each languages' individual file.

    If someone could suggest colours to use for each language, that would at least get part of the work done.
     
    Joined
    Jun 27, 2013
    Messages
    896
    Reaction score
    166
    Unfortunately, GeSHi doesn't have an easy way to change the colours. They have to be changed manually in each languages' individual file.

    If someone could suggest colours to use for each language, that would at least get part of the work done.
    I don't think the colours themselves matter that much, as long as the result is readable.

    Considering that the syntax and grammar of HTML and XML are very similar if not identical, shouldn't it be possible to butcher the HTML file which seems to have a sensible colour table?

    I have no idea how GeSHi definition files are composed, but to be on the safe side, I'd try to analyse the colours used in both the XML and HTML files (and possibly the other definitions as well) to look for colour combinations that don't make sense with the forum's colour scheme, like dark anything on a dark background, and replace them with colours that aren't in use in other places in the same file.
    On the other hand, maybe the GeSHi community has ready-to-use drop-in replacements?
     

    DukeofRealms

    Count Duku
    Joined
    Sep 4, 2013
    Messages
    1,477
    Reaction score
    1,617
    • Schine
    I don't think the colours themselves matter that much, as long as the result is readable.

    Considering that the syntax and grammar of HTML and XML are very similar if not identical, shouldn't it be possible to butcher the HTML file which seems to have a sensible colour table?

    I have no idea how GeSHi definition files are composed, but to be on the safe side, I'd try to analyse the colours used in both the XML and HTML files (and possibly the other definitions as well) to look for colour combinations that don't make sense with the forum's colour scheme, like dark anything on a dark background, and replace them with colours that aren't in use in other places in the same file.
    On the other hand, maybe the GeSHi community has ready-to-use drop-in replacements?
    Are PHP and XML the only formats that need to be changed?
     
    Joined
    Jun 27, 2013
    Messages
    896
    Reaction score
    166
    Are PHP and XML the only formats that need to be changed?
    I have no idea, those are just the two that show dark text in the very incomplete and unvalidated examples above; I mean, PHP doesn't even have anything like a <tag> in the language itself AFAIK, but its string literal shouldn't be dark blue on black either.

    How I would probably go about it would be to pipe the definition files through some sort|grep|awk filters to see what colours are in actual use, and analyse the result for contrast, or something along those lines. Maybe Kupu could give some input on viable colours; however I think the actual colours are of secondary concern, contrast is the primary issue here.
     
    Joined
    Jun 27, 2013
    Messages
    896
    Reaction score
    166
    here is another candidate:
    Bash:
    ls -l -a /path/to/directory/*
    Code:
    ls -l -a /path/to/directory/*

    Since
    https://starmadedock.net/help/bb-codes said:
    CODE=language
    Displays text in 220 programming languages, highlighting the syntax where possible using GeSHi.
    it's a bit like fishing in the dark...
     

    DukeofRealms

    Count Duku
    Joined
    Sep 4, 2013
    Messages
    1,477
    Reaction score
    1,617
    • Schine
    I've edited the following languages to fit the forum: Java, C++, C#, Python, Ruby, CoffeeScript, JavaScript, PHP, SQL, XML, HTML, CSS and Bash.

    Java:
    package org.communitybridge.main;
    
    import java.net.MalformedURLException;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import org.communitybridge.utility.Log;
    
    public class SQL
    {
        private Log log;
        private String host;
        private DatabaseHandler manageDB;
        private String username;
        private String password;
        private String database;
        private String localAddress;
    
        public SQL(Log log, String host, String database, String username, String password, String localAddress)
        {
            this.log = log;
            this.database = database;
            this.host = host;
            this.username = username;
            this.password = password;
            this.localAddress = localAddress;
        }
    
        public boolean initialize()
        {
            this.manageDB = new DatabaseHandler(log, host, database, username, password, localAddress);
            return false;
        }
    
        public ResultSet sqlQuery(String query) throws MalformedURLException, InstantiationException, IllegalAccessException, SQLException
        {
            log.finest(query);
            return this.manageDB.sqlQuery(query);
        }
    
        public void insertQuery(String query) throws MalformedURLException, InstantiationException, IllegalAccessException, SQLException
        {
            log.finest(query);
            this.manageDB.insertQuery(query);
        }
    
        public void updateQuery(String query) throws MalformedURLException, InstantiationException, IllegalAccessException
        {
            log.finest(query);
            this.manageDB.updateQuery(query);
        }
    
        public void deleteQuery(String query) throws MalformedURLException, InstantiationException, IllegalAccessException
        {
            log.finest(query);
            this.manageDB.deleteQuery(query);
        }
    
        public Boolean checkTable(String table) throws MalformedURLException, InstantiationException, IllegalAccessException
        {
            return this.manageDB.checkTable(table);
        }
    
        public Connection getConnection() throws MalformedURLException, InstantiationException, IllegalAccessException
        {
            return this.manageDB.getConnection();
        }
    
        public void close()
        {
            this.manageDB.closeConnection();
        }
    
        public boolean checkConnection()
        {
            return this.manageDB.checkConnection();
        }
    }
    C++:
    /* my second program in C++
       with more comments */
    
    #include <iostream>
    
    int main ()
    {
      std::cout << "Hello World! ";     // prints Hello World!
      std::cout << "I'm a C++ program"; // prints I'm a C++ program
    }
    C#:
    // Hello4.cs
    using System;
    
    public class Hello4
    {
       public static int Main(string[] args)
       {
          Console.WriteLine("Hello, World!");
          return 0;
       }
    }
    Python:
    import itertools
    
    def iter_primes():
         # an iterator of all numbers between 2 and +infinity
         numbers = itertools.count(2)
    
         # generate primes forever
         while True:
             # get the first number from the iterator (always a prime)
             prime = numbers.next()
             yield prime
    
             # this code iteratively builds up a chain of
             # filters...slightly tricky, but ponder it a bit
             numbers = itertools.ifilter(prime.__rmod__, numbers)
    
    for p in iter_primes():
        if p > 1000:
            break
        print p
    Ruby:
    # Takes a JSON string and parses it into an equivalent Ruby value.
    
    require 'rubygems'
    require 'treetop'
    
    
    Treetop.load 'json'
    
    
    class JSONParser
      def initialize
        @parser = JSONHelperParser.new
      end
    
      def parse(input)
        result = @parser.parse(input)
        raise "could not parse" if result.nil?
        result.resolve
      end
    end
    CoffeeScript:
    # Assignment:
    number   = 42
    opposite = true
    
    # Conditions:
    number = -42 if opposite
    
    # Functions:
    square = (x) -> x * x
    
    # Arrays:
    list = [1, 2, 3, 4, 5]
    
    # Objects:
    math =
      root:   Math.sqrt
      square: square
      cube:   (x) -> x * square x
    
    # Splats:
    race = (winner, runners...) ->
      print winner, runners
    
    # Existence:
    alert "I knew it!" if elvis?
    
    # Array comprehensions:
    cubes = (math.cube num for num in list)
    JavaScript:
    const defaults = {
    string: {
    value: '',
    valid: false,
    pristine: true,
    type: 'string'
    },
    bool: {
    value: false,
    type: 'boolean'
    }
    };
    export function getDefaults(type, value) {
    if (!type) {
    return defaults['string'];
    }
    if (value) {
    return Object.assign({}, defaults[type], { value });
    }
    return Object.assign({}, defaults[type]);
    }
    export function isJobValid(job) {
    return job &&
    !job.isFilled &&
    job.isApproved &&
    job.isPaid;
    }
    PHP:
    <?php
    
    $startTime = microtime(true);
    $fileDir = dirname(__FILE__);
    
    require($fileDir . '/library/XenForo/Autoloader.php');
    XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
    
    XenForo_Application::initialize($fileDir . '/library', $fileDir);
    XenForo_Application::set('page_start_time', $startTime);
    
    ####################
    
    
    
    // GET DB
    $db = XenForo_Application::get('db');
    
    // ASSIGN GET PARAMETERS
    $userid = (!empty($_GET['userid']) ? intval($_GET['userid']) : false);
    $username = (!empty($_GET['username']) ? $_GET['username'] : false);
    $size = (!empty($_GET['size']) ? $_GET['size'] : false);
    
    // ENFORCE VALUES FOR SIZE, AND SET DEFAULT 'm'
    $size = (in_array($size, array('s','m','l')) ? $size : 'm');
    
    
    
    // GET USER BY USERID
    if ($userid)
    {
        $user = $db->fetchRow("
            SELECT *
            FROM xf_user
            WHERE user_id = ?
        ", $userid);
    }
    // ELSE GET USER BY USERNAME
    else if ($username)
    {
        $user = $db->fetchRow("
            SELECT *
            FROM xf_user
            WHERE username = ?
        ", $username);
    }
    
    
    
    // USER NOT FOUND, OUTPUT DEFAULT NO GENDER
    if (empty($user['user_id']))
    {
        $file = "./styles/default/xenforo/avatars/avatar_{$size}.png";
        $type = 'image/png';
        header('Content-Type:'.$type);
        header('Content-Length: ' . filesize($file));
        readfile($file);
    
        exit(0);
    }
    
    
    
    // GRAVATARS
    if ($user['gravatar'])
    {
        $avaurl = XenForo_Template_Helper_Core::getAvatarUrl($user, $size);
    
        $file = $avaurl;
        $filecontents = file_get_contents($file);
        $type = 'image/jpeg';
        header('Content-Type:'.$type);
        header('Content-Length: ' . strlen($filecontents));
        echo $filecontents;
    
        exit(0);
    }
    
    
    
    // CUSTOM AVATARS
    if (!empty($user['avatar_date']))
    {
        $avaurl = XenForo_Template_Helper_Core::getAvatarUrl($user, $size, 'custom');
    
        $file = './' . substr($avaurl, 0, strpos($avaurl, '?'));
        $type = 'image/jpeg';
        header('Content-Type:'.$type);
        header('Content-Length: ' . filesize($file));
        readfile($file);
    
        exit(0);
    }
    
    
    
    // DEFAULT AVATARS
    if (true)
    {
        $avaurl = XenForo_Template_Helper_Core::getAvatarUrl($user, $size, 'default');
    
        $file = './' . $avaurl;
        $type = 'image/png';
        header('Content-Type:'.$type);
        header('Content-Length: ' . filesize($file));
        readfile($file);
    
        exit(0);
    }
    SQL:
    /******************************************************************************/
    --- Converting posts...
    /******************************************************************************/
    
    ---* {$to_prefix}messages 200
    ---{
    if(empty($row['id_board']))
        $row['id_board'] = 1;
    $row['poster_time'] = strtotime($row['poster_time']);
    $row['modified_time'] = is_null($row['modified_time']) ? 0 : strtotime($row['modified_time']);
    $row['modified_name'] = is_null($row['modified_name']) ? '' : $row['modified_name'];
    ---}
    SELECT
        p.DiscussionID AS id_topic, t.CategoryID AS id_board,
        p.DateInserted AS poster_time, p.InsertUserID AS id_member, t.Name AS subject,
        IFNULL(m.Name, 'Guest') AS poster_name, IFNULL(m.Email, 'Unknown') AS poster_email, '' AS poster_ip,
        p.DateUpdated AS modified_time, m2.Name AS modified_name, p.Body AS body
    FROM {$from_prefix}Comment AS p
        LEFT JOIN {$from_prefix}Discussion AS t ON (t.DiscussionID = p.DiscussionID)
        LEFT JOIN {$from_prefix}User AS m ON (m.UserID = p.InsertUserID)
        LEFT JOIN {$from_prefix}User AS m2 ON (m2.UserID = p.UpdateUserID)
    WHERE p.CommentID > 0;
    ---*
    XML:
    <?xml version="1.0" encoding="utf-8"?>
    <!--Generated by crowdin.com-->
    <resources>
      <string name="#BLOCK_533_DESCRIPTION">クリスタルを加工して作られる装甲ブロック。
    半透明でガラスのような見た目だが、耐久力は非常に高い。
    
    [ブロックの強度]\n  HP: $HP  ダメージ軽減: $ARMOUR%</string>
    </resources>
    HTML:
    !DOCTYPE html>
    <html>
    <head>
    <title>Page Title</title>
    </head>
    <body>
    
    <h1>This is a Heading</h1>
    <p>This is a paragraph.</p>
    
    </body>
    </html>
    CSS:
     /* {{t|Ambox}} design */
    .ambox {
      font-size: 95%;
      width: 80%;
      margin: 0 auto 2px auto;
      border: 2px solid rgba(255,255,255,0.05);
      border-color: rgb(48,48,60);
      border-left: 10px solid #1e90ff;
      border-collapse: collapse;
      background-color: #191F29;
    }
    Bash:
    #!/bin/bash
    # Starmade Selective upgrade script for BASH.  Please run in the parent or root directory of Starmade
    # Requires curl to be installed
    # Grab the releaseindex as a very long string variable
    echo "This script will install/update StarMade from the master repo.  Use ./update.sh force to force a check on all files"
    read -s -r -p "Press any key to continue..." -n 1 dummy
    if command -v curl >/dev/null
    then
        echo "Curl was found"
        releaseindex=$(curl http://files.star-made.org/releasebuildindex)
    # Go to the end of the variable at the last .
        newversion=${releaseindex##*.}
        echo "newversion $newversion"
    # Get the first version to compare
        cutstring=${newversion#*_}
        NEWSMVERSION1=${cutstring%_*}
        echo "NEWSMVERSION1 $NEWSMVERSION1"
    # Get the second version to compare
        NEWSMVERSION2=${cutstring#*_}
        echo "NEWSMVERSION2 $NEWSMVERSION2"
    # Gather the old version from the version.txt file in StarMade
        oldversion=$(cat StarMade/version.txt)
        if [ -z "$oldversion" ]
        then
            echo "No install found for StarMade"
            OLDSMVER1=0
            OLDSMVER2=0
        else
            echo "oldversion $oldversion"
        # Get the first version to compare
            cutstring=${oldversion#*#}
            OLDSMVER1=${cutstring%_*}
            echo "OLDSMVER1 $OLDSMVER1"
        # Get the second version to compare
            OLDSMVER2=${cutstring#*_}
            echo "OLDSMVER2 $OLDSMVER2"
        fi
    # If the first or second newversion exceeds the first or second old version
        if [ "$NEWSMVERSION1" -gt "$OLDSMVER1" ] || [ "$NEWSMVERSION2" -gt "$OLDSMVER2" ] || [ "$1" = "force" ]
        then
            echo "Newer Version Detected"
    # Set the field seperator to new line and then store the chucksums as an array with each element being a line
            OLD_IFS=$IFS
            IFS=$'\n'
            releaseindex=( $(curl http://files.star-made.org$newversion/checksums) )
            IFS=$OLD_IFS
    # Set line count to 0 then go through the array line by line until the array index is unset     
            LINECOUNT=0
            while [ -n "${releaseindex[$LINECOUNT]+set}" ]
            do
                CURRENTSTRING=${releaseindex[$LINECOUNT]}
                #echo $CURRENTSTRING
    # Format the current line by removing everything after the first space and then removing ./ in the beginning of the name     
                cutstring=${CURRENTSTRING%[[:space:]]*}
                cutstring=${cutstring%[[:space:]]*}
                CURRENTFILE=${cutstring/.\//}
    # Formatfile was added here because when requesting web URL space should be replaced with %20
                FORMATFILE=${CURRENTFILE// /%20}
                cutstring=${CURRENTSTRING%[[:space:]]*}
                cutstring=${cutstring##*[[:space:]]}
                CURRENTCKSUM=${cutstring%%[[:space:]]*}
                OLDCKSUMSTRING=$(cksum "StarMade/$CURRENTFILE")
    # Check to see if OLDCKSUMSTRING is set, if not this indicates the file does not exist
                if [ -z "$OLDCKSUMSTRING" ]
                then
                    echo "No existing file found - downloading file"
    # Makes sure directory structure is created if it does not exist for the file write
                    if [ ! -f "StarMade/$CURRENTFILE" ]; then
                        mkdir -p "StarMade/$CURRENTFILE"
                        rm -r "StarMade/$CURRENTFILE"
                    fi
                    curl "http://files.star-made.org$newversion/$FORMATFILE" > "StarMade/$CURRENTFILE"
                else
                    cutstring=${OLDCKSUMSTRING#*[[:space:]]}
                    OLDCKSUM=${cutstring%%[[:space:]]*}
                    echo "CURRENTFILE $CURRENTFILE CURRENTCKSUM $CURRENTCKSUM OLDCKSUM $OLDCKSUM"
    # Check to see if the cksums differ
                    if [ "$CURRENTCKSUM" -ne "$OLDCKSUM" ]
                    then
    # Download the new file and then copy it into the proper location
                        echo "Updated file detected - downloading file"
    # Makes sure directory structure is created if it does not exist for the file write
                        if [ ! -f "StarMade/$CURRENTFILE" ]; then
                            mkdir -p "StarMade/$CURRENTFILE"
                            rm -r "StarMade/$CURRENTFILE"
                        fi
                        curl "http://files.star-made.org$newversion/$FORMATFILE" > "StarMade/$CURRENTFILE"
                    else
                        echo "Current file detected - no action"
                    fi
                fi
                let LINECOUNT++
            done
    # Added to make sure version.txt is updated.  Sometimes the checksum will match despite the file being different.  This behaviour seems to be limited to very small text files with minor differences that happen to equal each other according to the way checksum calculates file size.
            curl "http://files.star-made.org$newversion/version.txt" > "$CONFIGDTSD_INSTALLPATH/StarMade/version.txt"
        else
            echo "Version Current"
        fi
    else
        echo "You must install Curl to run this"
    fi
     
    • Like
    Reactions: Megacrafter127