replace smartypants with typogr, disable typogrify by default

This commit is contained in:
daniel-j 2018-03-16 08:57:23 +01:00
parent 37f320ca26
commit a0bd04a323
5 changed files with 7 additions and 7 deletions

View file

@ -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"
},

View file

@ -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, {

View file

@ -6,7 +6,7 @@ const args = require('commander')
.option('-d, --dir <path>', 'Directory to store ebook in. Is prepended to filename')
.option('-t, --title <value>', 'Set the title of the story')
.option('-a, --author <value>', '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')

View file

@ -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'),

View file

@ -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;