Browse Source

Upgrade the markdown renderer

pull/4/head
jrtechs 6 years ago
parent
commit
c213358eef
9 changed files with 56 additions and 88 deletions
  1. +1
    -2
      README.md
  2. +9
    -46
      entries/projects/ackermann-function-written-in-java.md
  3. +3
    -3
      entries/projects/batch-minecraft-launcher-with-auto-restart.md
  4. +5
    -22
      entries/projects/java-fibonacci-solver.md
  5. +3
    -1
      entries/projects/musical-floppy-drives.md
  6. +4
    -4
      entries/projects/timelapse-programming-pong.md
  7. +3
    -3
      entries/projects/timelapse-programming-zombie-game.md
  8. +27
    -6
      posts/singlePost.js
  9. +1
    -1
      server.js

+ 1
- 2
README.md View File

@ -50,9 +50,8 @@ npm install express-session
npm install mysql npm install mysql
npm install sanitizer npm install sanitizer
npm install promise npm install promise
npm install markdown
npm install markdown-to-html -g
npm install highlight npm install highlight
npm install crypto npm install crypto
npm install express-force-ssl npm install express-force-ssl
npm install remarkable
``` ```

+ 9
- 46
entries/projects/ackermann-function-written-in-java.md View File

@ -1,82 +1,45 @@
\`\`\`
```
class Ackermann_function class Ackermann_function
 {
{
    public static void main(String[] args)     public static void main(String[] args)
    {     {
        //prints intro         //prints intro
        System.out.println("This program will solve for all values in ackermann         System.out.println("This program will solve for all values in ackermann
function using recursion.1"); function using recursion.1");
        System.out.println("\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*n");
System.out.println("**************************n")
        //calls for all values of ackerman using for loop         //calls for all values of ackerman using for loop
 
        for(int i = 0; i \< 6; i ++)
        for(int i = 0; i < 6; i ++)
        {         {
            for(int j = 0; j \< 10; j ++)
            for(int j = 0; j < 10; j ++)
            {             {
                System.out.println("Ackerman (" + i + "," + j + ") is: " +                 System.out.println("Ackerman (" + i + "," + j + ") is: " +
ack(i,j)); ack(i,j));
            }             }
 
        }         }
        //test sinlge         //test sinlge
        //System.out.println(ack(3,1));         //System.out.println(ack(3,1));
    }     }
    public static int ack(int m, int n)     public static int ack(int m, int n)
    {     {
        if(m == 0)         if(m == 0)
        {         {
            return(n + 1);             return(n + 1);
        }         }
        else if(m \> 0 && n == 0)
        else if(m > 0 && n == 0)
        {         {
            return(ack(m-1,1));             return(ack(m-1,1));
        }         }
        else if(m\>0 && n \> 0);
        else if(m >0 && n > 0);
        {         {
            return(ack(m-1, ack(m,n-1)));             return(ack(m-1, ack(m,n-1)));
        }         }
    }     }
 
 }
\`\`\`
}
```
The Ackermann function is a classic example of a function that is not primitive The Ackermann function is a classic example of a function that is not primitive
recursive – you cannot solve it using loops like Fibonacci. In other words, you recursive – you cannot solve it using loops like Fibonacci. In other words, you

+ 3
- 3
entries/projects/batch-minecraft-launcher-with-auto-restart.md View File

@ -1,6 +1,6 @@
\`\`\`
```
\@echo off
@echo off
color a color a
@ -24,7 +24,7 @@ ping 127.0.0.1 -n 5
goto startServer goto startServer
\`\`\`
```
This batch script great for Minecraft servers which frequently crash – for This batch script great for Minecraft servers which frequently crash – for
whatever reason. If you want to learn more about how this script works I would whatever reason. If you want to learn more about how this script works I would

entries/projects/java-fibonacci-solve.md → entries/projects/java-fibonacci-solver.md View File

@ -7,47 +7,30 @@ Ex:
|---|---|---|---|---|---|---| |---|---|---|---|---|---|---|
| x | 1 | 1 | 2 | 3 | 5 | 8 | | x | 1 | 1 | 2 | 3 | 5 | 8 |
\`\`\`
class Fibonacci
```
class Fibonacci
{ {
   public static void main(String[] args)    public static void main(String[] args)
   {    {
       for(int i = 1; i \< 60; i ++)
       for(int i = 1; i < 60; i ++)
       {        {
               System.out.println("Fibonacci " + i + " is: t" + fib(i));                System.out.println("Fibonacci " + i + " is: t" + fib(i));
       }        }
   }    }
//recursive definition of bibonacci
//recursive definition of Fibonacci
   public static double fib(int n)    public static double fib(int n)
   {    {
       if(n == 1 \|\| n == 2)        if(n == 1 \|\| n == 2)
       {        {
           return(1);            return(1);
       }        }
       return(fib(n -1) + fib(n -2));        return(fib(n -1) + fib(n -2));
   }    }
} }
\`\`\`
```
![](media/088cc48e754c1b99e0fcd5a5eddb9d64.png) ![](media/088cc48e754c1b99e0fcd5a5eddb9d64.png)

+ 3
- 1
entries/projects/musical-floppy-drives.md View File

@ -1,3 +1,5 @@
![video](<https://youtu.be/b65Av0gy_m8>)
<iframe width="560" height="315" src="https://www.youtube.com/embed/b65Av0gy_m8" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/DBrR6sE-vaY" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
A more detailed description of how I made this will be coming soon. A more detailed description of how I made this will be coming soon.

+ 4
- 4
entries/projects/timelapse-programming-pong.md View File

@ -1,15 +1,15 @@
![video](https://youtu.be/5OZfKYzYHPM)
<iframe width="560" height="315" src="https://www.youtube.com/embed/5OZfKYzYHPM" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Downloads: Downloads:
[Demo Source Code](http://jrtechs.net/download/180/) [Demo Source Code](http://jrtechs.net/download/180/)
![A screenshot of a computer screen Description generated with very high confidence](media/ad84021445feb7021f2320f6be599ef5.png)
![](media/ad84021445feb7021f2320f6be599ef5.png)
[Extreme VB Pong](http://jrtechs.net/download/70/) [Extreme VB Pong](http://jrtechs.net/download/70/)
![A picture containing screenshot Description generated with high confidence](media/fc0a0ddf2a914b171bb3a5013e9e7b6c.png)
![](media/fc0a0ddf2a914b171bb3a5013e9e7b6c.png)
[Extreme VB Pong Source Code](http://jrtechs.net/download/182/) [Extreme VB Pong Source Code](http://jrtechs.net/download/182/)
![A screenshot of a computer screen Description generated with very high confidence](media/13f1d6d93532bfb23a03a9a4fec5f41b.png)
![](media/13f1d6d93532bfb23a03a9a4fec5f41b.png)

+ 3
- 3
entries/projects/timelapse-programming-zombie-game.md View File

@ -1,4 +1,4 @@
![video](https://www.youtube.com/watch?v=KC9zrgMt1FA)
<iframe width="560" height="315" src="https://www.youtube.com/embed/KC9zrgMt1FA" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
This is a simple zombie shooter game that I made in visual basics. The graphics This is a simple zombie shooter game that I made in visual basics. The graphics
are very basic due to copyrights that I wanted to avoid – and lack of artistic are very basic due to copyrights that I wanted to avoid – and lack of artistic
@ -11,10 +11,10 @@ from the YouTube Audio Library.
Downloads: Downloads:
![A screenshot of a computer Description generated with very high confidence](media/d3f05acc1973ea938920407511c28bff.png)
![](media/d3f05acc1973ea938920407511c28bff.png)
[Zombie Game YouTube demo](http://jrtechs.net/download/214/) [Zombie Game YouTube demo](http://jrtechs.net/download/214/)
![A screenshot of a computer Description generated with very high confidence](media/09d34d523359111041accf89c82fd6c2.png)
![](media/09d34d523359111041accf89c82fd6c2.png)
[Demo source code](http://jrtechs.net/download/211/) [Demo source code](http://jrtechs.net/download/211/)

+ 27
- 6
posts/singlePost.js View File

@ -6,6 +6,27 @@ var markdown = require( "markdown" ).markdown;
const sql = require('../utils/sql'); const sql = require('../utils/sql');
var Remarkable = require('remarkable');
var hljs = require('highlight.js') // https://highlightjs.org/
// Actual default values
var md = new Remarkable({
html: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (err) {}
}
try {
return hljs.highlightAuto(str).value;
} catch (err) {}
return ''; // use external default escaping
}
});
module.exports= module.exports=
{ {
@ -35,19 +56,19 @@ module.exports=
html +="</div>"; html +="</div>";
html += "<div class=\"w3-container\">"; html += "<div class=\"w3-container\">";
try try
{ {
sql.getCategory(post.category_id).then(function(category) sql.getCategory(post.category_id).then(function(category)
{ {
var pathName = "entries/" + category[0].url + "/" + post.url + ".md"; var pathName = "entries/" + category[0].url + "/" + post.url + ".md";
html += markdown.toHTML(utils.getFileContents(pathName).toString());
var markDown = utils.getFileContents(pathName).toString();
markDown = markDown.split("![](media/").join("![](" + "../entries/" + category[0].url + "/media/");
html += md.render(markDown);
html = html.split("<code>").join("<pre><code>");
html = html.split("</code>").join("</code></pre>");
html = html.split("\\`\\`\\`").join("```");
html = html.split("![](media/").join("![](" + "entries/" + category.url + "/media/");
html = html.split("<img").join("<img width=\"%100\" ");
html += "</div></div>"; html += "</div></div>";
res.write(html); res.write(html);
resolve() resolve()
}); });

+ 1
- 1
server.js View File

@ -41,7 +41,7 @@ app.use(function(request, res)
var filename = q.pathname; var filename = q.pathname;
//handles image requests //handles image requests
if(filename.includes("/img/") || filename.includes(".jpg"))
if(filename.includes("/img/") || filename.includes(".jpg") || filename.includes(".png"))
{ {
require("./img/image.js").main(res, filename); require("./img/image.js").main(res, filename);
} }

Loading…
Cancel
Save