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="<!---c-->"><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:
1 parent
3919df50fb
commit
b66c79254a
700 files changed
+7052
-7056
No files matched your search
+18
-18
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ For more detailed information see [1996 august bugs](../../bugs.html#1996_august
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.c test.oc | ./august > test.oo
|
||||
./august < test.oo
|
||||
```
|
||||
@@ -33,7 +33,7 @@ The above should print a `!` followed by a newline.
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -43,33 +43,33 @@ The above should print a `!` followed by a newline.
|
||||
This entry can feed on itself. If you C pre-process the source,
|
||||
you can compile the interpreter:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make august.oc
|
||||
```
|
||||
|
||||
We can now compile the interpreter as follows:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.c august.oc | ./august > august.oo
|
||||
```
|
||||
|
||||
and use the compiled interpreter to execute some previously
|
||||
compiled code:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.oo test.oo | ./august
|
||||
```
|
||||
|
||||
And we can have the compiled interpreter interpret itself which
|
||||
in turn compiles the test program:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.oo august.oo fac.oo | ./august
|
||||
```
|
||||
|
||||
And if you have lots of spare time, you can recurse one level deeper:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.oo august.oo august.oo fac.oo | ./august
|
||||
```
|
||||
|
||||
@@ -107,25 +107,25 @@ can go wrong. But this is what seasoned C programmers are used to.
|
||||
Assume that the interpreter has been compiled (source in [august.c](august.c)
|
||||
and binary in august) and that we have this in a file named `test.oc`:
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
main() { putchar('!'); putchar('\n'); exit(0); }
|
||||
```
|
||||
|
||||
We can then compile by
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.c test.oc | ./august > test.oo
|
||||
```
|
||||
|
||||
And run the compiled program by
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./august < test.oo
|
||||
```
|
||||
|
||||
Or even simpler:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.c test.oc | ./august | ./august
|
||||
```
|
||||
|
||||
@@ -141,26 +141,26 @@ need to use an external one. To pre-process [august.c](august.c) use the
|
||||
command from the Makefile, but add the `-E` flag and change 60000 to 40000,
|
||||
i.e.:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cc -E -DZ=40000 .... august.c > august.oc
|
||||
```
|
||||
|
||||
If `august.oc` contain some junk line starting with a `#` (most likely
|
||||
it does) then remove it like:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
sed -i'' '/^#/d' august.oc
|
||||
```
|
||||
|
||||
OK, we can now compile the interpreter:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.c august.oc | ./august > august.oo
|
||||
```
|
||||
|
||||
And we can run it:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.oo test.oo | ./august
|
||||
```
|
||||
|
||||
@@ -168,13 +168,13 @@ Here we have the interpreter interpreting another interpreter that runs
|
||||
the program. Did you think that was too fast? Just throw in another
|
||||
level of interpretation:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.oo august.oo test.oo | ./august
|
||||
```
|
||||
|
||||
And another...
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat august.oo august.oo august.oo test.oo | ./august
|
||||
```
|
||||
|
||||
|
||||
+19
-19
@@ -141,34 +141,34 @@ Location: <a href="../../location.html#SE">SE</a> - <em>Kingdom of Sweden</em> (
|
||||
<!-- 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="<!---sh-->"><code> make all</code></pre>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code> STATUS: doesn't work with some compilers - please provide alternative code or fix for more compilers</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1996_august">1996 august bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</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="fu">cat</span> august.c test.oc <span class="kw">|</span> <span class="ex">./august</span> <span class="op">></span> test.oo</span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./august</span> <span class="op"><</span> test.oo</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.c test.oc | ./august > test.oo
|
||||
./august < test.oo</code></pre>
|
||||
<p>NOTE: some compilers will compile this code into infinite loops! If the above
|
||||
cat line (or one of the ones later in the try section) does not execute in a
|
||||
very short amount of time, then you may need to fix your compiler or use gcc.</p>
|
||||
<p>The above should print a <code>!</code> followed by a newline.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<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="ex">./try.sh</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>This entry can feed on itself. If you C pre-process the source,
|
||||
you can compile the interpreter:</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="fu">make</span> august.oc</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> make august.oc</code></pre>
|
||||
<p>We can now compile the interpreter as follows:</p>
|
||||
<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="fu">cat</span> august.c august.oc <span class="kw">|</span> <span class="ex">./august</span> <span class="op">></span> august.oo</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.c august.oc | ./august > august.oo</code></pre>
|
||||
<p>and use the compiled interpreter to execute some previously
|
||||
compiled code:</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="fu">cat</span> august.oo test.oo <span class="kw">|</span> <span class="ex">./august</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.oo test.oo | ./august</code></pre>
|
||||
<p>And we can have the compiled interpreter interpret itself which
|
||||
in turn compiles the test program:</p>
|
||||
<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="fu">cat</span> august.oo august.oo fac.oo <span class="kw">|</span> <span class="ex">./august</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.oo august.oo fac.oo | ./august</code></pre>
|
||||
<p>And if you have lots of spare time, you can recurse one level deeper:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> august.oo august.oo august.oo fac.oo <span class="kw">|</span> <span class="ex">./august</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.oo august.oo august.oo fac.oo | ./august</code></pre>
|
||||
<p>We (the judges) recommend that you spend some time studying this
|
||||
entry as it surely will make the ‘best of the IOCCC’ list. It was
|
||||
very well received by those who attended the IOCCC BOF.</p>
|
||||
@@ -194,13 +194,13 @@ of operators, and control constructs.</p>
|
||||
can go wrong. But this is what seasoned C programmers are used to.</p>
|
||||
<p>Assume that the interpreter has been compiled (source in <a href="august.c">august.c</a>
|
||||
and binary in august) and that we have this in a file named <code>test.oc</code>:</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> main<span class="op">()</span> <span class="op">{</span> putchar<span class="op">(</span><span class="ch">'!'</span><span class="op">);</span> putchar<span class="op">(</span><span class="ch">'</span><span class="sc">\n</span><span class="ch">'</span><span class="op">);</span> exit<span class="op">(</span><span class="dv">0</span><span class="op">);</span> <span class="op">}</span></span></code></pre></div>
|
||||
<pre class="<!---c-->"><code> main() { putchar('!'); putchar('\n'); exit(0); }</code></pre>
|
||||
<p>We can then compile by</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> august.c test.oc <span class="kw">|</span> <span class="ex">./august</span> <span class="op">></span> test.oo</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.c test.oc | ./august > test.oo</code></pre>
|
||||
<p>And run the compiled program by</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="ex">./august</span> <span class="op"><</span> test.oo</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./august < test.oo</code></pre>
|
||||
<p>Or even simpler:</p>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> august.c test.oc <span class="kw">|</span> <span class="ex">./august</span> <span class="kw">|</span> <span class="ex">./august</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.c test.oc | ./august | ./august</code></pre>
|
||||
<p>A larger example is included <a href="fac.oc">fac.oc</a>.</p>
|
||||
<p>The compiler for OC is naturally written in OC (where did you think the byte
|
||||
code came from?). It is in the file <a href="parse.oc">parse.oc</a>.</p>
|
||||
@@ -210,20 +210,20 @@ preprocessor (hey, what do you expect from a program that is this small), so we
|
||||
need to use an external one. To pre-process <a href="august.c">august.c</a> use the
|
||||
command from the Makefile, but add the <code>-E</code> flag and change 60000 to 40000,
|
||||
i.e.:</p>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-E</span> <span class="at">-DZ</span><span class="op">=</span>40000 .... august.c <span class="op">></span> august.oc</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cc -E -DZ=40000 .... august.c > august.oc</code></pre>
|
||||
<p>If <code>august.oc</code> contain some junk line starting with a <code>#</code> (most likely
|
||||
it does) then remove it like:</p>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">sed</span> <span class="at">-i</span><span class="st">''</span> <span class="st">'/^#/d'</span> august.oc</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> sed -i'' '/^#/d' august.oc</code></pre>
|
||||
<p>OK, we can now compile the interpreter:</p>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> august.c august.oc <span class="kw">|</span> <span class="ex">./august</span> <span class="op">></span> august.oo</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.c august.oc | ./august > august.oo</code></pre>
|
||||
<p>And we can run it:</p>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> august.oo test.oo <span class="kw">|</span> <span class="ex">./august</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.oo test.oo | ./august</code></pre>
|
||||
<p>Here we have the interpreter interpreting another interpreter that runs
|
||||
the program. Did you think that was too fast? Just throw in another
|
||||
level of interpretation:</p>
|
||||
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> august.oo august.oo test.oo <span class="kw">|</span> <span class="ex">./august</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.oo august.oo test.oo | ./august</code></pre>
|
||||
<p>And another…</p>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> august.oo august.oo august.oo test.oo <span class="kw">|</span> <span class="ex">./august</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cat august.oo august.oo august.oo test.oo | ./august</code></pre>
|
||||
<hr />
|
||||
<p>Fitting the byte code for the compiler into the initial comment
|
||||
was a challenge. I had to strip the compiler/interpreter of
|
||||
|
||||
Reference in new issue
Block a user