Read the blog

Dr. Jones

Posted on October 8, 2016 6:46 AM, Markdown


Read the blogpost about this blog :)

Blog post

Here's the complete source code on github

And here's the Markdown code for this blog post:

### Read the blogpost about this blog :)
[Blog post](https://restdb.io/blog/#!posts/57f388a0a5631e2a0000071e)

Here's the complete source code on [github](https://github.com/RestDB/clientexamples/tree/master/Blogdown)

And here's the Markdown code for this blog post:
...


Tables in Markdown

Canuto

Posted on October 5, 2016 7:18 PM, Markdown


Tables are supported in Markdown. The syntax is esoteric but effective.

A table:

Col 1Col 2Col 3
LeftCenterRight

The markup for the markdown:

    | Col 1 | Col 2 | Col 3 |
    | ---  | :---: | ---: |
    | Left | Center | Right |


Markdown in 60 seconds

Dr. Jones

Posted on October 5, 2016 7:12 PM, Tech Markdown


Markdown is just plain text which follows the Markdown language.

The Hello World code in Markdown:

# Hello world!
A paragraph in a markdown element

Learn markdown in 60 seconds here: http://commonmark.org/help/


Code highlightning

Canuto

Posted on October 4, 2016 12:48 PM, Markdown JavaScript


Writing tecnical articles with a lot of code examples or docs is a sweet spot for Markdown. Having the code syntax highlighted is a nice feature that adds readability to your text.

The exellent library http://prismjs.com enables easy code hightligning inside code blocks in Markdown. Just add the language name after the 3 backticks.

This code:

```javascript
    var x = 42;
```

Will render a html which enables the http://prismjs.com library to highlight the code:

<pre><code class="language-javascript">
var x = 42;
</code></pre>

Including prism.js

Download the CSS and JavaScript files from prism.js and include them in you project.

screenshot


Handlebars Markdown helper

Dr. Jones

Posted on October 4, 2016 12:24 PM, Tech Handlebars


In order to render an item from the database as Markdown it must be transformed from plain text to valid HTML.

The {{markdown}} helper renders the input variable as HTML, or if used with {{#markdown}} ... {{/markdown}} it renders the body Markdown text from inside the tag.

If we load some items from the database we can pass it to the Markdown helper like this.

{{#context}}
{
    "items": {
        "collection": "blogposts",
        "query": {"published": true},
        "hint": {"$orderby": {"publishdate": -1}}
    }
}
{{/context}}
<p>
{{#each item}}
    {{{markdown this.content}}}
{{/each}}
</p>

Note the 3 {{{ around the markdown tag, it's necessary to escape the HTML output from the Markdown tag into the page.


The source

Dr. Jones

Posted on October 3, 2016 7:25 PM, Handlebars Markdown


The source code for this page:

{{#context}}
{
    "posts": {
        "collection": "blogposts",
        {{#if request.query.searchterm}}
            "query": {"published": true,"_tags": {"$regex": "{{_ "replace" request.query.searchterm " " "|"}}"}},
        {{else}}
            "query": {"published": true},
        {{/if}}
        "hint": {"$orderby": {"publishdate": -1}}
    },
    "category": {
        "collection": "category",
        "query": {}
    }
}
{{/context}}
{{#inherit 'masterpage'}}
{{#block 'blogposts'}}
    {{#each posts}}
        <h2>{{title}}</h2>
        <p class="lead">
            <img class="profileimg" src="/media/{{author.0.photo}}"> <a href="#">{{author.0.name}}</a>
        </p>
        <p><span class="glyphicon glyphicon-time"></span> Posted on {{moment publishdate format="LLL"}}, 
        
        {{#each categories}}
            <span class="label label-default">{{name}}</span>
        {{/each}}
        </p>
        <hr>
        <p>{{{markdown content}}}</p>
        <hr class="blogsep">
    {{/each}}
{{/block}}
{{/inherit}}


Blog Search

About Markdown

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).