{"id":234,"date":"2019-03-25T19:52:50","date_gmt":"2019-03-25T19:52:50","guid":{"rendered":"http:\/\/www.hoopchuk.org\/wordpress\/?page_id=234"},"modified":"2019-04-25T19:04:36","modified_gmt":"2019-04-25T19:04:36","slug":"code-template","status":"publish","type":"page","link":"https:\/\/www.hoopchuk.org\/wordpress\/code-template\/","title":{"rendered":"Code Template"},"content":{"rendered":"<h1>Summary<\/h1>\n<p>Ross&#8217;s &#8220;template for code stuff&#8221;.<\/p>\n<p>I&#8217;ll also try to document what plugins I&#8217;m using via examples in this.<\/p>\n<h1>TODOs<\/h1>\n<p>There are at least two &#8220;TODOs&#8221; I can think of on 25MAR2019MON:<\/p>\n<ol>\n<li>One<\/li>\n<li>Two<\/li>\n<\/ol>\n<h1>Code Editor<\/h1>\n<p>I have wasted much time trying to override WordPress&#8217;s stupid &#8220;change my code&#8221; in the &#8220;Visual Editor&#8221;.<\/p>\n<p>The easy solution is to just use the &#8220;Code Editor&#8221; on pages that might need it like this one.<\/p>\n<p>This is a huge kludge but I just created a user called &#8220;code&#8221; that I turned off the &#8220;Visual Editor&#8221; via &#8220;User Profile&#8221; like:<\/p>\n<pre>Visual Editor  _X_ Disable the visual editor when writing\n<\/pre>\n<h1>Displaying Source Code<\/h1>\n<p>You&#8217;re going to want to check out for all the cool details:<\/p>\n<ol>\n<li><a href=\"https:\/\/help.edublogs.org\/syntaxhighlighter-evolved-plugin\/\">https:\/\/help.edublogs.org\/syntaxhighlighter-evolved-plugin\/<\/a><\/li>\n<\/ol>\n<p>For displaying source code I use &#8220;SyntaxHighlighter Evolved&#8221; like:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;!--?php\necho \u201cHello World\u201d;\n?--&gt;\n<\/pre>\n<p>And the source for that looks like:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;&#x5B;php]\n&lt;!--?php\necho \u201cHello World\u201d;\n?--&gt;\n&#x5B;\/php]]\n<\/pre>\n<p>And that code actually in the &#8220;Code Editor&#8221; in WordPress is:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;&#x5B;text]\n&#x5B;&#x5B;php]\n&lt;!--?php\necho \u201cHello World\u201d;\n?--&gt;\n&#x5B;\/php]]\n&#x5B;\/text]]\n<\/pre>\n<p>And the above example was generated by wrapping in &#8216;&#091;&#091;code language=&#8221;text&#8221;&#093;&#093;&#8217; and adding layers of &#8216;[[&#8216; and &#8216;]]&#8217;.<\/p>\n<p>And to to get &#8216;&#091;&#091;code language=&#8221;text&#8221;&#093;&#093;&#8217; you need to do:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#039;&amp;#091;&amp;#091;code language=&quot;text&quot;&amp;#093;&amp;#093;&#039;\n<\/pre>\n<h1>Header 1<\/h1>\n<p>Header 1 body text.<\/p>\n<h2>Header 2<\/h2>\n<p>Header 2 body text.<\/p>\n<h3>Header 3<\/h3>\n<p>Header 3 body text.<\/p>\n<h4>Header 4<\/h4>\n<p>Header 4 body text.<\/p>\n<h5>Header 5<\/h5>\n<p>Header 5 body text.<\/p>\n<h6>Header 6<\/h6>\n<p>Header 6 body text.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;h1&gt;Header 1&lt;\/h1&gt;\nHeader 1 body text.\n&lt;h2&gt;Header 2&lt;\/h2&gt;\nHeader 2 body text.\n&lt;h3&gt;Header 3&lt;\/h3&gt;\nHeader 3 body text.\n&lt;h4&gt;Header 4&lt;\/h4&gt;\nHeader 4 body text.\n&lt;h5&gt;Header 5&lt;\/h5&gt;\nHeader 5 body text.\n&lt;h6&gt;Header 6&lt;\/h6&gt;\nHeader 6 body text.\n<\/pre>\n<h1>Table<\/h1>\n<p>Here&#8217;s a table using simple &#8220;html table tags&#8221; (I am not currently using a plugin for tables but that may change in the future):<\/p>\n<table>\n<tbody>\n<tr>\n<th>FIRST 1st COLUMN<\/th>\n<th>SECOND 2nd COLUMN<\/th>\n<\/tr>\n<tr>\n<td>1st column 1st row<\/td>\n<td>2nd column 1st row<\/td>\n<\/tr>\n<tr>\n<td>1st column 2nd row<\/td>\n<td>2nd column 2nd row<\/td>\n<\/tr>\n<tr>\n<td>1st column 3rd row<\/td>\n<td>2nd column 3rd row<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;table&gt;\n  &lt;tbody&gt;\n  &lt;tr&gt;\n    &lt;th&gt;FIRST 1st COLUMN&lt;\/th&gt;\n    &lt;th&gt;SECOND 2nd COLUMN&lt;\/th&gt;\n  &lt;\/tr&gt;\n  &lt;tr&gt;\n    &lt;td&gt;1st column 1st row&lt;\/td&gt;\n    &lt;td&gt;2nd column 1st row&lt;\/td&gt;\n  &lt;\/tr&gt;\n  &lt;tr&gt;\n    &lt;td&gt;1st column 2nd row&lt;\/td&gt;\n    &lt;td&gt;2nd column 2nd row&lt;\/td&gt;\n  &lt;\/tr&gt;\n  &lt;tr&gt;\n    &lt;td&gt;1st column 3rd row&lt;\/td&gt;\n    &lt;td&gt;2nd column 3rd row&lt;\/td&gt;\n  &lt;\/tr&gt;\n  &lt;\/tbody&gt;\n&lt;\/table&gt;\n<\/pre>\n<h1>Footnote<\/h1>\n<p>This is a footnote<span id='easy-footnote-1-234' class='easy-footnote-margin-adjust'><\/span><span class='easy-footnote'><a href='https:\/\/www.hoopchuk.org\/wordpress\/code-template\/#easy-footnote-bottom-1-234' title='For footnotes I use plugin &amp;#8220;Easy Footnotes&amp;#8221;.'><sup>1<\/sup><\/a><\/span> using &#8220;Easy Footnotes&#8221;.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nThis is a footnote&#x5B;&#x5B;efn_note]For footnotes I use plugin &quot;Easy Footnotes&quot;.&#x5B;\/efn_note]] using &quot;Easy Footnotes&quot;.\n<\/pre>\n<h1>Commands And Output<\/h1>\n<p>Simple &#8220;&lt;pre&gt;&#8221; is all you need here:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&lt;pre&gt;$ ls\n...\n&lt;\/pre&gt;\n<\/pre>\n<p>Which renders like:<\/p>\n<pre>$ ls\n...\n<\/pre>\n<p>One incredibly annoying tidbit is the &#8220;Code Editor&#8221; in WordPress with &#8220;remove whitespace&#8221; and keeps putting the &#8220;ls&#8221; on the the same line as the &#8220;&lt;pre&gt;&#8221;.<br \/>\nThis is very annoying but don&#8217;t waste too much time trying to fix as I think you&#8217;ll fail (or see people telling you to modify the actual &#8220;*.php&#8221; code which I&#8217;m not wanting to do right now).<\/p>\n<p>I almost never set &#8220;auto yes&#8221; so I always have a chance to say &#8220;N&#8221; on an upgrade so it&#8217;s safe to use <code>&hyphen;&hyphen;disablerepo<\/code> to see what the effects are like:<\/p>\n<pre>[root@snafu ~]# dnf upgrade\nLast metadata expiration check: 0:00:00 ago on Thu 14 Mar 2019 08:05:20 PM CDT.\nDependencies resolved.\n===============================================================================\n&nbsp;Package               Arch         Version                Repository     Size\n===============================================================================\nUpgrading:\n...\n&nbsp;pcre                x86_64     8.43-1.fc28         <span style=\"color: #ff0000;\">fubar-local-repo<\/span>     208 k\n\nTransaction Summary\n===============================================================================\nUpgrade 6 Packages\n\nTotal download size: 93 M\n<span style=\"color: #ff0000;\">Is this ok [y\/N]: N<\/span>\n<span style=\"color: #ff0000;\">Operation aborted.<\/span><\/pre>\n<p>If I need to make sure my custom repo isn&#8217;t hurting anything I can disable for just the one command like:<\/p>\n<pre>[root@snafu ~]# dnf --disablerepo=fubar-local-repo upgrade\nLast metadata expiration check: 0:11:32 ago on Thu 14 Mar 2019 07:51:29 PM CDT.\nDependencies resolved.\n===============================================================================\n&nbsp;Package               Arch         Version                Repository     Size\n===============================================================================\nUpgrading:\n...\n pcre                  x86_64       8.43-1.fc28            <span style=\"color: #ff0000;\">updates<\/span>       208 k\n\nTransaction Summary\n===============================================================================\nUpgrade 6 Packages\n\nTotal download size: 93 M\n<span style=\"color: #ff0000;\">Is this ok [y\/N]: N<\/span>\n<span style=\"color: #ff0000;\">Operation aborted.<\/span><\/pre>\n<h2>setopt<\/h2>\n<p>Above I had you set &#8220;priority&#8221; in the config file using a text editor, that could have been:<\/p>\n<pre>[root@snafu ~]# dnf config-manager --setopt priority=11 --save fubar-local-repo\nMain config did not have a priority attr. before setopt\nMain config did not have a priority attr. before setoptnext<\/pre>\n<p>Those &#8220;did not have&#8221; messages bother me but if you check out the master log file it did not change:<\/p>\n<pre>[root@snafu ~]# cat \/etc\/dnf\/dnf.conf\n[main]\ngpgcheck=1\ninstallonly_limit=3\nclean_requirements_on_remove=True<\/pre>\n<p>And if you check the &#8220;repo file&#8221; for our repo &#8220;fubar-local-repo&#8221; you&#8217;ll see the &#8220;11&#8221; like:<\/p>\n<pre>[root@snafu ~]# cat \/etc\/yum.repos.d\/fubar-local.repo\n[fubar-local-repo]\nname=Fubar Local Repository\n#baseurl=file:\/\/\/testrepo\/\nbaseurl=ftp:\/\/fubar\/pub\/dnfrepo\/\nenabled=1\ngpgcheck=0\n<span style=\"color: #ff0000;\">priority = 11<\/span><\/pre>\n<p>The full list of &#8220;options&#8221; is easy to find like:<\/p>\n<pre>[root@snafu ~]# dnf config-manager --dump fubar-local-repo\n=========================== repo: fubar-local-repo ============================\n[fubar-local-repo]\n...\npriority = 11\n...<\/pre>\n<p>Notice you see our &#8220;priority&#8221; we just set. Also notice some stuff from the master dnf conf is not present like &#8220;clean_requirements_on_remove&#8221; is not seen. If you want to see &#8220;master&#8221; leave off the repo like:<\/p>\n<pre>[root@snafu ~]# dnf config-manager --dump\n==================================== main =====================================\n[main]\n...\nclean_requirements_on_remove = True\n...<\/pre>\n<p>And you do not see our &#8220;priority&#8221;.<\/p>\n<p>I know of no built in way to see if an option is a default or from what config file. It&#8217;s not overly challenging to do some &#8220;grepp&#8217;ing&#8221; between files and have to do it so seldom I&#8217;ve never bothered to script it.<\/p>\n<p>And finally if you set a &#8220;non existent option&#8221; like:<\/p>\n<pre>[root@snafu ~]# dnf config-manager --setopt foo=bar --save fubar-local-repo\nMain config did not have a foo attr. before setopt\nMain config did not have a foo attr. before setopt<\/pre>\n<p>You&#8217;ll see in the config like:<\/p>\n<pre>[fubar-local-repo]\nname=Fubar Local Repository\n#baseurl=file:\/\/\/testrepo\/\nbaseurl=ftp:\/\/fubar\/pub\/dnfrepo\/\nenabled=1\ngpgcheck=0\npriority = 11\n<span style=\"color: #ff0000;\">foo = bar<\/span><\/pre>\n<p>&#8220;foo&#8221; is not a valid option so I&#8217;m not sure why it&#8217;s allowed but &#8220;dnf&#8221; won&#8217;t complain until you do something like (note I used &#8220;-v&#8221; for &#8220;verbose&#8221;):<\/p>\n<pre>[root@snafu ~]# dnf config-manager -v --dump-variables fubar-local-repo\nLoaded plugins: builddep, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repograph, repomanage, reposync\nDNF version: 2.7.5\ncachedir: \/var\/cache\/dnf\n<span style=\"color: #ff0000;\">Unknown configuration option: foo = bar in \/etc\/yum.repos.d\/fubar-local.repo<\/span>\narch = x86_64\nbasearch = x86_64\nreleasever = 28<\/pre>\n<p>I don&#8217;t know of a &#8220;verify&#8221; option you can use but I suspect one might exist.<\/p>\n<p><span style=\"color: #ff0000;\"><em>And if you need to remove option &#8220;foo&#8221; the only way I know is to use a text editor \ud83d\ude41<\/em><\/span><\/p>\n<h1>References<\/h1>\n<p>Almost always in something technical I&#8217;m looking stuff up and a references section is a good idea:<\/p>\n<p><a href=\"http:\/\/www.hoopchuk.org\/wordpress\/code-template\/\">http:\/\/www.hoopchuk.org\/wordpress\/code-template\/<\/a><\/p>\n<h1>Print Friendly<\/h1>\n<div class=\"printfriendly pf-button  pf-alignleft\">\n                    <a href=\"https:\/\/www.hoopchuk.org\/wordpress\/code-template\/?pfstyle=wp\" rel=\"nofollow\" onclick=\"\" title=\"Printer Friendly, PDF & Email\">\n                    <img data-recalc-dims=\"1\" decoding=\"async\" class=\"pf-button-img\" src=\"https:\/\/i0.wp.com\/cdn.printfriendly.com\/buttons\/printfriendly-button.png?w=840&#038;ssl=1\" alt=\"Print Friendly, PDF & Email\" style=\"width: 112px;height: 24px;\"  \/>\n                    <\/a>\n                <\/div>\n<p><br\/><br\/><\/p>\n<p>I prefer a PDF to print something like this.<\/p>\n<p>I use plugin &#8220;Print, PDF &amp; Email by PrintFriendly&#8221;.<\/p>\n<h1>Subversion<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$Id: code-template.txt 4149 2019-04-25 19:03:45Z hoopchuk $\n<\/pre>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>Summary Ross&#8217;s &#8220;template for code stuff&#8221;. I&#8217;ll also try to document what plugins I&#8217;m using via examples in this. TODOs There are at least two &#8220;TODOs&#8221; I can think of on 25MAR2019MON: One Two Code Editor I have wasted much time trying to override WordPress&#8217;s stupid &#8220;change my code&#8221; in the &#8220;Visual Editor&#8221;. The easy &hellip; <a href=\"https:\/\/www.hoopchuk.org\/wordpress\/code-template\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Code Template&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"nf_dc_page":"","wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","nfd_onboarding_generated":"","footnotes":""},"class_list":["post-234","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/PaQUmf-3M","_links":{"self":[{"href":"https:\/\/www.hoopchuk.org\/wordpress\/wp-json\/wp\/v2\/pages\/234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hoopchuk.org\/wordpress\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.hoopchuk.org\/wordpress\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.hoopchuk.org\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hoopchuk.org\/wordpress\/wp-json\/wp\/v2\/comments?post=234"}],"version-history":[{"count":5,"href":"https:\/\/www.hoopchuk.org\/wordpress\/wp-json\/wp\/v2\/pages\/234\/revisions"}],"predecessor-version":[{"id":415,"href":"https:\/\/www.hoopchuk.org\/wordpress\/wp-json\/wp\/v2\/pages\/234\/revisions\/415"}],"wp:attachment":[{"href":"https:\/\/www.hoopchuk.org\/wordpress\/wp-json\/wp\/v2\/media?parent=234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}