Open runarberg opened 9 years ago
@runarberg thanks for report. Would you be able to show an example for this issue?
Sure
example.md
Some basic markdown
-------------------
This text *should* be "turned into" HTML with
[marked](https://github.com/chjj/marked)---a markdown parser and
compiler--- and beautifully typeset with
[typogr](https://github.com/ekalinin/typogr.js)...
...but it isn't.
index.js
var fs = require('fs');
var marked = require('marked');
var typogr = require('typogr');
var result = '<h2 id="some-basic-markdown-">Some basic markdown</h2>\n'
+ '<p>This text <em>should</em> be “turned into” <span class="caps">HTML</span> with\n'
+ '<a href="https://github.com/chjj/marked">marked</a>—a markdown parser and\n'
+ 'compiler— and beautifully typeset with\n'
+ '<a href="https://github.com/ekalinin/typogr.js">typogr</a>…</p>\n'
+ '<p>…but it isn’t.</p>';
fs.readFile('./example.md', function(err, text) {
console.log("\ntext -> marked -> typogrify\n");
var html = marked(String(text));
console.log(typogr.typogrify(html));
console.log("\ntext -> typogrify -> marked\n");
var typeset = typogr.typogrify(String(text));
console.log(marked(typeset));
console.log("\nExpecting\n");
console.log(result);
});
Output
$ node index.js
text -> marked -> typogrify
<h2 id="some-basic-markdown">Some basic markdown</h2>
<p>This text <em>should</em> be "turned into" <span class="caps">HTML</span> with
<a href="https://github.com/chjj/marked">marked</a>—a markdown parser and
compiler— and beautifully typeset with
<a href="https://github.com/ekalinin/typogr.js">typogr</a>…</p>
<p>…but it isn't.</p>
text -> typogrify -> marked
<p>Some basic markdown
——————-</p>
<p>This text <em>should</em> be “turned into” <span class="caps">HTML</span> with
<a href="https://github.com/chjj/marked">marked</a>—a markdown parser and
compiler— and beautifully typeset with
<a href="https://github.com/ekalinin/typogr.js">typogr</a>…</p>
<p>…but it isn’t.</p>
Expecting
<h2 id="some-basic-markdown-">Some basic markdown</h2>
<p>This text <em>should</em> be “turned into” <span class="caps">HTML</span> with
<a href="https://github.com/chjj/marked">marked</a>—a markdown parser and
compiler— and beautifully typeset with
<a href="https://github.com/ekalinin/typogr.js">typogr</a>…</p>
<p>…but it isn’t.</p>
I had the same issue - I fixed it by using the smartypants option in marked (which does the same thing as the smartypants option in typogr).
This package doesn't work well with marked. Say I first run
marked
on a string of markdown, it will escape quotes to'
or&qout;
which meanstypogr.smartypants
won't typeset them. However if I first runtypogr.smartypants
on raw markdown it will change all underlined second headings to a series of em- and en-dashes, which the marked parser will subsequently miss.I suggest we either leave lone dashes between newlines alone, or we typeset html encoded quotes along with ascii encoded ones (or even both so that the order of operation won't matter).