beauty.js

0.2.1 • Public • Published

beauty.js

Build Status Coverage Downloads Downloads npm version dependencies dev dependencies License

Make the web more beautiful

Use it with NPM

Install it via npm:

npm install beauty.js

And include in your project:

import beautyJS from 'beauty.js';

// default usage
beautyJS.beauty('text')
beautyJS.beauty(Element)

// custom usage of TextFormat
const format = new beautyJS.TextFormat({
  nouns: ['Apple', 'IOS']
});
format.updateNouns(['Apple', 'IOS', 'Android'])
format.formatText('text')
// all tags must closed like: <tag /> or <tag></tag>
format.formatHTMLText('<p><image src="url"/>text</p>')
// all tags must closed like: <tag></tag> and no nest
format.formatHTML('<span>text</span><span>another text</span>')

// custom usage of ParagraphFormat
const p = new beautyJS.ParagraphFormat(Element, {
    disableHanging: true, // 取消标点悬挂
    format: new beautyJS.TextFormat(), // 文本格式化
    disableFormat: true, // 禁用文本格式化
    clamp: 3,// 最多显示行数
    strict: false // 是否开启严格排版模式,默认关闭。开启后会移除【】中的内容,"" “” 替换为 「」,以「」开头,直接去掉符号,• 替换为 ·
})
// clamp
p.clamp(10) //设置展开行数

// remember destroy to avoid memory leaks
p.clear()

Use it with Script Link

<head>
  // Files are located on /node_modules/beauty.js/build/
  <script src="beauty.min.js"></script>
</head>
<script>
  beautyJS.beauty('text')
  ...
</script>

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i beauty.js

Weekly Downloads

2

Version

0.2.1

License

MIT

Unpacked Size

115 kB

Total Files

16

Last publish

Collaborators

  • alexayan