CodeMirror Doesn't Display HTML Mode












1















I am trying to use CodeMirror modes in my web application, but it won't highlight the words for the mode "htmlmixed". I don't understand what is going wrong. The paths to each file are correct because I am not getting any 404 errors. Here is what I did:



<!DOCTYPE html>
<head>
<script src="/node_modules/codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="/path-to/codemirror/lib/codemirror.css">
<script src="/path-to/codemirror/lib/codemirror.js"></script>
<script src="/path-to/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script src="/path-to/jquery.min.js"></script>
</head>
<html>
<textarea id="editor"></textarea>
....
</html>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
lineNumbers: true,
mode: "htmlmixed",
htmlMode: true,
});
</script>


Any help would be greatly appreciated!



Thank you!










share|improve this question

























  • <link rel="stylesheet" href="/path-to/codemirror/lib/codemirror.css"> Is this an actual path?

    – ksav
    Nov 23 '18 at 19:56











  • Hi ksav, I just revised the path for simplicity here. The path in my actual code is correct.

    – CodeRocks
    Nov 23 '18 at 19:59


















1















I am trying to use CodeMirror modes in my web application, but it won't highlight the words for the mode "htmlmixed". I don't understand what is going wrong. The paths to each file are correct because I am not getting any 404 errors. Here is what I did:



<!DOCTYPE html>
<head>
<script src="/node_modules/codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="/path-to/codemirror/lib/codemirror.css">
<script src="/path-to/codemirror/lib/codemirror.js"></script>
<script src="/path-to/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script src="/path-to/jquery.min.js"></script>
</head>
<html>
<textarea id="editor"></textarea>
....
</html>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
lineNumbers: true,
mode: "htmlmixed",
htmlMode: true,
});
</script>


Any help would be greatly appreciated!



Thank you!










share|improve this question

























  • <link rel="stylesheet" href="/path-to/codemirror/lib/codemirror.css"> Is this an actual path?

    – ksav
    Nov 23 '18 at 19:56











  • Hi ksav, I just revised the path for simplicity here. The path in my actual code is correct.

    – CodeRocks
    Nov 23 '18 at 19:59
















1












1








1








I am trying to use CodeMirror modes in my web application, but it won't highlight the words for the mode "htmlmixed". I don't understand what is going wrong. The paths to each file are correct because I am not getting any 404 errors. Here is what I did:



<!DOCTYPE html>
<head>
<script src="/node_modules/codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="/path-to/codemirror/lib/codemirror.css">
<script src="/path-to/codemirror/lib/codemirror.js"></script>
<script src="/path-to/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script src="/path-to/jquery.min.js"></script>
</head>
<html>
<textarea id="editor"></textarea>
....
</html>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
lineNumbers: true,
mode: "htmlmixed",
htmlMode: true,
});
</script>


Any help would be greatly appreciated!



Thank you!










share|improve this question
















I am trying to use CodeMirror modes in my web application, but it won't highlight the words for the mode "htmlmixed". I don't understand what is going wrong. The paths to each file are correct because I am not getting any 404 errors. Here is what I did:



<!DOCTYPE html>
<head>
<script src="/node_modules/codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="/path-to/codemirror/lib/codemirror.css">
<script src="/path-to/codemirror/lib/codemirror.js"></script>
<script src="/path-to/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script src="/path-to/jquery.min.js"></script>
</head>
<html>
<textarea id="editor"></textarea>
....
</html>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
lineNumbers: true,
mode: "htmlmixed",
htmlMode: true,
});
</script>


Any help would be greatly appreciated!



Thank you!







javascript jquery html css codemirror






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 20:22







CodeRocks

















asked Nov 23 '18 at 19:39









CodeRocksCodeRocks

515




515













  • <link rel="stylesheet" href="/path-to/codemirror/lib/codemirror.css"> Is this an actual path?

    – ksav
    Nov 23 '18 at 19:56











  • Hi ksav, I just revised the path for simplicity here. The path in my actual code is correct.

    – CodeRocks
    Nov 23 '18 at 19:59





















  • <link rel="stylesheet" href="/path-to/codemirror/lib/codemirror.css"> Is this an actual path?

    – ksav
    Nov 23 '18 at 19:56











  • Hi ksav, I just revised the path for simplicity here. The path in my actual code is correct.

    – CodeRocks
    Nov 23 '18 at 19:59



















<link rel="stylesheet" href="/path-to/codemirror/lib/codemirror.css"> Is this an actual path?

– ksav
Nov 23 '18 at 19:56





<link rel="stylesheet" href="/path-to/codemirror/lib/codemirror.css"> Is this an actual path?

– ksav
Nov 23 '18 at 19:56













Hi ksav, I just revised the path for simplicity here. The path in my actual code is correct.

– CodeRocks
Nov 23 '18 at 19:59







Hi ksav, I just revised the path for simplicity here. The path in my actual code is correct.

– CodeRocks
Nov 23 '18 at 19:59














1 Answer
1






active

oldest

votes


















1














The htmlmixed mode depends on the xml, javascript, and css modes. They must be included for htmlmixed to work.



Here is an example:






var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
lineNumbers: true,
mode: "htmlmixed",
htmlMode: true,
});

<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/htmlmixed/htmlmixed.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/xml/xml.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/javascript/javascript.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/css/css.js"></script>
</head>
<html>
<textarea id="editor">&lt;p&gt; I am HTML&lt;/p&gt;
&lt;script&gt;
console.log(&quot;I am JS&quot;);
&lt;/script&gt;</textarea>
</html>








share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452168%2fcodemirror-doesnt-display-html-mode%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The htmlmixed mode depends on the xml, javascript, and css modes. They must be included for htmlmixed to work.



    Here is an example:






    var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
    lineNumbers: true,
    mode: "htmlmixed",
    htmlMode: true,
    });

    <head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/htmlmixed/htmlmixed.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/xml/xml.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/javascript/javascript.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/css/css.js"></script>
    </head>
    <html>
    <textarea id="editor">&lt;p&gt; I am HTML&lt;/p&gt;
    &lt;script&gt;
    console.log(&quot;I am JS&quot;);
    &lt;/script&gt;</textarea>
    </html>








    share|improve this answer




























      1














      The htmlmixed mode depends on the xml, javascript, and css modes. They must be included for htmlmixed to work.



      Here is an example:






      var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
      lineNumbers: true,
      mode: "htmlmixed",
      htmlMode: true,
      });

      <head>
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.css" />
      <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/htmlmixed/htmlmixed.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/xml/xml.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/javascript/javascript.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/css/css.js"></script>
      </head>
      <html>
      <textarea id="editor">&lt;p&gt; I am HTML&lt;/p&gt;
      &lt;script&gt;
      console.log(&quot;I am JS&quot;);
      &lt;/script&gt;</textarea>
      </html>








      share|improve this answer


























        1












        1








        1







        The htmlmixed mode depends on the xml, javascript, and css modes. They must be included for htmlmixed to work.



        Here is an example:






        var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
        lineNumbers: true,
        mode: "htmlmixed",
        htmlMode: true,
        });

        <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.css" />
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/htmlmixed/htmlmixed.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/xml/xml.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/javascript/javascript.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/css/css.js"></script>
        </head>
        <html>
        <textarea id="editor">&lt;p&gt; I am HTML&lt;/p&gt;
        &lt;script&gt;
        console.log(&quot;I am JS&quot;);
        &lt;/script&gt;</textarea>
        </html>








        share|improve this answer













        The htmlmixed mode depends on the xml, javascript, and css modes. They must be included for htmlmixed to work.



        Here is an example:






        var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
        lineNumbers: true,
        mode: "htmlmixed",
        htmlMode: true,
        });

        <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.css" />
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/htmlmixed/htmlmixed.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/xml/xml.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/javascript/javascript.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/css/css.js"></script>
        </head>
        <html>
        <textarea id="editor">&lt;p&gt; I am HTML&lt;/p&gt;
        &lt;script&gt;
        console.log(&quot;I am JS&quot;);
        &lt;/script&gt;</textarea>
        </html>








        var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
        lineNumbers: true,
        mode: "htmlmixed",
        htmlMode: true,
        });

        <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.css" />
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/htmlmixed/htmlmixed.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/xml/xml.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/javascript/javascript.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/css/css.js"></script>
        </head>
        <html>
        <textarea id="editor">&lt;p&gt; I am HTML&lt;/p&gt;
        &lt;script&gt;
        console.log(&quot;I am JS&quot;);
        &lt;/script&gt;</textarea>
        </html>





        var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
        lineNumbers: true,
        mode: "htmlmixed",
        htmlMode: true,
        });

        <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.css" />
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/htmlmixed/htmlmixed.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/xml/xml.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/javascript/javascript.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/mode/css/css.js"></script>
        </head>
        <html>
        <textarea id="editor">&lt;p&gt; I am HTML&lt;/p&gt;
        &lt;script&gt;
        console.log(&quot;I am JS&quot;);
        &lt;/script&gt;</textarea>
        </html>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 20:42









        asemahleasemahle

        8,44332631




        8,44332631






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452168%2fcodemirror-doesnt-display-html-mode%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Berounka

            Sphinx de Gizeh

            Different font size/position of beamer's navigation symbols template's content depending on regular/plain...