UNPKG

remark-typography

Version:

Remark plugin to fix typography: quotes, dashes and so on.

11 lines (9 loc) 1.05 kB
/** * @name remark-typography * @fileoverview Remark plugin to fix typography: quotes, dashes and so on. * @version 0.6.25 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/remark-typography/} */ import{pipe as u}from"fp-ts/lib/function.js";import{visit as g}from"unist-util-visit";import{convertAll as f}from"string-apostrophes";import{convertAll as c}from"string-dashes";import{removeWidows as m}from"string-remove-widows";import{multiplicationSign as v,ellipsis as e,rightSingleQuote as $}from"codsen-utils";var y=()=>{function n(i){return m(i,{convertEntities:!1}).res}function o(i){return f(i,{convertEntities:!1}).result}function s(i){return c(i,{convertEntities:!1}).result}function l(i){return i.replace(/([^.])\.\.\.$/,`$1${e}`).replace(/([^.])\.\.\.([^.])/g,`$1${e}$2`).replace(/ x (\d)/g,` ${v} $1`)}return i=>{g(i,"text",(r,a,p)=>{let t=r.value;r.value=u(r.value,o,s,l,n),p.children[a-1]?.type==="inlineCode"&&t[0]==="'"&&t[1]==="s"&&(r.value=`${$}${r.value.slice(1)}`)})}},E=y;export{E as default};