0

I am trying to embed a pretty formatted code in a div but it fails to break the code into new line and possibly into tabs, has copied. I am using this code from here to test both php and html pretty formatted code in the div (Submitting form, mysql and php) I am using the example from highlightjs but it seems not to work for me. (How to format code in html / css / js/ php) Here are my html output formats: ResultView and HTMLCSSView

I also added this script above the body closing tag html document

<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script>
<script>
hljs.initHighlightingOnLoad();
</script>

With the css link in the head tag

    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/default.min.css">

How Can I make this work perfectly?

Community
  • 1
  • 1

1 Answers1

0

You're missing the http: or https: part of the URL - currently, your file links look like this:

//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js

//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/default.min.css">

Change your links to look like this:

<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/default.min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script>

And your code will work.

Jack Bashford
  • 43,180
  • 11
  • 50
  • 79
  • I changed it but still remains the same. I have seen where links and scripts are used in such manner I did and it usually shows up in the developer tools that the library is present - for confirmation. – Adeniran Adeniyi Dec 09 '18 at 01:41
  • Well now your libraries are linked - maybe look into the `
    ` tag for retaining whitespace in code formatting.
    – Jack Bashford Dec 09 '18 at 01:49
  • it wasn't working because I was using the input tag to store the data in the database. That was why the pre tag could not do anything about it. I guess the input tag just made it a one-line format when I pasted my code on in it. I change the Input tag to a textarea tag to solve the issue. – Adeniran Adeniyi Dec 12 '18 at 06:22