smartypants()

套用引號、破折號與刪節號的排版式替換。

import { smartypants } from "@unifast/node";

函式簽名

function smartypants(options?: SmartypantsOptions): UnifastPlugin

參數

options?

要套用的替換項目設定

屬性型別預設值說明
quotesbooleantrue將直引號替換為彎引號
dashesbooleantrue將 – 替換為 en-dash,— 替換為 em-dash
ellipsesbooleantrue將 … 替換為刪節號字元

用法

import { compile, smartypants } from "@unifast/node";

const result = compile(md, {
  plugins: [
    smartypants({
      quotes: true,
      dashes: true,
      ellipses: true,
    }),
  ],
});

範例

排版式替換

原始碼結果
"Hello"彎式雙引號
'Hi'彎式單引號
--en-dash(–)
---em-dash(—)
...刪節號(…)