Sha256: e99ea877586d09a13aa47b07e3589ecb9595c7099b918c1748bef3f25242a65f

Contents?: true

Size: 1.5 KB

Versions: 10

Compression:

Stored size: 1.5 KB

Contents

/* TODO
	Add support for Markdown notation inside doc comments
	Add support for nested block comments...
	Match closure params even when not followed by dash or brace
	Add better support for macro definition
*/

Prism.languages.rust = {
	'comment': [
		{
			pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
			lookbehind: true
		},
		{
			pattern: /(^|[^\\:])\/\/.*/,
			lookbehind: true
		}
	],
	'string': [
		/b?r(#*)"(?:\\?.)*?"\1/,
		/b?("|')(?:\\?.)*?\1/
	],
	'keyword': /\b(?:abstract|alignof|as|be|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|offsetof|once|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/,

	'attribute': {
		pattern: /#!?\[.+?\]/,
		alias: 'attr-name'
	},

	'function': [
		/[a-z0-9_]+(?=\s*\()/i,
		// Macros can use parens or brackets
		/[a-z0-9_]+!(?=\s*\(|\[)/i
	],
	'macro-rules': {
		pattern: /[a-z0-9_]+!/i,
		alias: 'function'
	},

	// Hex, oct, bin, dec numbers with visual separators and type suffix
	'number': /\b-?(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(\d(_?\d)*)?\.?\d(_?\d)*([Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64)?|f32|f64))?\b/,

	// Closure params should not be confused with bitwise OR |
	'closure-params': {
		pattern: /\|[^|]*\|(?=\s*[{-])/,
		inside: {
			'punctuation': /[\|:,]/,
			'operator': /[&*]/
		}
	},
	'punctuation': /[{}[\];(),:]|\.+|->/,
	'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
};

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
prism-rails-1.6.0.3 vendor/assets/javascripts/prism/prism-rust.js
prism-rails-1.6.0.2 vendor/assets/javascripts/prism/prism-rust.js
prism-rails-1.6.0.1 vendor/assets/javascripts/prism/prism-rust.js
prism-rails-1.5.1.2 vendor/assets/javascripts/prism-rust.js
prism-rails-1.5.1 vendor/assets/javascripts/prism-rust.js
highlighting-0.1.4 vendor/assets/javascripts/prism-rust.js
highlighting-0.1.3 vendor/assets/javascripts/prism-rust.js
highlighting-0.1.2 vendor/assets/javascripts/prism-rust.js
highlighting-0.1.1 vendor/assets/javascripts/prism-rust.js
highlighting-0.1.0 vendor/assets/javascripts/prism-rust.js