mirror of
https://github.com/wassname/template.git
synced 2026-06-27 19:33:10 +08:00
Polish on typo subs
This commit is contained in:
@@ -12,6 +12,9 @@ export default function(dom, data) {
|
||||
node.nodeName !== "PRE" &&
|
||||
node.nodeName !== "SPAN" &&
|
||||
node.nodeName !== "DT-HEADER" &&
|
||||
node.nodeName !== "DT-BYLINE" &&
|
||||
node.nodeName !== "DT-MATH" &&
|
||||
node.nodeName !== "DT-CODE" &&
|
||||
node.nodeName !== "DT-BIBLIOGRAPHY" &&
|
||||
node.nodeName !== "DT-FOOTER" &&
|
||||
node.nodeType !== 8 && //comment nodes
|
||||
@@ -19,14 +22,13 @@ export default function(dom, data) {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
while (textNodes.nextNode()) {
|
||||
var n = textNodes.currentNode,
|
||||
text = n.nodeValue;
|
||||
if (n.nodeType === 3 && text) {
|
||||
quotes(text);
|
||||
punctuation(text);
|
||||
ligatures(text);
|
||||
text = quotes(text);
|
||||
text = punctuation(text);
|
||||
text = ligatures(text);
|
||||
n.nodeValue = text;
|
||||
}
|
||||
}
|
||||
@@ -46,14 +48,14 @@ export default function(dom, data) {
|
||||
function punctuation(text){
|
||||
|
||||
// Dashes
|
||||
text = text.replace(/--/g, '–');
|
||||
text = text.replace(/ – /g,' — ');
|
||||
text = text.replace(/--/g, '\u2014');
|
||||
text = text.replace(/ \u2014 /g,"\u2009\u2014\u2009"); //this has thin spaces
|
||||
|
||||
// Elipses
|
||||
text = text.replace(/\.\.\./g,'…');
|
||||
|
||||
// Nbsp for punc with spaces
|
||||
var NBSP = ' ';
|
||||
var NBSP = "\u00a0";
|
||||
var NBSP_PUNCTUATION_START = /([«¿¡]) /g;
|
||||
var NBSP_PUNCTUATION_END = / ([\!\?:;\.,‽»])/g;
|
||||
|
||||
|
||||
Vendored
+104
-4
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -18,6 +18,9 @@
|
||||
<h2>A description of the article</h2>
|
||||
<dt-byline></dt-byline>
|
||||
<p>This is the first paragraph of the article.</p>
|
||||
<p>Test a long — dash -- here it is.</p>
|
||||
<p>Test for owner's possessive.</p>
|
||||
<p>Test for "quoting a passage." And another sentence. Or two.</p>
|
||||
<p>We can also cite <dt-cite key="gregor2015draw,mercier2011humans"></dt-cite> external publications. <dt-cite key="dong2014image,dumoulin2016guide,mordvintsev2015inceptionism"></dt-cite></p>
|
||||
</dt-article>
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import citation from "./components/citation";
|
||||
import footnote from "./components/footnote";
|
||||
import markdown from "./components/markdown";
|
||||
import code from "./components/code";
|
||||
import typeset from "./components/typeset";
|
||||
import hoverBox from "./components/hover-box-include";
|
||||
import generateCrossref from "./components/generate-crossref";
|
||||
|
||||
@@ -34,10 +35,11 @@ function renderOnLoad(dom, data) {
|
||||
code(dom, data);
|
||||
citation(dom, data);
|
||||
footnote(dom, data);
|
||||
typeset(dom, data);
|
||||
hoverBox(dom, data);
|
||||
}
|
||||
|
||||
// If we are in a browser, render automatically.
|
||||
// If we are in a browser, render automatically...
|
||||
if(window && window.document) {
|
||||
let data = {};
|
||||
renderImmediately(window.document);
|
||||
@@ -51,13 +53,13 @@ if(window && window.document) {
|
||||
});
|
||||
}
|
||||
|
||||
// For node
|
||||
// If we are in node...
|
||||
function render(dom, data) {
|
||||
renderImmediately(dom);
|
||||
renderOnLoad(dom, data);
|
||||
// Remove script tag so it doesn't run again
|
||||
// Remove script tag so it doesn't run again in the client
|
||||
let s = dom.querySelector('script[src="http://distill.pub/template.js"]');
|
||||
if (s) { s.parentElement.removeChild(s); }
|
||||
if (s) { s.parentElement.removeChild(s); };
|
||||
}
|
||||
|
||||
export {render as render};
|
||||
|
||||
Reference in New Issue
Block a user