Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to embed a code editor in a page?

Problem

I want to create a page with a code editor embedded in it.I looked up codemirror
but i am having problems using it as i am new to java script.

So I am looking for an easy way to embed a code editor into a page(using java script or python).Can someone please provide some link/tutorial or method for it.

like image 891
sashas Avatar asked Jun 12 '13 11:06

sashas


People also ask

How do I embed code in HTML?

Highlight the embed code, then copy it to your clipboard. In your content management system, open up your HTML viewer. Paste the HTML snippet you just copied into your HTML viewer window. Then click 'OK' or 'Save.


2 Answers

Try Ace: https://github.com/ajaxorg/ace (source) https://ace.c9.io/ (Project page), this JavaScript editor is used by Cloud9

like image 179
Jakub Truneček Avatar answered Oct 08 '22 03:10

Jakub Truneček


I know this is old post , This is how i did while developing online code-editor you can use ace-editor

check this sample from ace

<html lang="en">
<head>
<title>ACE in Action</title>
<style type="text/css" media="screen">
    #editor { 
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }
</style>
</head>
<body>

<div id="editor">function foo(items) {
    var x = "All this is syntax highlighted";
    return x;
}</div>
    
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.5/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
    var editor = ace.edit("editor");
    editor.setTheme("ace/theme/monokai");
    editor.session.setMode("ace/mode/javascript");
</script>
</body>
</html>
like image 23
Sai Kumar Avatar answered Oct 08 '22 03:10

Sai Kumar