File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 11/* eslint-disable */
2-
32// https://github.com/yangsibai/node-html-excerpt
43// const excerpt = require('html-excerpt');
4+
5+ const sanitizeHtml = require ( 'sanitize-html' ) ;
56const trunc = require ( 'trunc-html' ) ;
67
8+ const sanitizeOptions = {
9+ allowedTags : [ 'br' ]
10+ } ;
11+
712module . exports = function ( options = { } ) { // eslint-disable-line no-unused-vars
813 return function ( hook ) {
914
@@ -15,9 +20,8 @@ module.exports = function (options = {}) { // eslint-disable-line no-unused-vars
1520
1621 try {
1722 /* eslint no-use-before-define: 0 */ // --> OFF
18- const content = hook . data [ options . field ]
19- . replace ( / \< b r \> | \< \/ b r \> | \< \/ b r \> | \< b r \> | \< b r \\ \> | \< p \> | \< \/ p \> / ig, "\n" )
20- . replace ( / \< ( s t r o n g | b | i | b l o c k q u o t e | p r e | e m | u | h [ 1 - 6 ] | a ) > | \< \/ ( s t r o n g | b | i | b l o c k q u o t e | p r e | e m | u | h [ 1 - 6 ] | a ) > / ig, '' )
23+ const content = sanitizeHtml ( hook . data [ options . field ] , sanitizeOptions )
24+ . replace ( / \< b r \> | \< \/ b r \> | \< \/ b r \> | \< b r \> | \< b r \\ \> / ig, "\n" )
2125 . replace ( / \< p \> \< b r \> \< \/ p \> / ig, ' ' )
2226 . replace ( / ( \ ) { 2 , } / ig, ' ' )
2327 . trim ( ) ;
You can’t perform that action at this time.
0 commit comments