File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -161,3 +161,29 @@ $('span.abc.raw').removeClass('raw')
161161 console . warn ( err )
162162 }
163163 } )
164+
165+
166+ // regex for extra tags
167+ const spaceregex = / \s * /
168+ const notinhtmltagregex = / (? ! [ ^ < ] * > | [ ^ < > ] * < \/ ) /
169+ let coloregex = / \[ c o l o r = ( [ # | ( | ) | \s | , | \w ] * ?) \] /
170+ coloregex = new RegExp ( coloregex . source + notinhtmltagregex . source , 'g' )
171+ let nameregex = / \[ n a m e = ( .* ?) \] /
172+ let timeregex = / \[ t i m e = ( [: | , | + | - | ( | ) | \s | \w ] * ?) \] /
173+ const nameandtimeregex = new RegExp ( nameregex . source + spaceregex . source + timeregex . source + notinhtmltagregex . source , 'g' )
174+ nameregex = new RegExp ( nameregex . source + notinhtmltagregex . source , 'g' )
175+ timeregex = new RegExp ( timeregex . source + notinhtmltagregex . source , 'g' )
176+
177+ function replaceExtraTags ( html ) {
178+ html = html . replace ( coloregex , '<span class="color" data-color="$1"></span>' )
179+ html = html . replace ( nameandtimeregex , '<small><i class="fa fa-user"></i> $1 <i class="fa fa-clock-o"></i> $2</small>' )
180+ html = html . replace ( nameregex , '<small><i class="fa fa-user"></i> $1</small>' )
181+ html = html . replace ( timeregex , '<small><i class="fa fa-clock-o"></i> $1</small>' )
182+ return html
183+ }
184+
185+
186+ $ ( 'blockquote' ) . removeClass ( '.raw' ) . each ( function ( _ , elem ) {
187+ const p = $ ( elem ) . find ( 'p' )
188+ p [ 0 ] . innerHTML = replaceExtraTags ( p [ 0 ] . innerHTML ) ;
189+ } )
You can’t perform that action at this time.
0 commit comments