簡體   English   中英

運行時如何美化html / jsp頁面中的源代碼?

[英]how to beautify source code in html/jsp page while running?

我設計了一個包含一些Java源代碼的網頁。 我把所有這些代碼都放在了塊中。 它來的不錯,但我想使其更加美化。 好像它似乎是一個Java代碼。 這是我的頁面代碼。 (您可以從http://www.concretepage.com/freemarker/freemarker-templateloader-with-multitemplateloader-example進行參考)

有沒有可以美化代碼的JS在線庫或插件? 我頁面的輸出

   <body>
 <div class="container">
<div class="col-xs-12 col-sm-9">
    <div class="row">
           <h2>Heading</h2>
        <p>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>

        <p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
        <pre><code>
  import java.util.Scanner;

  public class CalTest {

  public static void main(String args[]) {
  int a, b;
 float c;
 System.out.println("Enter the First No: ");
 Scanner sc = new Scanner(System.in);
 a = sc.nextInt();
System.out.println("Enter the Second No: ");
b = sc.nextInt();
c = a + b;
 System.out.println("Total =" + c);
  }
   }

             </code></pre>


    </div>
</div>

嘗試使用https://highlightjs.org/ ,您可以通過鍵入javascript庫在Google搜索上突出顯示語法來從字面上找到所需的內容。

有一些庫,例如https://highlightjs.org,該庫只需要將您的代碼放入<pre><code>標記中並運行hljs.initHighlightingOnLoad(); 所以看起來很容易使用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM