This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makes the change_background script have python syntax highlighting | |
change_background linguist-language=python |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function splitIntoPages(str, { maxLineWidth = 114, maxLines = 14, doubleNewLine = false, indentParagraph = true } = {}) { | |
// Replace any literary punctuations & newlines in the string | |
str = str | |
.replace(/“/g, '"') | |
.replace(/”/g, '"') | |
.replace(/’/g, "'") | |
.replace(/…/g, '...'); | |
// Contains widths for the majority of valid characters | |
const characterWidths = JSON.parse("{\"0\":\"6\",\"1\":\"6\",\"2\":\"6\",\"3\":\"6\",\"4\":\"6\",\"5\":\"6\",\"6\":\"6\",\"7\":\"6\",\"8\":\"6\",\"9\":\"6\",\" \":\"4\",\"!\":\"2\",\"\\\"\":\"5\",\"#\":\"6\",\"$\":\"6\",\"%\":\"6\",\"&\":\"6\",\"'\":\"3\",\"(\":\"5\",\")\":\"5\",\"*\":\"5\",\"+\":\"6\",\",\":\"2\",\"-\":\"6\",\".\":\"2\",\"/\":\"6\",\":\":\"2\",\";\":\"2\",\"<\":\"5\",\">\":\"5\",\"?\":\"6\",\"@\":\"7\",\"A\":\"6\",\"B\":\"6\",\"C\":\"6\",\"D\":\"6\",\"E\":\"6\",\"F\":\"6\",\"G\":\"6\",\"H\":\"6\",\"I\":\"4\",\"J\":\"6\",\"K\":\"6\",\"L\":\"6\",\"M\":\"6\",\"N\":\"6\",\"O\":\"6\",\"P\":\"6\",\"Q\":\"6\",\"R\":\"6\",\"S\":\"6\",\"T\":\"6\",\" |