Showing posts with label gitbook. Show all posts
Showing posts with label gitbook. Show all posts

Tuesday, November 25, 2014

The minimal amount of CSS to replicate the GitHub Markdown style

Use github-markdown.css to replicate the GitHub Markdown style:

1. Download CSS file.

2. Include it into your HTML code and add a markdown-body class to the styles:

<link rel="stylesheet" href="github-markdown.css">
<style>
    .markdown-body {
        min-width: 200px;
        max-width: 790px;
        margin: 0 auto;
        padding: 30px;
    }
</style>

3. Apply markdown-body class to any container:

<body class="markdown-body">
...
</body>

Monday, November 24, 2014

[C#] How to render GitHub-flavored markdown offline

1. Install Strike.IE package from NuGet.

2. Use the following code to generate HTML from GitHub-flavored markdown:

static public String RenderGithubMarkdow(String markdown)
{
    using (var markdownify = new Strike.IE.Markdownify())
    {
        return markdownify.Transform(markdown);
    }
}

Related posts:
  • The minimal amount of CSS to replicate the GitHub Markdown style
  • How to render GitHub-flavored markdown with GitHub API
  • [C#] How to render GitHub-flavored markdown with GitHub API

    The following code can be used to generate HTML from GitHub-flavored markdown using GitHub API:

    static public String RenderGithubMarkdow(String markdown)
    {
        var webClient = new WebClient();
        webClient.Headers.Add("User-Agent", "ghmd-renderer");
        webClient.Headers.Add("Content-Type", "text/x-markdown");
        return webClient.UploadString("https://api.github.com/markdown/raw", "POST", markdown);
    }
    

    Related posts:
  • The minimal amount of CSS to replicate the GitHub Markdown style
  • How to render GitHub-flavored markdown offline
  • Sunday, November 9, 2014

    How to build GitBook on Windows

    If you haven't done it yet, install GitBook toolchain.

    Below is a simple .CMD file to build mybook GitBook that is located in the book subdirectory. HTML version will be generated in html subdirectory, and PDF file will be generated in the same directory where .CMD file is located.

    @echo off
    
    call nodevars.bat
    
    call node %APPDATA%\npm\node_modules\gitbook-cli\bin\gitbook.js build %~dp0\book output=%~dp0\html
    
    call node %APPDATA%\npm\node_modules\gitbook-cli\bin\gitbook.js pdf %~dp0\book --output=%~dp0\mybook.pdf
    

    How to install GitBook toolchain on Windows

    1. Install Node.js from here:
    http://nodejs.org/

    2. If you want to generate books in eBook format (PDF, ePub or MOBI), then install Calibre from here:
    http://calibre-ebook.com/download

    3. If you are behind a company proxy, set Node.js to use it:
    npm config set proxy http://proxy.company.com:8080
    npm config set https-proxy http://proxy.company.com:8080
    

    4. Install gitbook-cli package:
    npm install -g gitbook-cli
    

    5. If you want to generate books in eBook format (PDF, ePub or MOBI), then install ebook-convert package:
    npm install -g ebook-convert
    

    Related post: How to build a GitBook on Windows.