add hack-a-round for language specified markdown code blocks

When language is specified in a markdown code block such as:

````
```c
    printf("Hello, world!\n");
```
````

is used, the resulting HTML as produced by `pandoc(1)` combined
with our revised `ioccc.css` is not intent the code block well.

A temporary "_hack-a-round_" is to turn the "markdown code language
specifier" into an HTML comment.  For example:

````
```<!---c-->
    printf("Hello, world!\n");
```
````

This commits turns off existing markdown code language specifiers
for now, while preserving our ability to restore them in the future
when a better  "_hack-a-round_" to the "markdown code language
specifier" problem is found.

The HTML impact if this "_hack-a-round_" is to produce HTML that
looks like this:

```
<pre class="&lt;!---c--&gt;"><code> .. </code></pre>
```

We might be able to create a complex set of classes for each markdown
code language (there won't be very many) in `ioccc.css`, or we might
find a more general CSS (or maybe `pandoc(1)`?) solution.

For now, this hack-a-round will have to do.
This commit is contained in:
Landon Curt Noll committed 2024-04-04 14:50:38 -07:00
1 parent 3919df50fb
commit b66c79254a
700 files changed
+7052 -7056

No files matched your search

+10 -10
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make all
```
@@ -12,7 +12,7 @@ includes some interesting details about the entry.
## To use:
```sh
```<!---sh-->
./schweikh1
```
@@ -30,7 +30,7 @@ if you don't have a Mac as it has some interesting details about the entry.
### Alternate build:
```sh
```<!---sh-->
make alt
```
@@ -126,7 +126,7 @@ macros can be defined, because you could write strictly conforming
programs that may fail to compile due to syntax errors: supposing that
`<stdio.h>` defines `PIPE_BUF`, then the conforming
```c
```<!---c-->
#include <assert.h>
#include <stdio.h> /* <- or where the bogus macro is defined */
#include <string.h>
@@ -155,7 +155,7 @@ C compilers.
must resemble one of the canonical forms, `"foo.h"` or `<bar.h>`.
This lets us write things like
```c
```<!---c-->
#define HEADER "foo.h"
#include HEADER
```
@@ -164,7 +164,7 @@ C compilers.
torturing the preprocessor a little more, by using token pasting,
at least one compiler falls over.
```c
```<!---c-->
#define H(x) <st##x##.h>
#include H(dio) /* expands to <stdio.h> */
```
@@ -187,7 +187,7 @@ C compilers.
ISO 6.8.4. ISO 6.1.4 defines string literals as s-char-sequences,
which may include octal escape sequences. Let's look at
```c
```<!---c-->
#include <stdio.h>
#line 42 "foo\0bar"
int main (void) {
@@ -214,7 +214,7 @@ C compilers.
under his/her nose. Easy money from a bet! Make sure your guru has
no chance to use Standardese weasel words as an escape: can I have
```c
```<!---c-->
case <some_token>:
case <some_token>:
```
@@ -255,7 +255,7 @@ script to compute the character count according to the rules.
The advantages of an independent clean room approach...
```perl
```<!---perl-->
#!/usr/bin/perl -w
$/ = "\0";
$_ = <>;
@@ -266,7 +266,7 @@ The advantages of an independent clean room approach...
To use, try:
```sh
```<!---sh-->
perl ./charcount.pl schweikh1.c
```
+33 -33
View File
@@ -141,13 +141,13 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</code></pre>
<p>There is an alternate version of this entry that will work with macOS. See the
<a href="#alternate-code">Alternate code</a> section below. We recommend you look at it
even if you don’t have a Mac, unless you want to figure it out yourself, as it
includes some interesting details about the entry.</p>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./schweikh1</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./schweikh1</code></pre>
<h2 id="alternate-code">Alternate code:</h2>
<p>As noted above this entry will not work as it stands for macOS and there are
some important notes as well as a description of how the fixed version works
@@ -157,7 +157,7 @@ adjustments). For details of what had to change, see <a href="macos.html">macos.
Unless you wish to figure it out yourself, we recommend that you read this even
if you don’t have a Mac as it has some interesting details about the entry.</p>
<h3 id="alternate-build">Alternate build:</h3>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<h3 id="alternate-build-1">Alternate build:</h3>
<p>Use <code>schweikh1.alt</code> as you would <code>schweikh1</code> above.</p>
<h3 id="alternate-try">Alternate try:</h3>
@@ -220,17 +220,17 @@ macros are explicitly enumerated. In a compliant implementation no other
macros can be defined, because you could write strictly conforming
programs that may fail to compile due to syntax errors: supposing that
<code>&lt;stdio.h&gt;</code> defines <code>PIPE_BUF</code>, then the conforming</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im">&lt;assert.h&gt;</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im">&lt;stdio.h&gt;</span><span class="pp"> </span><span class="co">/* &lt;- or where the bogus macro is defined */</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im">&lt;string.h&gt;</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define STR</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span><span class="pp"> </span><span class="op">#</span><span class="pp">x</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define XSTR</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span><span class="pp"> STR</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> main <span class="op">(</span><span class="dt">void</span><span class="op">)</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> PIPE_BUF <span class="op">=</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a> assert <span class="op">(</span>strcmp <span class="op">(</span><span class="st">&quot;PIPE_BUF&quot;</span><span class="op">,</span> XSTR <span class="op">(</span>PIPE_BUF<span class="op">))</span> <span class="op">==</span> <span class="dv">0</span><span class="op">);</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> #include &lt;assert.h&gt;
#include &lt;stdio.h&gt; /* &lt;- or where the bogus macro is defined */
#include &lt;string.h&gt;
#define STR(x) #x
#define XSTR(x) STR(x)
int main (void)
{
int PIPE_BUF = 0;
assert (strcmp (&quot;PIPE_BUF&quot;, XSTR (PIPE_BUF)) == 0);
return 0;
}</code></pre>
<p>is expected to compile and meet the assertion. If it does not, your
compiler compiles some other language than ISO C.</p>
<h3 id="why-i-think-my-program-is-obfuscated">Why I think my program is obfuscated</h3>
@@ -243,13 +243,13 @@ C compilers.</p>
must resemble one of the canonical forms, <code>"foo.h"</code> or <code>&lt;bar.h&gt;</code>.
This lets us write things like</li>
</ol>
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define HEADER </span><span class="st">&quot;foo.h&quot;</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include HEADER</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> #define HEADER &quot;foo.h&quot;
#include HEADER</code></pre>
<p>I could not find a compiler rejecting this. However, if we’re
torturing the preprocessor a little more, by using token pasting,
at least one compiler falls over.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define H</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span><span class="pp"> </span><span class="op">&lt;</span><span class="pp">st</span><span class="op">##</span><span class="pp">x</span><span class="op">##.</span><span class="pp">h</span><span class="op">&gt;</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include H(dio) </span><span class="co">/* expands to &lt;stdio.h&gt; */</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> #define H(x) &lt;st##x##.h&gt;
#include H(dio) /* expands to &lt;stdio.h&gt; */</code></pre>
<p>is rejected by tcc version 4.1.2, the TenDRA compiler:
<code>"t.c", line 3: Error:\ [ISO 6.8.3.3]: Invalid result for '##' operator in macro 'H'.</code></p>
<p>To be honest, I don’t know if the rules for pp-tokens and token
@@ -264,12 +264,12 @@ allows: in <code>#line num "file"</code> the <code>"file"</code> is an s-char-se
ISO 6.8.4. ISO 6.1.4 defines string literals as s-char-sequences,
which may include octal escape sequences. Let’s look at</li>
</ol>
<div class="sourceCode" id="cb8"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im">&lt;stdio.h&gt;</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#line 42 &quot;foo\0bar&quot;</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> main <span class="op">(</span><span class="dt">void</span><span class="op">)</span> <span class="op">{</span></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> printf <span class="op">(</span><span class="st">&quot;</span><span class="sc">%s</span><span class="st"> </span><span class="sc">%d\n</span><span class="st">&quot;</span><span class="op">,</span> __FILE__<span class="op">,</span> <span class="op">(</span><span class="dt">int</span><span class="op">)</span><span class="kw">sizeof</span> __FILE__<span class="op">);</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> #include &lt;stdio.h&gt;
#line 42 &quot;foo\0bar&quot;
int main (void) {
printf (&quot;%s %d\n&quot;, __FILE__, (int)sizeof __FILE__);
return 0;
}</code></pre>
<p>This is supposed to output <code>'foo 8'</code>. Here’s what happens in RL:</p>
<pre><code> foo 4 gcc 2.7.2.1, lcc
foo\0bar 9 tcc 4.1.2, Sunsoft cc turn &quot;\0&quot; into &quot;\\0&quot;, ugh!</code></pre>
@@ -283,8 +283,8 @@ ISO 6.6.4.2. Then make fun of the guru’s answer by waving <code>case __LINE__:
under his/her nose. Easy money from a bet! Make sure your guru has
no chance to use Standardese weasel words as an escape: can I have</p></li>
</ol>
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="op">&lt;</span>some_token<span class="op">&gt;:</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="op">&lt;</span>some_token<span class="op">&gt;:</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> case &lt;some_token&gt;:
case &lt;some_token&gt;:</code></pre>
<p>in the same switch? (Note that you need the [invisible] newline. You
can generously allow the additional constraint that no <code>#undef</code>s or
<code>#define</code>s are allowed between the two cases.)</p>
@@ -315,14 +315,14 @@ I could have used a lot more <code>^K</code> and <code>^L</code> probably undete
counter but decided to err on the side of safety. I use a perl
script to compute the character count according to the rules.
The advantages of an independent clean room approach…</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode perl"><code class="sourceCode perl"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="co">#!/usr/bin/perl -w</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="wa">$/</span> = <span class="ot">&quot;</span><span class="st">\0</span><span class="ot">&quot;</span>;</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="wa">$_</span> = &lt;&gt;;</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="ot">s/</span><span class="ch">[</span><span class="bn">;{}</span><span class="ch">][</span><span class="bn"> \t\n</span><span class="ch">]</span><span class="ot">/</span><span class="ch">\n</span><span class="ot">/g</span>;</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="ot">s/</span><span class="ch">[</span><span class="bn"> \t\n</span><span class="ch">]+</span><span class="ot">//g</span>;</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span> <span class="fu">length</span> (<span class="wa">$_</span>),<span class="ot">&quot;</span><span class="ch">\n</span><span class="ot">&quot;</span>;</span></code></pre></div>
<pre class="&lt;!---perl--&gt;"><code> #!/usr/bin/perl -w
$/ = &quot;\0&quot;;
$_ = &lt;&gt;;
s/[;{}][ \t\n]/\n/g;
s/[ \t\n]+//g;
print length ($_),&quot;\n&quot;;</code></pre>
<p>To use, try:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">perl</span> ./charcount.pl schweikh1.c</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> perl ./charcount.pl schweikh1.c</code></pre>
<p>I have tried, as suggested in the guidelines, to let the code look
like ordinary C code. Apart from a few long lines I think I left
the indentation like I would in RL. You should however not try to
+4 -4
View File
@@ -138,7 +138,7 @@ a file was not found (this limitation was removed in both versions in 2023). see
<p>However, as noted, macOS does <strong>not</strong> have <code>/usr/include</code> so this would never
work for macOS without some changes, described next. For macOS you will need the
command line tools installed which can be done like:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">sudo</span> xcode-select <span class="at">--install</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> sudo xcode-select --install</code></pre>
<p>An important point is that the original version hard-coded <code>gcc</code> but just like
the entry, the alternate version has also removed this limitation despite <code>gcc</code>
existing (though it’s <code>clang</code>) in macOS.</p>
@@ -154,9 +154,9 @@ the command is:</p>
<p>which has been changed to be:</p>
<pre><code>&quot;0cc -ansi -E -dM -undef %s /usr/include/%s&gt;r\0 (&quot;</code></pre>
<p>Shortly below that you will see, as noted above, the numbers:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">((</span>H <span class="op">=</span> fopen <span class="op">(</span>__FILE__<span class="op">+</span><span class="dv">43</span><span class="op">,</span> <span class="dv">43</span><span class="op">+</span>__FILE__<span class="op">)))</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">while</span> <span class="op">((</span>fgets <span class="op">(</span>L<span class="op">,</span> <span class="op">(</span><span class="dt">int</span><span class="op">)</span><span class="kw">sizeof</span> L<span class="op">,</span> H<span class="op">))</span> <span class="op">!=</span> <span class="dv">0</span><span class="op">)</span> <span class="op">{</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> I<span class="op">[</span>strcspn <span class="op">(</span>I<span class="op">,</span> <span class="dv">45</span><span class="op">+</span>__FILE__<span class="op">)]</span> <span class="op">=</span> O <span class="op">=</span> <span class="dv">0</span><span class="op">;</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> if ((H = fopen (__FILE__+43, 43+__FILE__)))
while ((fgets (L, (int)sizeof L, H)) != 0) {
I[strcspn (I, 45+__FILE__)] = O = 0;</code></pre>
<p>The first number in the above C means the length starting from 0 up through the
<code>&gt;</code>. The second number is the same starting point but up through the <code>\0</code> which
is why it’s <code>+2</code>. But what happens if only the first number is updated (from the
+2 -2
View File
@@ -19,7 +19,7 @@ However, as noted, macOS does **not** have `/usr/include` so this would never
work for macOS without some changes, described next. For macOS you will need the
command line tools installed which can be done like:
```sh
```<!---sh-->
sudo xcode-select --install
```
@@ -50,7 +50,7 @@ which has been changed to be:
Shortly below that you will see, as noted above, the numbers:
```c
```<!---c-->
if ((H = fopen (__FILE__+43, 43+__FILE__)))
while ((fgets (L, (int)sizeof L, H)) != 0) {
I[strcspn (I, 45+__FILE__)] = O = 0;