highlight.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. casper.notebook_test(function () {
  2. this.on('remote.callback', function(data){
  3. if(data.error_expected){
  4. that.test.assertEquals(
  5. data.error,
  6. true,
  7. "!highlight: " + data.provided + " errors"
  8. );
  9. }else{
  10. that.test.assertEquals(
  11. data.observed,
  12. data.expected,
  13. "highlight: " + data.provided + " as " + data.expected
  14. );
  15. }
  16. });
  17. var that = this;
  18. // syntax highlighting
  19. [
  20. {to: "gfm"},
  21. {to: "python"},
  22. {to: "ipython"},
  23. {to: "ipythongfm"},
  24. {to: "text/x-markdown", from: [".md"]},
  25. {to: "text/x-python", from: [".py", "Python"]},
  26. {to: "application/json", from: ["json", "JSON"]},
  27. {to: "text/x-ruby", from: [".rb", "ruby", "Ruby"]},
  28. {to: "application/ld+json", from: ["json-ld", "JSON-LD"]},
  29. {from: [".pyc"], error: true},
  30. {from: ["../"], error: true},
  31. {from: ["//"], error: true},
  32. ].map(function (mode) {
  33. (mode.from || []).concat(mode.to || []).map(function(from){
  34. casper.evaluate(function(from, expected, error_expected){
  35. IPython.utils.requireCodeMirrorMode(from, function(observed){
  36. window.callPhantom({
  37. provided: from,
  38. expected: expected,
  39. observed: observed,
  40. error_expected: error_expected
  41. });
  42. }, function(error){
  43. window.callPhantom({
  44. provided: from,
  45. expected: expected,
  46. error: true,
  47. error_expected: error_expected
  48. });
  49. });
  50. }, {
  51. from: from,
  52. expected: mode.to,
  53. error_expected: mode.error
  54. });
  55. });
  56. });
  57. });