Git Product home page Git Product logo

remark-compose's Introduction

remark-compose

Remark slide builder.

What it does?

  • Generates remark slides from HTML template and pure markdown files/templates.
  • Live server that watch for changes in template and markdown files and do output HTML regeneration.
  • Generates only what needs to be generated (like GNU make).

Motivation

  • Using markdown inside HTML you lose editor support like syntax highlighting, code outline etc. as your file is treated as HTML only. Some editors could be configured for multi-content editing but it is usually not that easy.

  • I have to maintain a large number of slide decks and want them to be consistent and easy to apply style changes to the set as a whole.

  • There is a configuration option in remark for externalizing markdown which solves first issue but you have to maintain two files per slide deck which might be a problem if you have a large number of slide decks and want them to be consistent.

  • Although, you could import all your css and js files in your HTML file and centralise style/configuration sooner or later you will have to alter HTML directly. And that is painful if you are building a large number of slide decks and would like them to be consistent.

  • These are problems only if you maintain a large set of slide decks (e.g. for teaching courses). If that is not the case than this tool would be probably an overkill.

  • All input files are treated as jinja2 templates with the same context given to the base template file. This means that you can use the full power of jinja2 (e.g. template inheritance, see examples) and have variables set in rconf file. There is a variable now in the template context of datetime type. You can use it to render date/time when the slides were built.

    For example:

# {{ title }}
{% if subtitle %}
## {{ subtitle }}
{% endif %}

Created on {{now|dtformat("%d.%m.%Y %H:%M")}}
  • Although it is motivated by remark it doesn't depend on remark in any way. You can use it with other html/javascript slides creation tools.

Installation

  • Create and activate Python virtual environment (recommended):

      $ virtualenv venv        
      New python executable in /home/igor/tmp/rmctest/venv/bin/python3
      Also creating executable in /home/igor/tmp/rmctest/venv/bin/python
      Installing setuptools, pip, wheel...done.
      
      $ source venv/bin/activate
    
  • Install/upgrade remark-compose:

      $ pip install --upgrade  https://github.com/igordejanovic/remark-compose/archive/master.zip
    

Usage

Write myconf.rconf file. Rconf is a simple DSL for the generator configuration consisting of global generator parameters and a set of rules.

  template = "path/to/template.html"

  "input/firstfile.md"
    title = "Title for the first slide deck"

  "input/secondfile.md" => "output/second_file_with_custom_out_name.html"
    title = "Title for the second slide deck"
    subtitle = "Subtitle for second slide deck"

    // Override template for this rule
    template = "path/to/other_template.html"

  "input2/*.md" => "output/"
    custom_param = "Some value"

Each .rconf rule defines input file (or glob2 pattern) and optionally output file after =>. If output file is not given it will default to the same directory and the same base name but using .html extension. Output can be directory in which case full output name is created by adding the base name of the input and .html extension.

Each rule may contain arbitrary number of additional parameters. Rule parameters will override global parameters. template parameter is used to define Jinja2 template which shall be used for output file generation. Usually we have the same template for all rules and we shall define it globally.

All parameters, either rule level or global level are passed to the template context so you can reference them from the template. E.g. in the previous example we use it for title and custom_param.

The content of input .md files will be rendered at the place of {{content}} tag inside HTML template.

For example, HTML template might look like:

<!DOCTYPE html>
<html>
    <head>
    <title>{{title}}</title>
    <meta charset="utf-8">
    <style>
        @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
        @import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
        @import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);

        body { font-family: 'Droid Serif'; }
        h1, h2, h3 {
        font-family: 'Yanone Kaffeesatz';
        font-weight: normal;
        }
        .remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
    </style>
    </head>
    <body>
    <textarea id="source">

{{content}}

    </textarea>
    <script src="https://gnab.github.io/remark/downloads/remark-latest.min.js">
    </script>
    <script>
        var slideshow = remark.create();
    </script>
    </body>
</html>

Now, to rebuild your HTML files run:

$ remarkc build myconf

To start a live server with auto-rebuild:

$ remarkc serve myconf

For help:

$ remarkc --help

or:

$ remarkc serve --help

Examples

LICENSE

MIT

remark-compose's People

Contributors

igordejanovic avatar

Watchers

James Cloos avatar Justin Morgan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.