prism-erb.js 653 B

12345678910111213141516171819202122232425
  1. (function (Prism) {
  2. Prism.languages.erb = {
  3. 'delimiter': {
  4. pattern: /^(\s*)<%=?|%>(?=\s*$)/,
  5. lookbehind: true,
  6. alias: 'punctuation'
  7. },
  8. 'ruby': {
  9. pattern: /\s*\S[\s\S]*/,
  10. alias: 'language-ruby',
  11. inside: Prism.languages.ruby
  12. }
  13. };
  14. Prism.hooks.add('before-tokenize', function (env) {
  15. var erbPattern = /<%=?(?:[^\r\n]|[\r\n](?!=begin)|[\r\n]=begin\s(?:[^\r\n]|[\r\n](?!=end))*[\r\n]=end)+?%>/g;
  16. Prism.languages['markup-templating'].buildPlaceholders(env, 'erb', erbPattern);
  17. });
  18. Prism.hooks.add('after-tokenize', function (env) {
  19. Prism.languages['markup-templating'].tokenizePlaceholders(env, 'erb');
  20. });
  21. }(Prism));