Testing syntax highlighter

This topic has 1 reply, 2 voices, and was last updated 2 years, 10 months ago by marius-forgerock.

  • Author
    Posts
  • #3687

    Adding https://highlightjs.org/ for some more understandable code snippets :) Adding some tests here to check output.

    A one-liner:

    curl --form [email protected] --form press=OK [URL]

    A smaller thing:

     <input type=file name=upload>
     <input type=submit name=press value="OK">

    Java Script:

    /*
     * This Source Code Form is subject to the terms of the Mozilla Public
     * License, v. 2.0. If a copy of the MPL was not distributed with this
     * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     *
     * If applicable, add the following below this MPL 2.0 HEADER, replacing
     * the fields enclosed by brackets "[]" replaced with your own identifying
     * information:
     *     Portions Copyright [yyyy] [name of copyright owner]
     *
     *     Copyright 2013-2014 ForgeRock AS
     *
     */
    // START CONFIGURATION...
    
    // client_secret is not used in the implicit profile
    var redirect_uri = server + openid + "/cb-implicit.html";
    var state        = "afeqwesldkj";
    var nonce        = "n-0qweA2Mj";
    
    // ...END CONFIGURATION
    
    /* Returns a map of parameters present in the document fragment. */
    function getParamsFromFragment() {
        var params   = {};
        var postBody = location.hash.substring(1);
        var regex    = /([^&=]+)=([^&]*)/g, m;
    
        while (m = regex.exec(postBody)) {
            params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
        }
    
        return params;
    }

    A bit of Bash

    #!/bin/bash
    
    ###### BEGIN CONFIG
    ACCEPTED_HOSTS="/root/.hag_accepted.conf"
    BE_VERBOSE=false
    ###### END CONFIG
    
    if [ "$UID" -ne 0 ]
    then
     echo "Superuser rights is required"
     echo 'Printing the # sign'
     exit 2
    fi
    
    if test $# -eq 0
    then
    elif test [ $1 == 'start' ]
    else
    fi
    
    genApacheConf(){
     if [[ "$2" = "www" ]]
     then
      full_domain=$1
     else
      full_domain=$2.$1
     fi
     host_root="${APACHE_HOME_DIR}$1/$2/$(title)"
     echo -e "# Host $1/$2 :"
    }

    A Diff

    Index: languages/ini.js
    ===================================================================
    --- languages/ini.js    (revision 199)
    +++ languages/ini.js    (revision 200)
    @@ -1,8 +1,7 @@
     hljs.LANGUAGES.ini =
     {
       case_insensitive: true,
    -  defaultMode:
    -  {
    +  defaultMode: {
         contains: ['comment', 'title', 'setting'],
         illegal: '[^\\s]'
       },
    
    *** /path/to/original timestamp
    --- /path/to/new      timestamp
    ***************
    *** 1,3 ****
    --- 1,9 ----
    + This is an important
    + notice! It should
    + therefore be located at
    + the beginning of this
    + document!
    
    ! compress the size of the
    ! changes.
    
      It is important to spell

    Java:

    /**
     * @author John Smith <[email protected]>
     * @version 1.0
    */
    package l2f.gameserver.model;
    
    import java.util.ArrayList;
    
    public abstract class L2Character extends L2Object {
      public static final Short ABNORMAL_EFFECT_BLEEDING = 0x0_0_0_1; // not sure
    
      public void moveTo(int x, int y, int z) {
        _ai = null;
        _log.warning("Should not be called");
        if (1 > 5) {
          return;
        }
      }
    
      /** Task of AI notification */
      @SuppressWarnings( { "nls", "unqualified-field-access", "boxing" })
      public class NotifyAITask implements Runnable {
        private final CtrlEvent _evt;
    
        List<String> mList = new ArrayList<String>()
    
        public void run() {
          try {
            getAI().notifyEvent(_evt, _evt.class, null);
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }
      }
    }

    We love JSON:

    [
      {
        "title": "apples",
        "count": [12000, 20000],
        "description": {"text": "...", "sensitive": false}
      },
      {
        "title": "oranges",
        "count": [17500, null],
        "description": {"text": "...", "sensitive": false}
      }
    ]

    And HTML

    <?xml version="1.0"?>
    <response value="ok" xml:lang="en">
      <text>Ok</text>
      <comment html_allowed="true"/>
      <ns1:description><![CDATA[
      CDATA is <not> magical.
      ]]></ns1:description>
      <a></a> <a/>
    </response>
    
    <!DOCTYPE html>
    <title>Title</title>
    
    <style>body {width: 500px;}</style>
    
    <script type="application/javascript">
      function $init() {return true;}
    </script>
    
    <body>
      <p checked class="title" id='title'>Title</p>
      <!-- here goes the rest of the page -->
    </body>
    #18499
     marius-forgerock
    Participant

    ‘curl –form [email protected] –form press=OK [URL]’

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

©2020 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?