code: func replaceShortcodeTokens(source []byte, replacements map[string]string) ([]byte, error) {
  
  	if len(replacements) == 0 {
  		return source, nil
  	}
  
  	start := 0
  
  	pre := []byte(shortcodePlaceholderPrefix)
  	post := []byte("HBHB")
  	pStart := []byte("<p>")
  	pEnd := []byte("</p>")
  
  	k := bytes.Index(source[start:], pre)
  
  	for k != -1 {
  		j := start + k
  		postIdx := bytes.Index(source[j:], post)
  		if postIdx < 0 {
  			// this should never happen, but let the caller decide to panic or not
  			return nil, errors.New("illegal state in content; shortcode token missing end delim")
  		}
  
  		end := j + postIdx + 4
  
  		newVal := []byte(replacements[string(source[j:end])])
  
  		// Issue #1148: Check for wrapping p-tags <p>
  		if j >= 3 && bytes.Equal(source[j-3:j], pStart) {
  			if (k+4) < len(source) && bytes.Equal(source[end:end+4], pEnd) {
  				j -= 3
  				end += 4
  			}
  		}
  
  		// This and other cool slice tricks: https://github.com/golang/go/wiki/SliceTricks
  		source = append(source[:j], append(newVal, source[end:]...)...)
  		start = j
  		k = bytes.Index(source[start:], pre)
  
  	}
  
  	return source, nil
  }
docs: // Replace prefixed shortcode tokens with the real content.
  // Note: This function will rewrite the input slice.