UNPKG

posthtml-typograf

Version:
25 lines (19 loc) 635 B
import parser from "posthtml-parser"; import render from "posthtml-render"; import Typograf from "typograf"; const DEFAULT_OPTIONS = { htmlEntity: { type: "name" }, locale: ["ru", "en-US"], }; export function getPosthtmlTypograf(disabledRules = [], options = {}) { return (tree) => parser(typografy(render(tree), disabledRules, options)); } export function typografy(html, disabledRules = [], options = {}) { const typograf = new Typograf({ ...DEFAULT_OPTIONS, ...options }); disabledRules.forEach((rule) => typograf.disableRule(rule)); return typograf.execute(html); } export default { getPosthtmlTypograf, typografy, };