{"id":1783,"date":"2024-11-10T14:04:25","date_gmt":"2024-11-10T06:04:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1783\/"},"modified":"2024-11-10T14:04:25","modified_gmt":"2024-11-10T06:04:25","slug":"%e4%bd%bf%e7%94%a8highlight-js%e5%ba%93%e5%a6%82%e4%bd%95%e4%b8%bahtml%e6%ba%90%e4%bb%a3%e7%a0%81%e6%b7%bb%e5%8a%a0%e8%a1%8c%e5%8f%b7%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1783\/","title":{"rendered":"\u4f7f\u7528highlight.js\u5e93\u5982\u4f55\u4e3aHTML\u6e90\u4ee3\u7801\u6dfb\u52a0\u884c\u53f7\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173055960557982.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528highlight.js\u5e93\u5982\u4f55\u4e3aHTML\u6e90\u4ee3\u7801\u6dfb\u52a0\u884c\u53f7\uff1f\u63d2\u56fe\" alt=\"\u4f7f\u7528highlight.js\u5e93\u5982\u4f55\u4e3aHTML\u6e90\u4ee3\u7801\u6dfb\u52a0\u884c\u53f7\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528highlightjs\u6dfb\u52a0html\u6e90\u4ee3\u7801\u884c\u53f7<\/strong><\/p>\n<p>\u5728\u751f\u6210\u5e26\u884c\u53f7\u7684HTML\u6e90\u4ee3\u7801\u65f6\uff0c\u4f7f\u7528highlightjs\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u56f0\u96be\u3002\u4ee5\u4e0b\u662f\u5728\u4f7f\u7528highlight.js\u5e93\u6dfb\u52a0\u884c\u53f7\u7684\u6b63\u786e\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u4e3a\u4e86\u5b9e\u73b0\u6b64\u529f\u80fd\uff0c\u9700\u8981\u8865\u5145\u6837\u5f0f\u4ee5\u521b\u5efa\u884c\u53f7\u5bb9\u5668\u548c\u5176\u4ed6\u5fc5\u8981\u7684\u6837\u5f0f\u3002<\/li>\n<li>\u5728\u6807\u7b7e\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u6837\u5f0f\uff1a<\/li>\n<\/ol>\n<pre>&lt;pre class=\"brush:php;toolbar:false\"&gt; {\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}\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u4e3a\u4e86\u4f7f\u7528highlight.js\u5e93\u7684\u9ad8\u4eae\u529f\u80fd\uff0c\u5728\u6807\u7b7e\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u811a\u672c\uff1a<\/li>\n<\/ol>\n<pre>&lt;link rel=\"stylesheet\" href=\"http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/11.7.0\/styles\/default.min.css\"&gt;\n&lt;script src=\"http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/11.7.0\/highlight.min.js\"&gt;&lt;\/script&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u5728\u6807\u7b7e\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u811a\u672c\u4ee5\u6dfb\u52a0\u884c\u53f7\uff1a<\/li>\n<\/ol>\n<pre>&lt;script&gt;\n    hljs.highlightAll();\n    $(function () {\n        $('pre code').each(function () {\n            var lines = $(this).text().split('\n').length - 1;\n            var $numbering = $(' &lt;ul&gt;&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;&lt;\/li&gt;').text(i));\n            }\n        });\n    });\n&lt;\/script&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u73b0\u5728\u53ef\u4ee5\u5728\u4f7f\u7528highlight.js\u5e93\u65f6\u6dfb\u52a0\u884c\u53f7\u5230HTML\u6e90\u4ee3\u7801\u4e2d\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528highlight.js\u5e93\u5982\u4f55\u4e3aHTML\u6e90\u4ee3\u7801\u6dfb\u52a0\u884c\u53f7\uff1f\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>\u4f7f\u7528highlightjs\u6dfb\u52a0html\u6e90\u4ee3\u7801\u884c\u53f7 \u5728\u751f\u6210\u5e26\u884c\u53f7\u7684HTML\u6e90\u4ee3\u7801\u65f6\uff0c\u4f7f\u7528highlightjs\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u56f0\u96be\u3002\u4ee5\u4e0b\u662f\u5728\u4f7f\u7528highlight.js\u5e93\u6dfb\u52a0\u884c\u53f7\u7684\u6b63\u786e\u6b65\u9aa4\uff1a \u4e3a\u4e86\u5b9e\u73b0\u6b64\u529f\u80fd\uff0c\u9700\u8981\u8865\u5145\u6837\u5f0f\u4ee5\u521b\u5efa\u884c\u53f7\u5bb9\u5668\u548c\u5176\u4ed6\u5fc5\u8981\u7684\u6837\u5f0f\u3002 \u5728\u6807\u7b7e\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u6837\u5f0f\uff1a &lt;pre class=&#8221;brush:php;toolbar:false&#8221;&gt; { 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; left: 0; width: 20px; padding: [&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-1783","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1783","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=1783"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1783\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}