Adding columns and typo subs

This commit is contained in:
Shan Carter
2017-02-03 15:40:11 -08:00
parent 571d437fcf
commit 1995d75cb0
2 changed files with 114 additions and 0 deletions
+18
View File
@@ -333,3 +333,21 @@ dt-article section > dt-code {
}
}
/* Rows and Columns */
.row {
display: flex;
}
.column {
flex: 1;
box-sizing: border-box;
margin-right: 24px;
margin-left: 24px;
}
.row > .column:first-of-type {
margin-left: 0;
}
.row > .column:last-of-type {
margin-right: 0;
}
+96
View File
@@ -0,0 +1,96 @@
export default function(dom, data) {
var textNodes = dom.createTreeWalker(
dom.body,
NodeFilter.ALL_ELEMENTS,
{
acceptNode: function(node) {
var isMath = (node.getAttribute && node.getAttribute("class")) ? node.getAttribute("class").includes("katex") || node.getAttribute("class").includes("MathJax") : false;
return node.nodeName !== "SCRIPT" &&
node.nodeName !== "STYLE" &&
node.nodeName !== "CODE" &&
node.nodeName !== "PRE" &&
node.nodeName !== "SPAN" &&
node.nodeName !== "DT-HEADER" &&
node.nodeName !== "DT-BIBLIOGRAPHY" &&
node.nodeName !== "DT-FOOTER" &&
node.nodeType !== 8 && //comment nodes
!isMath;
}
}
);
while (textNodes.nextNode()) {
var n = textNodes.currentNode,
text = n.nodeValue;
if (n.nodeType === 3 && text) {
quotes(text);
punctuation(text);
ligatures(text);
n.nodeValue = text;
}
}
}
/*!
* typeset - Typesetting for the web
* @version v0.1.6
* @link https://github.com/davidmerfield/Typeset.js
* @author David Merfield
*/
// which has a CC0 license
// http://creativecommons.org/publicdomain/zero/1.0/
function punctuation(text){
// Dashes
text = text.replace(/--/g, '');
text = text.replace(/ /g,' — ');
// Elipses
text = text.replace(/\.\.\./g,'…');
// Nbsp for punc with spaces
var NBSP = ' ';
var NBSP_PUNCTUATION_START = /([«¿¡]) /g;
var NBSP_PUNCTUATION_END = / ([\!\?:;\.,‽»])/g;
text = text.replace(NBSP_PUNCTUATION_START, '$1' + NBSP);
text = text.replace(NBSP_PUNCTUATION_END, NBSP + '$1');
return text;
}
function quotes(text) {
text = text
.replace(/(\W|^)"([^\s\!\?:;\.,‽»])/g, '$1\u201c$2') // beginning "
.replace(/(\u201c[^"]*)"([^"]*$|[^\u201c"]*\u201c)/g, '$1\u201d$2') // ending "
.replace(/([^0-9])"/g,'$1\u201d') // remaining " at end of word
.replace(/(\W|^)'(\S)/g, '$1\u2018$2') // beginning '
.replace(/([a-z])'([a-z])/ig, '$1\u2019$2') // conjunction's possession
.replace(/((\u2018[^']*)|[a-z])'([^0-9]|$)/ig, '$1\u2019$3') // ending '
.replace(/(\u2018)([0-9]{2}[^\u2019]*)(\u2018([^0-9]|$)|$|\u2019[a-z])/ig, '\u2019$2$3') // abbrev. years like '93
.replace(/(\B|^)\u2018(?=([^\u2019]*\u2019\b)*([^\u2019\u2018]*\W[\u2019\u2018]\b|[^\u2019\u2018]*$))/ig, '$1\u2019') // backwards apostrophe
.replace(/'''/g, '\u2034') // triple prime
.replace(/("|'')/g, '\u2033') // double prime
.replace(/'/g, '\u2032');
// Allow escaped quotes
text = text.replace(/\\“/, '\"');
text = text.replace(/\\”/, '\"');
text = text.replace(/\\/, '\'');
text = text.replace(/\\/, '\'');
return text;
}
function ligatures(text){
text = text.replace(/fi/g, 'fi');
text = text.replace(/fl/g, 'fl');
return text;
};