Skip to content

Instantly share code, notes, and snippets.

@garthk
Last active December 18, 2015 03:29
Show Gist options
  • Save garthk/5718391 to your computer and use it in GitHub Desktop.
Save garthk/5718391 to your computer and use it in GitHub Desktop.
rendering failure with hyperstream 0.2.0 and markdown-directory 0.1.0 under node 0.10.8..10
node_modules

Rendering Error when <!doctype html>

Hyperstream's insertions are missing their targets. Results, with extra oops comments:

<!doctype html>
<html lang="en">
  <head>
    <title></tREADMEitle>      <!-- oops -->
  </head>
  <body>
    <div id="article"></div>   <!-- oops -->
  <h1>Rendering Error</h1>     <!-- oops -->

Removing the doctype header from the template fixes the rendering errors, but then we have no doctype.

Versions

It might be wider than that combination, but I'm definitely seeing it with that combination.

<!doctype html>
<html lang="en">
<head>
<title></title>
</head>
<body>
<div id="article"></div>
</body>
</html>
#!/usr/bin/env tap --timeout 5 --stderr
var test = require('tap').test,
mdir = require('markdown-directory'),
concat = require('concat-stream'),
hyperstream = require('hyperstream'),
fs = require('fs'),
path = require('path');
test("rendering accuracy", function(t) {
t.plan(5);
var fetch = mdir(__dirname),
template = fs.createReadStream('doctemplate.html', 'utf8');
template.once('open', function (fd) {
var what = 'README',
content = fetch(what),
replacements = {
title: what,
'#article': content,
};
var editor = hyperstream(replacements);
template.pipe(editor).pipe(concat(function (html) {
process.stderr.write(html);
process.stderr.write('\n');
t.pass("survived");
function got(content) {
return html.indexOf(content) > 0;
}
t.ok(got('<title>README</title>'), "title rendered OK");
t.ok(got('<div id="article"><h1>'), "beginning of div insertion OK");
t.ok(got('</body>'), "</body> not lost");
t.ok(got('</html>'), "</html> not truncated");
}));
});
});
{
"name": "hsfail",
"version": "0.0.0",
"description": "demonstrates hyperstream failure",
"main": "hsfail.js",
"dependencies": {
"hyperstream": "~0.2.0",
"concat-stream": "~1.0.0",
"markdown-directory": "~0.1.0"
},
"devDependencies": {
"tap": "~0.4.3"
},
"scripts": {
"test": "node hsfail"
},
"repository": "https://gist.github.com/5718391.git",
"homepage": "https://gist.github.com/garthk/5718391",
"author": "Garth Kidd",
"license": "BSD"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment