plugins/previewers/prism-previewers.js
function(prefix, func, values) {
					// Default value for angle
					var angle = '180deg';

					if (/^(?:-?\d*\.?\d+(?:deg|rad)|to\b|top|right|bottom|left)/.test(values[0])) {
						angle = values.shift();
						if (angle.indexOf('to ') < 0) {
							// Angle uses old keywords
							// W3C syntax uses "to" + opposite keywords
							if (angle.indexOf('top') >= 0) {
								if (angle.indexOf('left') >= 0) {
									angle = 'to bottom right';
								} else if (angle.indexOf('right') >= 0) {
									angle = 'to bottom left';
								} else {
									angle = 'to bottom';
								}
							} else if (angle.indexOf('bottom') >= 0) {
								if (angle.indexOf('left') >= 0) {
									angle = 'to top right';
								} else if (angle.indexOf('right') >= 0) {
									angle = 'to top left';
								} else {
									angle = 'to top';
								}
							} else if (angle.indexOf('left') >= 0) {
								angle = 'to right';
							} else if (angle.indexOf('right') >= 0) {
								angle = 'to left';
							} else if (prefix) {
								// Angle is shifted by 90deg in prefixed gradients
								if (angle.indexOf('deg') >= 0) {
									angle = (90 - parseFloat(angle)) + 'deg';
								} else if (angle.indexOf('rad') >= 0) {
									angle = (Math.PI / 2 - parseFloat(angle)) + 'rad';
								}
							}
						}
					}

					return func + '(' + angle + ',' + values.join(',') + ')';
				}
function(prefix, func, values) {
					// Default value for angle
					var angle = '180deg';

					if (/^(?:-?\d*\.?\d+(?:deg|rad)|to\b|top|right|bottom|left)/.test(values[0])) {
						angle = values.shift();
						if (angle.indexOf('to ') < 0) {
							// Angle uses old keywords
							// W3C syntax uses "to" + opposite keywords
							if (angle.indexOf('top') >= 0) {
								if (angle.indexOf('left') >= 0) {
									angle = 'to bottom right';
								} else if (angle.indexOf('right') >= 0) {
									angle = 'to bottom left';
								} else {
									angle = 'to bottom';
								}
							} else if (angle.indexOf('bottom') >= 0) {
								if (angle.indexOf('left') >= 0) {
									angle = 'to top right';
								} else if (angle.indexOf('right') >= 0) {
									angle = 'to top left';
								} else {
									angle = 'to top';
								}
							} else if (angle.indexOf('left') >= 0) {
								angle = 'to right';
							} else if (angle.indexOf('right') >= 0) {
								angle = 'to left';
							} else if (prefix) {
								// Angle is shifted by 90deg in prefixed gradients
								if (angle.indexOf('deg') >= 0) {
									angle = (90 - parseFloat(angle)) + 'deg';
								} else if (angle.indexOf('rad') >= 0) {
									angle = (Math.PI / 2 - parseFloat(angle)) + 'rad';
								}
							}
						}
					}

					return func + '(' + angle + ',' + values.join(',') + ')';
				}
function ( prefix , func , values ) { // Default value for angle var angle = '180deg' ; if ( / ^(?:-?\d*\.?\d+(?:deg|rad)|to\b|top|right|bottom|left) / . test ( values [ 0 ] ) ) { angle = values . shift ( ) ; if ( angle . indexOf ( 'to ' ) < 0 ) { // Angle uses old keywords // W3C syntax uses "to" + opposite keywords if ( angle . indexOf ( 'top' ) >= 0 ) { if ( angle . indexOf ( 'left' ) >= 0 ) { angle = 'to bottom right' ; } else if ( angle . indexOf ( 'right' ) >= 0 ) { angle = 'to bottom left' ; } else { angle = 'to bottom' ; } } else if ( angle . indexOf ( 'bottom' ) >= 0 ) { if ( angle . indexOf ( 'left' ) >= 0 ) { angle = 'to top right' ; } else if ( angle . indexOf ( 'right' ) >= 0 ) { angle = 'to top left' ; } else { angle = 'to top' ; } } else if ( angle . indexOf ( 'left' ) >= 0 ) { angle = 'to right' ; } else if ( angle . indexOf ( 'right' ) >= 0 ) { angle = 'to left' ; } else if ( prefix ) { // Angle is shifted by 90deg in prefixed gradients if ( angle . indexOf ( 'deg' ) >= 0 ) { angle = ( 90 - parseFloat ( angle ) ) + 'deg' ; } else if ( angle . indexOf ( 'rad' ) >= 0 ) { angle = ( Math . PI / 2 - parseFloat ( angle ) ) + 'rad' ; } } } } return func + '(' + angle + ',' + values . join ( ',' ) + ')' ; }
Returns a W3C-valid linear gradient
@param {string} prefix Vendor prefix if any ("-moz-", "-webkit-", etc.)
@param {string} func Gradient function name ("linear-gradient")
@param {string[]} values Array of the gradient function parameters (["0deg", "red 0%", "blue 100%"])
Returns a W3C - valid linear gradient