{"id":1825,"date":"2024-11-10T08:29:35","date_gmt":"2024-11-10T00:29:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1825\/"},"modified":"2024-11-10T08:29:35","modified_gmt":"2024-11-10T00:29:35","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-highlight-js-%e5%9c%a8-html-%e4%bb%a3%e7%a0%81%e5%9d%97%e4%b8%ad%e6%b7%bb%e5%8a%a0%e8%a1%8c%e5%8f%b7","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1825\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 Highlight.js \u5728 HTML \u4ee3\u7801\u5757\u4e2d\u6dfb\u52a0\u884c\u53f7?"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173059903569746.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 Highlight.js \u5728 HTML \u4ee3\u7801\u5757\u4e2d\u6dfb\u52a0\u884c\u53f7?\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 Highlight.js \u5728 HTML \u4ee3\u7801\u5757\u4e2d\u6dfb\u52a0\u884c\u53f7?\u63d2\u56fe\" \/><\/p>\n<p>\u5982\u4f55\u5728\u5411 html \u6e90\u4ee3\u7801\u6dfb\u52a0\u884c\u53f7\u65f6\uff0c\u4f7f\u7528 highlight.js<\/p>\n<p>\u4f7f\u7528 Highlight.js \u80fd\u591f\u8ba9\u4f60\u7ed9\u4ee3\u7801\u5757\u6dfb\u52a0\u884c\u53f7\uff0c\u4f46\u4f60\u9700\u8981\u6267\u884c\u4e00\u4e9b\u989d\u5916\u6b65\u9aa4\u3002<\/p>\n<p><strong>\u6b63\u786e\u7684\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u5c06\u4ee5\u4e0b\u6837\u5f0f\u6dfb\u52a0\u5230\u4f60\u7684 <\/p>\n<p> \u6807\u7b7e\u4e2d\uff1a <\/p>\n<pre>pre {\n  position: relative;\n  margin-bottom: 24px;\n  border-radius: 3px;\n  border: 1px solid #C3CCD0;\n  background: #FFF;\n  overflow: hidden;\n}\n\ncode {\n  display: block;\n  padding: 12px 24px;\n  overflow-y: auto;\n  font-weight: 300;\n  font-family: Menlo, monospace;\n  font-size: 0.8em;\n}\n\ncode.has-numbering {\n  margin-left: 21px;\n}\n\n.pre-numbering {\n  position: absolute;\n  top: 0;\n  left: 0;\n  width: 20px;\n  padding: 12px 2px 12px 0;\n  border-right: 1px solid #C3CCD0;\n  border-radius: 3px 0 0 3px;\n  background-color: #EEE;\n  text-align: right;\n  font-family: Menlo, monospace;\n  font-size: 0.8em;\n  color: #AAA;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7136\u540e\uff0c\u5728 HTML \u4e2d\uff0c\u5c06 class=&#8221;language-html&#8221; \u6dfb\u52a0\u5230\u4f60\u7684\u4ee3\u7801\u5757\u4e2d\uff0c\u5e76\u5728\u4ee3\u7801\u5757\u7684\u7236\u6807\u7b7e\u7684\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>$(function () {\n  $('pre code').each(function () {\n    var lines = $(this).text().split('\n').length - 1;\n    var $numbering = $('&lt;ul\/&gt;').addClass('pre-numbering');\n    $(this)\n      .addClass('has-numbering')\n      .parent()\n      .append($numbering);\n    for (i = 1; i &lt;= lines; i++) {\n      $numbering.append($('&lt;li\/&gt;').text(i));\n    }\n  });\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6837\uff0c\u4f60\u7684\u4ee3\u7801\u5757\u5c31\u4f1a\u5e26\u6709\u6570\u5b57\u884c\u53f7\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 Highlight.js \u5728 HTML \u4ee3\u7801\u5757\u4e2d\u6dfb\u52a0\u884c\u53f7?\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5728\u5411 html \u6e90\u4ee3\u7801\u6dfb\u52a0\u884c\u53f7\u65f6\uff0c\u4f7f\u7528 highlight.js \u4f7f\u7528 Highlight.js \u80fd\u591f\u8ba9\u4f60\u7ed9\u4ee3\u7801\u5757\u6dfb\u52a0\u884c\u53f7\uff0c\u4f46\u4f60\u9700\u8981\u6267\u884c\u4e00\u4e9b\u989d\u5916\u6b65\u9aa4\u3002 \u6b63\u786e\u7684\u65b9\u6cd5\uff1a \u5c06\u4ee5\u4e0b\u6837\u5f0f\u6dfb\u52a0\u5230\u4f60\u7684 \u6807\u7b7e\u4e2d\uff1a pre { position: relative; margin-bottom: 24px; border-radius: 3px; border: 1px solid #C3CCD0; background: #FFF; overflow: hidden; } code { display: block; padding: 12px 24px; overflow-y: auto; font-weight: 300; font-family: Menlo, monospace; font-size: 0.8em; } code.has-numbering { margin-left: 21px; } .pre-numbering { position: absolute; top: 0; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1825","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1825","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1825"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1825\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}