22-position_data.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. (function () {
  2. function RunningInNode () {
  3. return(
  4. (typeof require) == "function"
  5. &&
  6. (typeof exports) == "object"
  7. &&
  8. (typeof module) == "object"
  9. &&
  10. (typeof __filename) == "string"
  11. &&
  12. (typeof __dirname) == "string"
  13. );
  14. }
  15. if (!RunningInNode()) {
  16. if (!this.Tautologistics)
  17. this.Tautologistics = {};
  18. if (!this.Tautologistics.NodeHtmlParser)
  19. this.Tautologistics.NodeHtmlParser = {};
  20. if (!this.Tautologistics.NodeHtmlParser.Tests)
  21. this.Tautologistics.NodeHtmlParser.Tests = [];
  22. exports = {};
  23. this.Tautologistics.NodeHtmlParser.Tests.push(exports);
  24. }
  25. exports.name = "Postion data";
  26. exports.options = {
  27. handler: {}
  28. , parser: { includeLocation: true }
  29. };
  30. exports.html = "<html>\r\n\n\t<title>The Title</title><body>\nHello world\r\n\n</body>\n\n</html>";
  31. exports.expected = [
  32. {
  33. raw: 'html',
  34. data: 'html',
  35. type: 'tag',
  36. name: 'html',
  37. location: {
  38. line: 1,
  39. col: 1
  40. },
  41. children: [{
  42. raw: '\r\n\n\t',
  43. data: '\r\n\n\t',
  44. type: 'text',
  45. location: {
  46. line: 1,
  47. col: 7
  48. }
  49. }, {
  50. raw: 'title',
  51. data: 'title',
  52. type: 'tag',
  53. name: 'title',
  54. location: {
  55. line: 3,
  56. col: 2
  57. },
  58. children: [{
  59. raw: 'The Title',
  60. data: 'The Title',
  61. type: 'text',
  62. location: {
  63. line: 3,
  64. col: 9
  65. }
  66. }]
  67. }, {
  68. raw: 'body',
  69. data: 'body',
  70. type: 'tag',
  71. name: 'body',
  72. location: {
  73. line: 3,
  74. col: 26
  75. },
  76. children: [{
  77. raw: '\nHello world\r\n\n',
  78. data: '\nHello world\r\n\n',
  79. type: 'text',
  80. location: {
  81. line: 3,
  82. col: 32
  83. }
  84. }]
  85. }, {
  86. raw: '\n\n',
  87. data: '\n\n',
  88. type: 'text',
  89. location: {
  90. line: 6,
  91. col: 8
  92. }
  93. }]
  94. }
  95. ];
  96. })();