nl_tokens: Find and select HTML tag pair
pl_tokens: function matchPair ( editor , direction ) { direction = String ( ( direction || 'out' ) . toLowerCase ( ) ) ; var info = require ( 'editorUtils' ) . outputInfo ( editor ) ; var range = require ( 'range' ) ; /** @type Range */ var sel = range . create ( editor . getSelectionRange ( ) ) ; var <mask> = info . content ; // validate previous match if ( lastMatch && ! lastMatch . range . equal ( sel ) ) { lastMatch = null ; } if ( lastMatch && sel . length ( ) ) { if ( direction == 'in' ) { // user has previously selected tag and wants to move inward if ( lastMatch . type == 'tag' && ! lastMatch . close ) { // unary tag was selected, can't move inward return false ; } else { if ( lastMatch . range . equal ( lastMatch . outerRange ) ) { lastMatch . range = lastMatch . innerRange ; } else { var narrowed = require ( 'utils' ) . narrowToNonSpace ( content , lastMatch . innerRange ) ; lastMatch = matcher . find ( content , narrowed . start + 1 ) ; if ( lastMatch && lastMatch . range . equal ( sel ) && lastMatch . outerRange . equal ( sel ) ) { lastMatch . range = lastMatch . innerRange ; } } } } else { if ( ! lastMatch . innerRange . equal ( lastMatch . outerRange ) && lastMatch . range . equal ( lastMatch . innerRange ) && sel . equal ( lastMatch . range ) ) { lastMatch . range = lastMatch . outerRange ; } else { lastMatch = matcher . find ( content , sel . start ) ; if ( lastMatch && lastMatch . range . equal ( sel ) && lastMatch . innerRange . equal ( sel ) ) { lastMatch . range = lastMatch . outerRange ; } } } } else { lastMatch = matcher . find ( content , sel . start ) ; } if ( lastMatch && ! lastMatch . range . equal ( sel ) ) { editor . createSelection ( lastMatch . range . start , lastMatch . range . end ) ; return true ; } lastMatch = null ; return false ; }