Giter VIP home page Giter VIP logo

codeblock's Introduction

codeblock

Textarea with support for multicolor text.

This library requires JQuery!

Examples:

Just a textarea with no syntax highlighting:

<script src="./codeblock.js"></script>
<div class="codeblock"></div>

This snippet will show any text between quotation marks in this color: #ABCDEF

<script src="./codeblock.js"></script>
<script>
  var name = [{
    'color':'#ABCDEF', 
    'regex':/([\"'])(?:(?=(\\?))\2.)*?\1/g
  }]
</script>
<div syntax="name" class="codeblock">Hello "World"</div>

The syntax highlighting will go through the array top to bottom, and any text that is matched by the regex will not be matchable by the next regex.

Here is another example using an included syntax 'java':

<script src="./codeblock.js"></script>
<div syntax="java" class="codeblock">public static void main(String[] arg) {}</div>

If you don't want the codeblock to be editable, simply add editable="false":

<script src="./codeblock.js"></script>
<div editable="false" syntax="json" class="codeblock"> { "id" : 33, "content" : "This is an example", "ready" : false } </div>

You can also set the text using JavaScript:

<script src="./codeblock.js"></script>
<div id="code" editable="true" syntax="java" class="codeblock"></div>
<script>
  $("#code").setText("String text = \"This text will show up in the codeblock\";");
</script>

This is something quick I have thrown together for a project, if you have any suggestions or see anything that can be optimized feel free to contact me. If you have any questions you can find me on Discord @Kaixo#0001

codeblock's People

Contributors

kaixocode avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.