better_html 1.0.15 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -0
  3. data/Rakefile +19 -14
  4. data/ext/better_html_ext/better_html.h +1 -0
  5. data/ext/better_html_ext/extconf.rb +16 -0
  6. data/ext/better_html_ext/html_tokenizer.c +12 -0
  7. data/ext/better_html_ext/html_tokenizer.h +7 -0
  8. data/ext/better_html_ext/parser.c +793 -0
  9. data/ext/better_html_ext/parser.h +93 -0
  10. data/ext/better_html_ext/tokenizer.c +717 -0
  11. data/ext/better_html_ext/tokenizer.h +80 -0
  12. data/lib/better_html/ast/iterator.rb +14 -9
  13. data/lib/better_html/ast/node.rb +4 -2
  14. data/lib/better_html/better_erb/erubi_implementation.rb +43 -39
  15. data/lib/better_html/better_erb/runtime_checks.rb +140 -133
  16. data/lib/better_html/better_erb/validated_output_buffer.rb +30 -22
  17. data/lib/better_html/better_erb.rb +47 -56
  18. data/lib/better_html/config.rb +7 -4
  19. data/lib/better_html/errors.rb +15 -2
  20. data/lib/better_html/helpers.rb +7 -3
  21. data/lib/better_html/html_attributes.rb +6 -2
  22. data/lib/better_html/parser.rb +22 -14
  23. data/lib/better_html/railtie.rb +8 -4
  24. data/lib/better_html/test_helper/ruby_node.rb +15 -10
  25. data/lib/better_html/test_helper/safe_erb/allowed_script_type.rb +8 -4
  26. data/lib/better_html/test_helper/safe_erb/base.rb +12 -9
  27. data/lib/better_html/test_helper/safe_erb/no_javascript_tag_helper.rb +7 -3
  28. data/lib/better_html/test_helper/safe_erb/no_statements.rb +7 -3
  29. data/lib/better_html/test_helper/safe_erb/script_interpolation.rb +9 -4
  30. data/lib/better_html/test_helper/safe_erb/tag_interpolation.rb +23 -20
  31. data/lib/better_html/test_helper/safe_erb_tester.rb +34 -32
  32. data/lib/better_html/test_helper/safe_lodash_tester.rb +36 -35
  33. data/lib/better_html/test_helper/safety_error.rb +2 -0
  34. data/lib/better_html/tokenizer/base_erb.rb +19 -15
  35. data/lib/better_html/tokenizer/html_erb.rb +3 -2
  36. data/lib/better_html/tokenizer/html_lodash.rb +22 -14
  37. data/lib/better_html/tokenizer/javascript_erb.rb +3 -1
  38. data/lib/better_html/tokenizer/location.rb +17 -6
  39. data/lib/better_html/tokenizer/token.rb +2 -0
  40. data/lib/better_html/tokenizer/token_array.rb +8 -8
  41. data/lib/better_html/tree/attribute.rb +10 -6
  42. data/lib/better_html/tree/attributes_list.rb +9 -5
  43. data/lib/better_html/tree/tag.rb +10 -6
  44. data/lib/better_html/version.rb +3 -1
  45. data/lib/better_html.rb +19 -17
  46. data/lib/tasks/better_html_tasks.rake +1 -0
  47. metadata +39 -147
  48. data/lib/better_html/better_erb/erubis_implementation.rb +0 -44
  49. data/test/better_html/better_erb/implementation_test.rb +0 -406
  50. data/test/better_html/errors_test.rb +0 -13
  51. data/test/better_html/helpers_test.rb +0 -49
  52. data/test/better_html/parser_test.rb +0 -314
  53. data/test/better_html/test_helper/ruby_node_test.rb +0 -288
  54. data/test/better_html/test_helper/safe_erb/allowed_script_type_test.rb +0 -46
  55. data/test/better_html/test_helper/safe_erb/no_javascript_tag_helper_test.rb +0 -37
  56. data/test/better_html/test_helper/safe_erb/no_statements_test.rb +0 -129
  57. data/test/better_html/test_helper/safe_erb/script_interpolation_test.rb +0 -149
  58. data/test/better_html/test_helper/safe_erb/tag_interpolation_test.rb +0 -303
  59. data/test/better_html/test_helper/safe_lodash_tester_test.rb +0 -90
  60. data/test/better_html/tokenizer/html_erb_test.rb +0 -180
  61. data/test/better_html/tokenizer/html_lodash_test.rb +0 -98
  62. data/test/better_html/tokenizer/location_test.rb +0 -75
  63. data/test/better_html/tokenizer/token_array_test.rb +0 -146
  64. data/test/better_html/tokenizer/token_test.rb +0 -15
  65. data/test/dummy/README.rdoc +0 -28
  66. data/test/dummy/Rakefile +0 -6
  67. data/test/dummy/app/assets/javascripts/application.js +0 -13
  68. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  69. data/test/dummy/app/controllers/application_controller.rb +0 -5
  70. data/test/dummy/app/helpers/application_helper.rb +0 -2
  71. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  72. data/test/dummy/bin/bundle +0 -3
  73. data/test/dummy/bin/rails +0 -4
  74. data/test/dummy/bin/rake +0 -4
  75. data/test/dummy/bin/setup +0 -29
  76. data/test/dummy/config/application.rb +0 -26
  77. data/test/dummy/config/boot.rb +0 -5
  78. data/test/dummy/config/database.yml +0 -25
  79. data/test/dummy/config/environment.rb +0 -5
  80. data/test/dummy/config/environments/development.rb +0 -41
  81. data/test/dummy/config/environments/production.rb +0 -79
  82. data/test/dummy/config/environments/test.rb +0 -42
  83. data/test/dummy/config/initializers/assets.rb +0 -11
  84. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  85. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  86. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  87. data/test/dummy/config/initializers/inflections.rb +0 -16
  88. data/test/dummy/config/initializers/mime_types.rb +0 -4
  89. data/test/dummy/config/initializers/session_store.rb +0 -3
  90. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  91. data/test/dummy/config/locales/en.yml +0 -23
  92. data/test/dummy/config/routes.rb +0 -56
  93. data/test/dummy/config/secrets.yml +0 -22
  94. data/test/dummy/config.ru +0 -4
  95. data/test/dummy/public/404.html +0 -67
  96. data/test/dummy/public/422.html +0 -67
  97. data/test/dummy/public/500.html +0 -66
  98. data/test/dummy/public/favicon.ico +0 -0
  99. data/test/test_helper.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6a028523ef92bb33a8ec5d7c7236086b98057c8f9585b01f40aa33ab10ed6dc
4
- data.tar.gz: ce8b217ae3543b998969a4d9ef03a4ef66d84e1b501724339c1fdf790ee2ecc2
3
+ metadata.gz: ac75570144a95e0a5a28f54dc99f265192ec4727d96b960ada7a97fd47851194
4
+ data.tar.gz: a29a57f1969999dd394336dd785facc3ca5432e326397e0c4dcfb745f7df79b9
5
5
  SHA512:
6
- metadata.gz: 233ba0bec33c08fb81b33b2d69783cfe26aac27db4c9487b1a0f6aa78b5d81e8de7982bf09110c8e033eed957b202f5520026070fb21fe4f0a90848e180cc912
7
- data.tar.gz: '08fcd850bed062e0e7fb3d8a9b0e9aa3d3f1df17db101cc9af5a04ecccc2a6aeebe406405684dc31b4d034b585eaeae4357f8248cfff5bbdb9afd539598c73da'
6
+ metadata.gz: 0341b84eb8f09fe099f3aefe91edad0e99064113070336d76ebc6d4ffbd341189ee6c8cb41b2011c89ca1e42c63227d2fc41db736e3c3f3ac0474db071c02cf5
7
+ data.tar.gz: 725880baa643e0589c6a781dcb28f8437e3ccab29b58d7a460ea1ec4e4bb3320dc6d9ef1b1a770a40909a8c3adaacda623bdb163ef4fa96819a7ec3f40ebca0f
data/MIT-LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+ Copyright 2022-present Shopify Inc.
1
2
  Copyright 2016 Francois Chagnon
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person obtaining
data/Rakefile CHANGED
@@ -1,28 +1,33 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
- require 'bundler/setup'
4
+ require "bundler/setup"
3
5
  require "bundler/gem_tasks"
4
6
  rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
6
8
  end
7
9
 
8
- require 'rdoc/task'
10
+ require "rake/extensiontask"
11
+
12
+ Rake::ExtensionTask.new("better_html_ext")
13
+
14
+ require "rdoc/task"
9
15
 
10
16
  RDoc::Task.new(:rdoc) do |rdoc|
11
- rdoc.rdoc_dir = 'rdoc'
12
- rdoc.title = 'BetterHtml'
13
- rdoc.options << '--line-numbers'
14
- rdoc.rdoc_files.include('README.rdoc')
15
- rdoc.rdoc_files.include('lib/**/*.rb')
17
+ rdoc.rdoc_dir = "rdoc"
18
+ rdoc.title = "BetterHtml"
19
+ rdoc.options << "--line-numbers"
20
+ rdoc.rdoc_files.include("README.rdoc")
21
+ rdoc.rdoc_files.include("lib/**/*.rb")
16
22
  end
17
23
 
18
- require 'rake/testtask'
24
+ require "rake/testtask"
19
25
 
20
26
  Rake::TestTask.new(:test) do |t|
21
- t.libs << 'lib'
22
- t.libs << 'test'
23
- t.pattern = 'test/**/*_test.rb'
27
+ t.libs << "lib"
28
+ t.libs << "test"
29
+ t.pattern = "test/**/*_test.rb"
24
30
  t.verbose = false
25
31
  end
26
32
 
27
-
28
- task default: :test
33
+ task default: [:compile, :test]
@@ -0,0 +1 @@
1
+ #include "html_tokenizer.h"
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+
5
+ # rubocop:disable Style/GlobalVars
6
+ $CXXFLAGS += " -std=c++11 "
7
+ $CXXFLAGS += " -g -O1 -ggdb "
8
+ $CFLAGS += " -g -O1 -ggdb "
9
+
10
+ if ENV["DEBUG"]
11
+ $CXXFLAGS += " -DDEBUG "
12
+ $CFLAGS += " -DDEBUG "
13
+ end
14
+ # rubocop:enable Style/GlobalVars
15
+
16
+ create_makefile("better_html_ext")
@@ -0,0 +1,12 @@
1
+ #include <ruby.h>
2
+ #include "tokenizer.h"
3
+ #include "parser.h"
4
+
5
+ static VALUE mHtmlTokenizer = Qnil;
6
+
7
+ void Init_better_html_ext()
8
+ {
9
+ mHtmlTokenizer = rb_define_module("HtmlTokenizer");
10
+ Init_html_tokenizer_tokenizer(mHtmlTokenizer);
11
+ Init_html_tokenizer_parser(mHtmlTokenizer);
12
+ }
@@ -0,0 +1,7 @@
1
+ #pragma once
2
+
3
+ #ifdef DEBUG
4
+ #define DBG_PRINT(msg, arg...) printf("%s:%u: " msg "\n", __FUNCTION__, __LINE__, arg);
5
+ #else
6
+ #define DBG_PRINT(msg, arg...) ((void)0);
7
+ #endif