htx 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/VERSION +1 -1
  4. data/lib/htx/template.rb +109 -24
  5. data/lib/htx/version.rb +1 -1
  6. metadata +12 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbd968d3152b9ef4c7813f1e08139a4dc386ae99f8822758a0eb2574eb8beab5
4
- data.tar.gz: e2fa1f7035a09e3518be5e3fe5f8c053fd4d7d8022f6f3d121e8caecea180d6a
3
+ metadata.gz: d869f62a146bed898334d085ce1dc507d214950d166454b65e502058bc68e6b6
4
+ data.tar.gz: fd81c8b3b82f2bd95e85899f14ee35f881f11a8b0f8b07b38af1f5b0ee599a87
5
5
  SHA512:
6
- metadata.gz: 3c15b1d31a60c7447137bd599bb2e7e767896d4f8ebef93878efb5981138beddd7a712744a974ea4150edd9b511593acf1d8ca0cb6754ae04f17ffbc85ce9ed1
7
- data.tar.gz: adab39540cfe4261e26697a0a6af1081a620ab55305b38abcae5e446a919dfd5a5ac96cc01b5fa3cdd28bbbd3e6755c1c00a98f492530333ef102da43b4c5381
6
+ metadata.gz: bd23ac9b3363d467c1e47258654ed3d9a136e32e66379374b2d33a1abeeb358a1957de66364ad5af3dd20768a4ace5226ccb57c256b18b232de0381fe3144d25
7
+ data.tar.gz: e304e3e8b87c093eabc07628c0179c15eef76d9870483d96a129ce9f2f1358d0ec50df14e369e2c052aa59b992bcae2647753f3cb62f9e37de1d06b221332f4b
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2019-2023 Nate Pickens
1
+ Copyright 2019-2024 Nate Pickens
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4
4
  documentation files (the "Software"), to deal in the Software without restriction, including without
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 1.0.0
data/lib/htx/template.rb CHANGED
@@ -20,8 +20,8 @@ module HTX
20
20
  INDENT_GUESS = /^( +|\t+)(?=\S)/.freeze
21
21
  INDENT_REGEX = /\n(?=[^\n])/.freeze
22
22
 
23
- NO_SEMICOLON_BEGIN = /\A\s*[\n;}]/.freeze
24
- NO_SEMICOLON_END = /(\A|[\n;{}][^\S\n]*)\z/.freeze
23
+ AUTO_SEMICOLON_BEGIN = /\A\s*[\n;}]/.freeze
24
+ AUTO_SEMICOLON_END = /(\A|[\n;{}][^\S\n]*)\z/.freeze
25
25
 
26
26
  NEWLINE_BEGIN = /\A\s*\n/.freeze
27
27
  NEWLINE_END = /\n[^\S\n]*\z/.freeze
@@ -182,6 +182,7 @@ module HTX
182
182
  # * +xmlns+ - True if node is the descendant of a node with an xmlns attribute.
183
183
  #
184
184
  def process_element_node(node, xmlns: false)
185
+ is_template = node.name == 'template'
185
186
  children = node.children
186
187
  childless = children.empty? || (children.size == 1 && self.class.formatting_node?(children.first))
187
188
  dynamic_key = self.class.attribute_value(node.attr(DYNAMIC_KEY_ATTR))
@@ -201,19 +202,21 @@ module HTX
201
202
  dynamic_key: dynamic_key,
202
203
  )
203
204
  else
204
- append_htx_node(
205
- "'#{self.class.tag_name(node.name)}'",
206
- *attributes,
207
- dynamic_key,
208
- ELEMENT | (childless ? CHILDLESS : 0) | (xmlns ? XMLNS : 0),
209
- )
205
+ unless is_template
206
+ append_htx_node(
207
+ "'#{self.class.tag_name(node.name)}'",
208
+ *attributes,
209
+ dynamic_key,
210
+ ELEMENT | (childless ? CHILDLESS : 0) | (xmlns ? XMLNS : 0),
211
+ )
212
+ end
210
213
 
211
214
  unless childless
212
215
  children.each do |child|
213
216
  process(child, xmlns: xmlns)
214
217
  end
215
218
 
216
- @close_count += 1
219
+ @close_count += 1 unless is_template
217
220
  end
218
221
  end
219
222
  end
@@ -281,8 +284,14 @@ module HTX
281
284
 
282
285
  if (confirmed_newline || @statement_buff.match?(NEWLINE_END)) && !text.match?(NEWLINE_BEGIN)
283
286
  @statement_buff << @indent
284
- elsif !@statement_buff.match?(NO_SEMICOLON_END) && !text.match?(NO_SEMICOLON_BEGIN)
285
- @statement_buff << ";#{' ' unless text.match?(WHITESPACE_BEGIN)}"
287
+ else
288
+ unless @statement_buff.match?(AUTO_SEMICOLON_END) || text.match?(AUTO_SEMICOLON_BEGIN)
289
+ @statement_buff << ";"
290
+ end
291
+
292
+ unless @statement_buff.empty? || text.match?(WHITESPACE_BEGIN)
293
+ @statement_buff << ' '
294
+ end
286
295
  end
287
296
 
288
297
  flush if text.match?(NON_WHITESPACE)
@@ -410,24 +419,100 @@ module HTX
410
419
 
411
420
  # Source: https://developer.mozilla.org/en-US/docs/Web/SVG/Element
412
421
  TAG_MAP = %w[
413
- animateMotion animateTransform clipPath feBlend feColorMatrix feComponentTransfer feComposite
414
- feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA
415
- feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight
416
- feSpecularLighting feSpotLight feTile feTurbulence foreignObject linearGradient radialGradient
422
+ animateMotion
423
+ animateTransform
424
+ clipPath
425
+ feBlend
426
+ feColorMatrix
427
+ feComponentTransfer
428
+ feComposite
429
+ feConvolveMatrix
430
+ feDiffuseLighting
431
+ feDisplacementMap
432
+ feDistantLight
433
+ feDropShadow
434
+ feFlood
435
+ feFuncA
436
+ feFuncB
437
+ feFuncG
438
+ feFuncR
439
+ feGaussianBlur
440
+ feImage
441
+ feMerge
442
+ feMergeNode
443
+ feMorphology
444
+ feOffset
445
+ fePointLight
446
+ feSpecularLighting
447
+ feSpotLight
448
+ feTile
449
+ feTurbulence
450
+ foreignObject
451
+ linearGradient
452
+ radialGradient
417
453
  textPath
418
454
  ].map { |tag| [tag.downcase, tag] }.to_h.freeze
419
455
 
420
456
  # Source: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
421
457
  ATTR_MAP = %w[
422
- attributeName attributeType baseFrequency baseProfile calcMode clipPathUnits contentScriptType
423
- contentStyleType diffuseConstant edgeMode filterRes filterUnits glyphRef gradientTransform
424
- gradientUnits kernelMatrix kernelUnitLength keyPoints keySplines keyTimes lengthAdjust
425
- limitingConeAngle markerHeight markerUnits markerWidth maskContentUnits maskUnits numOctaves
426
- pathLength patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ
427
- preserveAlpha preserveAspectRatio primitiveUnits refX refY referrerPolicy repeatCount repeatDur
428
- requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod startOffset
429
- stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX targetY textLength viewBox
430
- viewTarget xChannelSelector yChannelSelector zoomAndPan
458
+ attributeName
459
+ attributeType
460
+ baseFrequency
461
+ baseProfile
462
+ calcMode
463
+ clipPathUnits
464
+ diffuseConstant
465
+ edgeMode
466
+ filterUnits
467
+ glyphRef
468
+ gradientTransform
469
+ gradientUnits
470
+ kernelMatrix
471
+ kernelUnitLength
472
+ keyPoints
473
+ keySplines
474
+ keyTimes
475
+ lengthAdjust
476
+ limitingConeAngle
477
+ markerHeight
478
+ markerUnits
479
+ markerWidth
480
+ maskContentUnits
481
+ maskUnits
482
+ numOctaves
483
+ pathLength
484
+ patternContentUnits
485
+ patternTransform
486
+ patternUnits
487
+ pointsAtX
488
+ pointsAtY
489
+ pointsAtZ
490
+ preserveAlpha
491
+ preserveAspectRatio
492
+ primitiveUnits
493
+ refX
494
+ refY
495
+ referrerPolicy
496
+ repeatCount
497
+ repeatDur
498
+ requiredExtensions
499
+ requiredFeatures
500
+ specularConstant
501
+ specularExponent
502
+ spreadMethod
503
+ startOffset
504
+ stdDeviation
505
+ stitchTiles
506
+ surfaceScale
507
+ systemLanguage
508
+ tableValues
509
+ targetX
510
+ targetY
511
+ textLength
512
+ viewBox
513
+ xChannelSelector
514
+ yChannelSelector
515
+ zoomAndPan
431
516
  ].map { |attr| [attr.downcase, attr] }.to_h.freeze
432
517
  end
433
518
  end
data/lib/htx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTX
4
- VERSION = '0.1.1'
4
+ VERSION = '1.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Pickens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-15 00:00:00.000000000 Z
11
+ date: 2024-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -42,22 +42,16 @@ dependencies:
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 5.11.2
48
- - - "<"
45
+ - - "~>"
49
46
  - !ruby/object:Gem::Version
50
- version: 6.0.0
47
+ version: '5.21'
51
48
  type: :development
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: 5.11.2
58
- - - "<"
52
+ - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: 6.0.0
54
+ version: '5.21'
61
55
  description: HTX is a full-featured HTML template system that is simple, lightweight,
62
56
  and highly performant. This library is a Ruby implementation of the HTX template
63
57
  compiler--it converts HTX templates to their compiled JavaScript form.
@@ -78,9 +72,9 @@ homepage: https://github.com/npickens/htx
78
72
  licenses:
79
73
  - MIT
80
74
  metadata:
81
- allowed_push_host: https://rubygems.org
82
- homepage_uri: https://github.com/npickens/htx
83
- source_code_uri: https://github.com/npickens/htx
75
+ bug_tracker_uri: https://github.com/npickens/htx/issues
76
+ documentation_uri: https://github.com/npickens/htx/blob/1.0.0/README.md
77
+ source_code_uri: https://github.com/npickens/htx/tree/1.0.0
84
78
  post_install_message:
85
79
  rdoc_options: []
86
80
  require_paths:
@@ -89,14 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
83
  requirements:
90
84
  - - ">="
91
85
  - !ruby/object:Gem::Version
92
- version: 2.6.0
86
+ version: 3.0.0
93
87
  required_rubygems_version: !ruby/object:Gem::Requirement
94
88
  requirements:
95
89
  - - ">="
96
90
  - !ruby/object:Gem::Version
97
- version: '0'
91
+ version: 2.0.0
98
92
  requirements: []
99
- rubygems_version: 3.4.15
93
+ rubygems_version: 3.5.10
100
94
  signing_key:
101
95
  specification_version: 4
102
96
  summary: A Ruby compiler for HTX templates.