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

+8 -8
View File
@@ -1,13 +1,13 @@
## To build:
```sh
```<!---sh-->
make all
```
## To use:
```sh
```<!---sh-->
./dorssel
# input some text
@@ -17,7 +17,7 @@
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -48,7 +48,7 @@ altering the behavior ?
Try doing what the last part of the last command in [try.sh](try.sh) suggests.
As in, do the following:
```sh
```<!---sh-->
echo ". -..- . .-. -.-. .. ... .
-.-. .... .- -. --. . - .... . .--. .-. --- --. .-. .- -- ... --- .. - -.. --- . ... -. --- - ... .... --- ..- -" | ./dorssel
```
@@ -91,7 +91,7 @@ invoke undefined behavior.
Try:
```sh
```<!---sh-->
./dorssel < dorssel.c | ./dorssel
```
@@ -101,20 +101,20 @@ better job than most C beautifiers).
- Filter your text twice (as in the previous sample) to obtain a version of your
text that can be reversibly Morsified, i.e.
```sh
```<!---sh-->
./dorssel < dorssel.c | ./dorssel | ./dorssel | ./dorssel
```
is the same as
```sh
```<!---sh-->
./dorssel < dorssel.c | ./dorssel
```
- The file [dorssel.md](dorssel.md) contains all the information needed to
understand this program. For an obfuscated spoiler, try
```sh
```<!---sh-->
./dorssel < dorssel.md
```
+15 -15
View File
@@ -150,11 +150,11 @@ two bits would suffice, e.g.</p>
<p>That means bits 6 and 5 set to 00 is length 1, set to 01 is length 2, etc.
But this would mean that we would have to extract the length into a
counter before shifting out each symbol, such as</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> length <span class="op">=</span> <span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">96</span><span class="op">)</span> <span class="op">&gt;&gt;</span> <span class="dv">5</span><span class="op">;</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">do</span> <span class="op">{</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">&#39;-&#39;</span> <span class="op">:</span> <span class="ch">&#39;.&#39;</span><span class="op">);</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">&gt;&gt;=</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span> <span class="cf">while</span> <span class="op">(</span>length<span class="op">--);</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> length = (encoding &amp; 96) &gt;&gt; 5;
do {
putchar(encoding &amp; 1 ? &#39;-&#39; : &#39;.&#39;);
encoding &gt;&gt;= 1;
} while (length--);</code></pre>
<p>We can also use the remaining bits to <em>include</em> the counter</p>
<pre><code> length 1: 00000.1x E &gt; 00000.11
length 2: 0000.1xx
@@ -162,10 +162,10 @@ counter before shifting out each symbol, such as</p>
length 4: 00.1xxxx Z &gt; 00.11100
length 5: 0.1xxxxx 3 &gt; 0.100111</code></pre>
<p>with 1 bit still to be chosen freely (let’s assume it is 0). Now we can do</p>
<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="cf">do</span> <span class="op">{</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">&#39;-&#39;</span> <span class="op">:</span> <span class="ch">&#39;.&#39;</span><span class="op">);</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">&gt;&gt;=</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">while</span> <span class="op">(</span>encoding <span class="op">&gt;</span> <span class="dv">1</span><span class="op">);</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> do {
putchar(encoding &amp; 1 ? &#39;-&#39; : &#39;.&#39;);
encoding &gt;&gt;= 1;
while (encoding &gt; 1);</code></pre>
<p>As you see, the encoded Morse sequence can be the counter itself. But
this is not very pleasant, as some Morse sequences will end up having
an ASCII value &lt; 32, i.e. they will be control codes. This would make
@@ -179,21 +179,21 @@ following</p>
<p>Notice these encodings in the initialization string. Only the coding for
<code>5</code> needs an escape (<code>5 = ..... &gt; 01111111 = '\177'</code>). The way the length
is encoded still allows the encoding to be its own counter:</p>
<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="cf">do</span> <span class="op">{</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">&#39;-&#39;</span> <span class="op">:</span> <span class="ch">&#39;.&#39;</span><span class="op">);</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">=</span> <span class="op">(</span>encoding <span class="op">+</span> <span class="dv">32</span><span class="op">)</span> <span class="op">&gt;&gt;</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span> <span class="cf">while</span> <span class="op">(</span>encoding <span class="op">&gt;</span> <span class="dv">35</span><span class="op">);</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> do {
putchar(encoding &amp; 1 ? &#39;-&#39; : &#39;.&#39;);
encoding = (encoding + 32) &gt;&gt; 1;
} while (encoding &gt; 35);</code></pre>
<p>The last shift will always result in <code>00100010</code>, hence the test for <code>&gt;35</code>.
Note that the calculation for the next value of <code>encoding</code> is done at <code>int</code>
precision, so that the actual value of the <code>char</code> remains <code>&lt;= 127</code>.</p>
<p>The character <code>'-'</code> (ASCII 45) and <code>'.'</code> (ASCII 46) are conveniently in
sequence, so the putchar can simply be</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span><span class="dv">45</span> <span class="op">+</span> encoding <span class="op">%</span> <span class="dv">2</span><span class="op">);</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> putchar(45 + encoding % 2);</code></pre>
<p>I used the modulo operator this time, because <code>+</code> takes precedence over <code>&amp;</code>.
The assignment can be incorporated into the <code>while</code> control test, and a
<code>do-while</code> loop with a body of a single expression statement can be written
as a <code>while</code> loop with a comma operator in the test:</p>
<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">while</span><span class="op">(</span>putchar<span class="op">(</span><span class="dv">45</span> <span class="op">+</span> encoding <span class="op">%</span> <span class="dv">2</span><span class="op">),</span> encoding <span class="op">=</span> encoding <span class="op">+</span> <span class="dv">32</span> <span class="op">&gt;&gt;</span> <span class="dv">1</span><span class="op">);</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> while(putchar(45 + encoding % 2), encoding = encoding + 32 &gt;&gt; 1);</code></pre>
<p>Voila.</p>
<p>Now, the decoding of Morse codes is just the reverse. We shift in <code>0</code>s
and <code>1</code>s as we scan the line. But: we have to scan from back to front
+5 -5
View File
@@ -42,7 +42,7 @@ That means bits 6 and 5 set to 00 is length 1, set to 01 is length 2, etc.
But this would mean that we would have to extract the length into a
counter before shifting out each symbol, such as
```c
```<!---c-->
length = (encoding & 96) >> 5;
do {
putchar(encoding & 1 ? '-' : '.');
@@ -62,7 +62,7 @@ We can also use the remaining bits to *include* the counter
with 1 bit still to be chosen freely (let's assume it is 0). Now we can do
```c
```<!---c-->
do {
putchar(encoding & 1 ? '-' : '.');
encoding >>= 1;
@@ -87,7 +87,7 @@ Notice these encodings in the initialization string. Only the coding for
`5` needs an escape (`5 = ..... > 01111111 = '\177'`). The way the length
is encoded still allows the encoding to be its own counter:
```c
```<!---c-->
do {
putchar(encoding & 1 ? '-' : '.');
encoding = (encoding + 32) >> 1;
@@ -101,7 +101,7 @@ precision, so that the actual value of the `char` remains `<= 127`.
The character `'-'` (ASCII 45) and `'.'` (ASCII 46) are conveniently in
sequence, so the putchar can simply be
```c
```<!---c-->
putchar(45 + encoding % 2);
```
@@ -110,7 +110,7 @@ The assignment can be incorporated into the `while` control test, and a
`do-while` loop with a body of a single expression statement can be written
as a `while` loop with a comma operator in the test:
```c
```<!---c-->
while(putchar(45 + encoding % 2), encoding = encoding + 32 >> 1);
```
+12 -12
View File
@@ -141,14 +141,14 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></l
<!-- 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>
<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">./dorssel</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># input some text</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> text <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./dorssel
# input some text
echo text | ./dorssel</code></pre>
<h2 id="try">Try:</h2>
<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="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>How does the program decide which way to convert?</p>
<p>What obsolescent feature are we talking about? (No, it’s not a
@@ -166,8 +166,8 @@ altering the behavior ?</p></li>
<h3 id="extra-credit">Extra credit:</h3>
<p>Try doing what the last part of the last command in <a href="try.sh">try.sh</a> suggests.
As in, do the following:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">&quot;. -..- . .-. -.-. .. ... .</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="st"> -.-. .... .- -. --. . - .... . .--. .-. --- --. .-. .- -- ... --- .. - -.. --- . ... -. --- - ... .... --- ..- -&quot;</span> <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> echo &quot;. -..- . .-. -.-. .. ... .
-.-. .... .- -. --. . - .... . .--. .-. --- --. .-. .- -- ... --- .. - -.. --- . ... -. --- - ... .... --- ..- -&quot; | ./dorssel</code></pre>
<p>and make the necessary adjustments.</p>
<p>You might also want to read the <a href="dorssel.html">dorssel.html</a> file.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
@@ -195,21 +195,21 @@ ASCII. As far as I can tell, the program is conforming and does not
invoke undefined behavior.</p>
<h3 id="hints">Hints</h3>
<p>Try:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./dorssel &lt; dorssel.c | ./dorssel</code></pre>
<p>to see what variables, numbers, and functions are used. (Does a
better job than most C beautifiers).</p>
<ul>
<li>Filter your text twice (as in the previous sample) to obtain a version of your
text that can be reversibly Morsified, i.e.</li>
</ul>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span> <span class="kw">|</span> <span class="ex">./dorssel</span> <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./dorssel &lt; dorssel.c | ./dorssel | ./dorssel | ./dorssel</code></pre>
<p>is the same as</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./dorssel &lt; dorssel.c | ./dorssel</code></pre>
<ul>
<li>The file <a href="dorssel.md">dorssel.md</a> contains all the information needed to
understand this program. For an obfuscated spoiler, try</li>
</ul>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.md</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./dorssel &lt; dorssel.md</code></pre>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.