Simple markdown conversion to elearn.js based HTML and PDF.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Jun 4, 2018
assets/elearnjs Update elearn.js to v1.0.11 Dec 6, 2018
scripts
src fix/PdfConverter: adapt to Puppeteer Changes Dec 6, 2018
testAssets feat/markdown-disable: add comment to disable a block Nov 11, 2018
types refa/tslint: setup tslinter, refactored code Jun 30, 2018
.gitattributes feat/test: add test report script Jul 2, 2018
.gitignore refa/typedoc: move documentation into docs/api Nov 10, 2018
.npmignore Update .npmignore Jul 3, 2018
CHANGELOG.md Update dependencies Dec 6, 2018
Jenkinsfile refa/coverage: move coverage report Nov 10, 2018
LICENSE Initial commit Jun 4, 2018
PULL_REQUEST_TEMPLATE.md Add Issue/Pull-Req. Templates Jun 4, 2018
README.md refa/coverage: move coverage report Nov 10, 2018
package-lock.json 1.7.3 Dec 6, 2018
package.json 1.7.3 Dec 6, 2018
tsconfig.json feat/PDF: switch to Puppeteer for PDF conversion Sep 17, 2018
tslint.json feat/codestyle: fix unuesed variables, Update README.md Jul 6, 2018

README.md

markdown-elearnjs

Build Status npm Test Status Test Coverage

markdown-elearnjs is a node.js package for simple markdown conversion to elearn.js based HTML and PDF. It is used for example by atom-elearnjs.

If you want to create your own conversion tool, this library will do all the actual conversion work so you can focus on the UI and additional features.

Installation

Use the following

npm install --save markdown-elearnjs

Usage

Insert this into your file

const MarkdownElearnJS = require('markdown-elearnjs');

or you can import the components you need directly

import {
    HtmlConverter,
    PdfConverter,
    ExtensionManager,
    FileExtractor,
    FileExtractorObject
} from 'markdown-elearnjs';

Conversion

To convert some markdown code to Html you can simply use

var htmlConverter = new MarkdownElearnJS.HtmlConverter();

htmlConverter.toFile(markdown, filePath, rootPath).then((filename) => {
    console.log(filename);
}, err => console.error(err));

htmlConverter.toHtml(markdown).then((html) => {
    console.log(html);
}, err => console.error(err));

Or for Pdf conversion

var pdfConverter = new MarkdownElearnJS.PdfConverter();

// save as file
pdfConverter.toFile(markdown, filePath, rootPath).then((filename) => {
    console.log(filename);
}, err => console.error(err));

//get a buffer
pdfConverter.toBuffer(markdown, rootPath).then((buffer) => {
    // do something with the buffer
}, err => console.error(err));

// only the html if you want to use your own render framework
pdfConverter.toHtml(markdown).then((html) => {
    console.log(html);
}, err => console.error(err));

You can also use conversion options in each function call and specific converter settings. Check the wiki pages.

Additional Features

The package does not only support the markdown conversion but also additional features like elearn.js extension detection, assets export and extraction of linked files. For more information on this check the wiki pages.

Known Issues

  • All platforms:
    • PDF output might be slow
      • consider keeping Chrome alive for multiple PDF exports (check settings)

Credits

  • elearn.js based for output scripts and styles.
  • Showdown used for Markdown to HTML conversion.
  • Puppeteer used for HTML to PDF conversion.

License

markdown-elearnjs is developed by dl.min of Universität Hamburg.

The software is using MIT-License.

cc-by Michael Heinecke, Arne Westphal, dl.min, Universität Hamburg