{"id":1619,"date":"2024-06-04T20:39:13","date_gmt":"2024-06-04T23:39:13","guid":{"rendered":"https:\/\/benjaminray.com\/codebase\/?p=1619"},"modified":"2024-08-12T15:12:25","modified_gmt":"2024-08-12T18:12:25","slug":"testing-highlight-js","status":"publish","type":"post","link":"https:\/\/benjaminray.com\/codebase\/testing-highlight-js\/","title":{"rendered":"Testing Highlight.js"},"content":{"rendered":"<p>Testing command line code hint (cmd):<\/p>\n<pre><code class=\"language-cmd\">rem This is a test\nnetsh delete ipport=0.0.0.0:44369\n<\/code><\/pre>\n<p>Code fence with no lang hint will have language auto-detected by highlight.js:<\/p>\n<div class=\"br-row\">\n<div class=\"br-half-sm\">\n<pre><code class=\"language-nohighlight\">```\nconsole.log(&quot;this is a test&quot;);\n```\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"br-half-sm\">\n<pre><code>console.log(&quot;this is a test&quot;);\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>Code fence with valid lang hint:<\/p>\n<div class=\"br-row\">\n<div class=\"br-half-sm\">\n<pre><code class=\"language-nohighlight\">```js\nconsole.log(&quot;this is a test&quot;);\n```\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"br-half-sm\">\n<pre><code class=\"language-js\">console.log(&quot;this is a test&quot;);\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>Code fence with invalid lang hint:<\/p>\n<div class=\"br-row\">\n<div class=\"br-half-sm\">\n<pre><code class=\"language-nohighlight\">```pastry7\nconsole.log(&quot;this is a test&quot;);\n```\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"br-half-sm\">\n<pre><code class=\"language-pastry7\">console.log(&quot;this is a test&quot;);\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>Custom: No highlighting on code fence with lang hint &quot;nohighlight&quot;:<\/p>\n<div class=\"br-row\">\n<div class=\"br-half-sm\">\n<pre><code class=\"language-nohighlight\">```nohighlight\nconsole.log(&quot;this is a test&quot;);\n```\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"br-half-sm\">\n<pre><code class=\"language-nohighlight\">console.log(&quot;this is a test&quot;);\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>Code fence with special lang hint &quot;naked&quot; which excludes the code from highlighting and no pre background:<\/p>\n<div class=\"br-row\">\n<div class=\"br-half-sm\">\n<p>Input:<\/p>\n<pre>\n```naked\nconst testVar = \"test value\";\nconsole.log(\"testVar\", testVar);\n```\n<\/pre>\n<\/p><\/div>\n<div class=\"br-half-sm\">\n<p>Output:<\/p>\n<pre><code class=\"language-naked\">const testVar = &quot;test value&quot;;\nconsole.log(&quot;testVar&quot;, testVar);\n<\/code><\/pre>\n<\/div>\n<\/div>\n<h2>Legacy Stuff<\/h2>\n<p>Legacy Custom: No highlighting on code fence with lang hint &quot;noprettyprint&quot;:<\/p>\n<div class=\"br-row\">\n<div class=\"br-half-sm\">\n<pre><code class=\"language-nohighlight\">```noprettyprint\nconsole.log(&quot;this is a test&quot;);\n```\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"br-half-sm\">\n<pre><code class=\"language-noprettyprint\">console.log(&quot;this is a test&quot;);\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>Legacy Custom: No highlighting on PRE tag with class &quot;noprettyprint&quot; (without code tag):<\/p>\n<div class=\"br-row\">\n<div class=\"br-half-sm\">\n<pre><code class=\"language-nohighlight\">&lt;pre class=&quot;noprettyprint&quot;&gt;\nvar s = 'some test';\nconsole.log(s);\n&lt;\/pre&gt;\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"br-half-sm\">\n<pre class=\"noprettyprint\">\nvar s = 'some test';\nconsole.log(s);\n<\/pre>\n<\/div>\n<\/div>\n<p>Legacy Custom: No highlighting on PRE tag with class &quot;noprettyprint&quot; (with code tag):<\/p>\n<div class=\"br-row\">\n<div class=\"br-half-sm\">\n<pre><code class=\"language-nohighlight\">&lt;pre class=&quot;noprettyprint&quot;&gt;&lt;code&gt;var s = 'some test';\nconsole.log(s);\n&lt;\/code&gt;&lt;\/pre&gt;\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"br-half-sm\">\n<pre class=\"noprettyprint\"><code>var s = 'some test';\nconsole.log(s);\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>Legacy Custom: No highlighting on CODE tag with class &quot;noprettyprint&quot;:<\/p>\n<div class=\"br-row\">\n<div class=\"br-half-sm\">\n<pre><code class=\"language-nohighlight\">&lt;pre&gt;&lt;code class=&quot;noprettyprint&quot;&gt;var s = 'some test';\nconsole.log(s);\n&lt;\/code&gt;&lt;\/pre&gt;\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"br-half-sm\">\n<pre><code class=\"noprettyprint\">var s = 'some test';\nconsole.log(s);\n<\/code><\/pre>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Testing command line code hint (cmd): rem This is a test netsh delete ipport=0.0.0.0:44369 Code fence with no lang hint will have language auto-detected by highlight.js: &#8220;` console.log(&quot;this is a  [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-1619","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9GNjN-q7","jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/posts\/1619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/comments?post=1619"}],"version-history":[{"count":109,"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/posts\/1619\/revisions"}],"predecessor-version":[{"id":2523,"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/posts\/1619\/revisions\/2523"}],"wp:attachment":[{"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/media?parent=1619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/categories?post=1619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benjaminray.com\/codebase\/wp-json\/wp\/v2\/tags?post=1619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}