我想用各种编程语言语言在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