Skip to content

Commit

Permalink
Support for Markdown footnotes
Browse files Browse the repository at this point in the history
  • Loading branch information
pheyvaer committed Sep 28, 2021
1 parent 70f7fef commit 821f963
Show file tree
Hide file tree
Showing 5 changed files with 641 additions and 622 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added
- Support for Markdown footnotes

### Changed
- Error handling in `RequestHandler`

## [2.2.1] - 2021-08-26

### Added
Expand Down
6 changes: 4 additions & 2 deletions lib/converters/html-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Converter = require('./converter');
const cons = require('consolidate');
const fs = require('fs-extra');
const MarkdownIt = require('markdown-it');
const mdFootNote = require('markdown-it-footnote');
const tmp = require('tmp');
const HTMLInfo = require('../models/html-info');
const pug = require('pug');
Expand Down Expand Up @@ -96,8 +97,9 @@ module.exports = class HtmlConverter extends Converter {
}
}
} catch (err) {
const error = new Error(`Converting to HTML failed.`);
const error = new Error(err.msg || err.message);
error.type = 'HTML_CONVERSION_FAILED';
error.subType = err.code;

reject(error);
}
Expand All @@ -109,7 +111,7 @@ module.exports = class HtmlConverter extends Converter {
if (engine === 'html') {
resolve(fileContent);
} else if (engine === 'md') {
const md = new MarkdownIt(markdownOptions);
const md = new MarkdownIt(markdownOptions).use(mdFootNote);
resolve(md.render(fileContent));
} else {
if (engine === 'pug') {
Expand Down
7 changes: 6 additions & 1 deletion lib/handlers/request-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ module.exports = class RequestHandler extends Handler {
const html = await converter.convert(htmlInfo[String(status)], {});
this.responseHandler.handle(res, status, 'text/html')(html);
} catch (err) {
this.logger.error(`HTML conversion failed for "${req.path}".`);
this.logger.error(`HTML conversion failed for "${req.path}": `);

if (err.message) {
this.logger.error(`${err.message}`);
}

status = 500;
const html = await converter.convert(htmlInfo[String(status)], {});
this.responseHandler.handle(res, status, 'text/html')(html);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"jsonld": "^1.6.2",
"jsonpath": "^1.0.2",
"markdown-it": "^10.0.0",
"markdown-it-footnote": "^3.0.3",
"morgan": "~1.10.0",
"n3": "^1.2.0",
"nunjucks": "^3.2.3",
Expand Down
Loading

0 comments on commit 821f963

Please sign in to comment.