diff --git a/package.json b/package.json index 17218f7..0328861 100644 --- a/package.json +++ b/package.json @@ -39,9 +39,9 @@ "pretty-data": "^0.40.0", "request": "^2.85.0", "sanitize-filename": "^1.6.0", - "smartypants": "0.0.5", "syllable": "^3.0.0", "twemoji": "^2.5.0", + "typogr": "^0.6.7", "url-regex": "^4.1.1", "zero-fill": "^2.2.3" }, diff --git a/src/FimFic2Epub.js b/src/FimFic2Epub.js index 431f49f..03245ec 100644 --- a/src/FimFic2Epub.js +++ b/src/FimFic2Epub.js @@ -10,7 +10,7 @@ import fileType from 'file-type' import isSvg from 'is-svg' import sizeOf from 'image-size' import EventEmitter from 'events' -import { smartypantsu } from 'smartypants' +import typogr from 'typogr' import { cleanMarkup } from './cleanMarkup' import fetch from './fetch' @@ -90,7 +90,7 @@ class FimFic2Epub extends EventEmitter { this.storyId = FimFic2Epub.getStoryId(storyId) this.defaultOptions = { - typogrify: true, + typogrify: false, addCommentsLink: true, includeAuthorNotes: true, useAuthorNotesIndex: false, @@ -374,7 +374,7 @@ class FimFic2Epub extends EventEmitter { let chapter = this.chapters[i] let content = chapter.content if (this.options.typogrify) { - content = smartypantsu(content.replace(/"|”|“/g, '"').replace(/\.\.+/g, '...'), 'qde') + content = typogr(content.replace(/"/ig, '"').replace(/\.\.\.+/ig, '...')).chain().widont().smartypants().ord().value() } chain = chain.then(template.createChapter.bind(null, this, { diff --git a/src/cli.js b/src/cli.js index 89c5eab..5e1dd44 100755 --- a/src/cli.js +++ b/src/cli.js @@ -6,7 +6,7 @@ const args = require('commander') .option('-d, --dir ', 'Directory to store ebook in. Is prepended to filename') .option('-t, --title ', 'Set the title of the story') .option('-a, --author ', 'Set the author of the story') - .option('-T, --no-typogrify', 'Disable typographic fixes (smartypants)') + .option('-T, --typogrify', 'Enable typographic fixes (smart quotes, dashes, ellipsis, ordinal)') .option('-c, --no-comments-link', 'Don\'t add link to online comments') .option('-H, --no-headings', 'Don\'t add headings to chapters') .option('-b, --no-bars', 'Don\'t add chapter bars to show reading progress') diff --git a/src/main.js b/src/main.js index d76f532..e57f45a 100644 --- a/src/main.js +++ b/src/main.js @@ -253,7 +253,7 @@ let dialog = { ], ctrl.paragraphStyle())) )), m('tr', m('td.label', ''), m('td', {colspan: 2}, - m(checkbox, {checked: ctrl.typogrify(), onchange: m.withAttr('checked', ctrl.typogrify)}, 'Apply typographic fixes (smartypants)'), + m(checkbox, {checked: ctrl.typogrify(), onchange: m.withAttr('checked', ctrl.typogrify)}, 'Apply typographic fixes (smart quotes, dashes etc.)'), m(checkbox, {checked: ctrl.addChapterHeadings(), onchange: m.withAttr('checked', ctrl.addChapterHeadings)}, 'Add chapter headings, with chapter word count and time to read'), m(checkbox, {checked: ctrl.addCommentsLink(), onchange: m.withAttr('checked', ctrl.addCommentsLink)}, 'Add link to online comments (at the end of chapters)'), m(checkbox, {checked: ctrl.includeAuthorNotes(), onchange: m.withAttr('checked', ctrl.includeAuthorNotes)}, 'Include author\'s notes'), diff --git a/src/style/style.styl b/src/style/style.styl index 12c5b3f..4264719 100644 --- a/src/style/style.styl +++ b/src/style/style.styl @@ -219,7 +219,7 @@ sub { vertical-align: sub; vertical-align: -20%; } -sup { +sup, span.ord { font-size: 0.675em; line-height: 1.2; vertical-align: super;