Make the web more beautiful
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()
<head>
// Files are located on /node_modules/beauty.js/build/
<script src="beauty.min.js"></script>
</head>
<script>
beautyJS.beauty('text')
...
</script>
MIT