我想用各種編程語言語言在html頁面中添加示例代碼。在html中添加豐富多彩的示例代碼的最佳方法
<div class="example-cpp">
#include <iostream>
using namespace std;
int main() {
for(; ;) {
printf("This loop will run forever.\n");
}
return 0;
}
</div>
我想用多彩的字體顯示這個沒有獨立的風格。
像下面的例子
你能建議最好的方法嗎?
使用現有的JavaScript庫。就像[highlightjs](https://highlightjs.org/)一樣,僅舉一個例子。 – domsson
或類似的東西https://github.com/google/code-prettify – andrew