All Projects → vinta → Pangu.js

vinta / Pangu.js

Licence: mit
Paranoid text spacing in JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
SCSS
7915 projects

Projects that are alternatives of or similar to Pangu.js

Psdle
Improving everyone's favorite online download list, one loop at a time.
Stars: ✭ 141 (-95.68%)
Mutual labels:  chrome-extension, userscript
Remove Google Redirection
Remove redirection and click-tracking in Google search results.
Stars: ✭ 111 (-96.6%)
Mutual labels:  chrome-extension, userscript
Nxenhanced
Adds "quality-of-life" features to NextDNS website for a more practical usability
Stars: ✭ 58 (-98.22%)
Mutual labels:  chrome-extension, userscript
Simpread Little
简悦( SimpRead ) · 轻阅版
Stars: ✭ 216 (-93.38%)
Mutual labels:  chrome-extension, userscript
Extension Boilerplate
⚡️ A template for building cross browser extensions for Chrome, Opera & Firefox.
Stars: ✭ 2,958 (-9.4%)
Mutual labels:  chrome-extension
septum
Context-based code search tool
Stars: ✭ 25 (-99.23%)
Mutual labels:  text
allot
Parse placeholder and wildcard text commands
Stars: ✭ 51 (-98.44%)
Mutual labels:  text
todoscreensaver
A screensaver that reads a text file from somewhere on your PC.
Stars: ✭ 20 (-99.39%)
Mutual labels:  text
Sync Sofa
streaming video playback synchronizer extension
Stars: ✭ 274 (-91.61%)
Mutual labels:  chrome-extension
Ac Music Extension
Google Chrome extension that plays hourly Animal Crossing music and more while browsing!
Stars: ✭ 262 (-91.98%)
Mutual labels:  chrome-extension
Motrix Webextension
A chrome extension for the Motrix Download Manager
Stars: ✭ 253 (-92.25%)
Mutual labels:  chrome-extension
EnglishText.jl
Utilities for English-language quirks in Julia
Stars: ✭ 12 (-99.63%)
Mutual labels:  text
Blotter
A JavaScript API for drawing unconventional text effects on the web.
Stars: ✭ 2,833 (-13.23%)
Mutual labels:  text
pixi-text-style
PIXI.TextStyle Generator
Stars: ✭ 23 (-99.3%)
Mutual labels:  text
Web Archives
Browser extension for viewing archived and cached versions of web pages
Stars: ✭ 263 (-91.94%)
Mutual labels:  chrome-extension
Ananas
An easy image editor integration for your Android apps.
Stars: ✭ 186 (-94.3%)
Mutual labels:  text
ngx-linkifyjs
Angular V8 wrapper for linkifyjs - library for finding links in plain text and converting them to HTML <a> tags via linkifyjs
Stars: ✭ 40 (-98.77%)
Mutual labels:  text
Userscripts
An open-source userscript editor for Safari
Stars: ✭ 261 (-92.01%)
Mutual labels:  userscript
textlint-rule-terminology
Textlint rule to check correct terms spelling
Stars: ✭ 32 (-99.02%)
Mutual labels:  text
Kinopoisk-Watch
Скрипт, превращающий Kinopoisk.ru в онлайн - кинотеатр! 🎥
Stars: ✭ 85 (-97.4%)
Mutual labels:  userscript

為什麼你們就是不能加個空格呢?

如果你跟我一樣,每次看到網頁上的中文字和英文、數字、符號擠在一塊,就會坐立難安,忍不住想在它們之間加個空格。這個外掛(支援 Chrome 和 Firefox)正是你在網路世界走跳所需要的東西,它會自動替你在網頁中所有的中文字和半形的英文、數字、符號之間插入空白。

漢學家稱這個空白字元為「盤古之白」,因為它劈開了全形字和半形字之間的混沌。另有研究顯示,打字的時候不喜歡在中文和英文之間加空格的人,感情路都走得很辛苦,有七成的比例會在 34 歲的時候跟自己不愛的人結婚,而其餘三成的人最後只能把遺產留給自己的貓。畢竟愛情跟書寫都需要適時地留白。

與大家共勉之。

Installation

For Users

For Developers

Usage

$ npm install pangu --save
# or
$ yarn add pangu

Browser

Files are located in ./node_modules/pangu/dist/browser/.

<head>
  <script src="pangu.min.js"></script>
</head>
<script>
  const text = pangu.spacing("當你凝視著bug,bug也凝視著你");
  // text = '當你凝視著 bug,bug 也凝視著你'

  pangu.spacingElementById('main');
  pangu.spacingElementByClassName('comment');
  pangu.spacingElementByTagName('p');

  document.addEventListener('DOMContentLoaded', () => {
    // listen to any DOM change and automatically perform spacing via MutationObserver()
    pangu.autoSpacingPage();
  });
</script>

pangu.js is also available on jsDelivr and cdnjs:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/browser/pangu.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/browser/pangu.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/pangu/4.0.7/pangu.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pangu/4.0.7/pangu.min.js"></script>

You can also import pangu.js as an ES Module via jspm or Skypack:

<script type="module">
  import pangu from 'https://jspm.dev/[email protected]';
  import pangu from 'https://cdn.skypack.dev/[email protected]';
</script>

Node.js

Learn more on npm.

const pangu = require('pangu');

const text = pangu.spacing('與PM戰鬥的人,應當小心自己不要成為PM');
// text = '與 PM 戰鬥的人,應當小心自己不要成為 PM'

pangu.spacingFile('/path/to/text.txt', (err, data) => {
  console.log(data);
});

pangu.spacingFile('/path/to/text.txt')
  .then((data) => {
    console.log(data);
  })
  .catch((err) => {
    console.error(err);
  });

const data = pangu.spacingFileSync('/path/to/text.txt');

You SHOULD NOT use pangu.js directly to spacing Markdown documents, this library is specially designed for HTML webpages and plain texts without any markup language. See issue #127.

CLI

$ pangu "不能信任那些Terminal或Editor用白底的人"
不能信任那些 Terminal 或 Editor 用白底的人

$ pangu --help
usage: pangu [-h] [-v] [-t] [-f] text_or_path

pangu.js -- Paranoid text spacing for good readability, to automatically insert whitespace
between CJK and half-width characters (alphabetical letters, numerical digits and symbols).

positional arguments:
  text_or_path   the text or file path to perform spacing

optional arguments:
  -h, --help     show this help message and exit
  -v, --version  show program's version number and exit
  -t, --text     specify the input value is a text
  -f, --file     specify the input value is a file path

Testing

You need to install Node.js.

$ git clone [email protected]:vinta/pangu.js.git && cd pangu.js
$ npm install
$ npm run test

License

Released under the MIT License.

Author

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].