@bookshop/hugo-engine 3.3.3 → 3.4.0-alpha.2

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 (96) hide show
  1. package/.nyc_output/{25f8c04a-7fe3-4d10-b99e-0688e18203ec.json → 0f70a16f-6a79-48c7-8b16-3b4665e247b2.json} +0 -0
  2. package/.nyc_output/{2c3e7d19-6b44-48be-857a-ceba6bb9bf99.json → 6285d5fa-be3d-49e4-8f2f-82157d95dcd8.json} +0 -0
  3. package/.nyc_output/{5429d932-0ea0-4757-b731-0a647f4adc5f.json → 8b5e1314-6e86-4197-a3ae-3c40e4c2f39e.json} +0 -0
  4. package/.nyc_output/{723f5a1e-49f4-48c2-8a96-069bb758bb7f.json → c5490eb0-70c0-468f-a43f-e58c75dd34c8.json} +0 -0
  5. package/.nyc_output/{e4df4511-7e66-4fa6-84ed-6bd96e3027fe.json → ee1a9bec-d318-4aea-af93-7269debcf6df.json} +0 -0
  6. package/.nyc_output/processinfo/{25f8c04a-7fe3-4d10-b99e-0688e18203ec.json → 0f70a16f-6a79-48c7-8b16-3b4665e247b2.json} +1 -1
  7. package/.nyc_output/processinfo/6285d5fa-be3d-49e4-8f2f-82157d95dcd8.json +1 -0
  8. package/.nyc_output/processinfo/{2c3e7d19-6b44-48be-857a-ceba6bb9bf99.json → 8b5e1314-6e86-4197-a3ae-3c40e4c2f39e.json} +1 -1
  9. package/.nyc_output/processinfo/{5429d932-0ea0-4757-b731-0a647f4adc5f.json → c5490eb0-70c0-468f-a43f-e58c75dd34c8.json} +1 -1
  10. package/.nyc_output/processinfo/{723f5a1e-49f4-48c2-8a96-069bb758bb7f.json → ee1a9bec-d318-4aea-af93-7269debcf6df.json} +1 -1
  11. package/.nyc_output/processinfo/index.json +1 -1
  12. package/bookshop-hugo-templates/bookshop.html +56 -0
  13. package/bookshop-hugo-templates/bookshop_bindings.html +29 -0
  14. package/bookshop-hugo-templates/bookshop_component_browser.html +30 -0
  15. package/bookshop-hugo-templates/bookshop_partial.html +42 -0
  16. package/bookshop-hugo-templates/bookshop_scss.html +9 -0
  17. package/bookshop-hugo-templates/errors/bad_bookshop_tag.html +39 -0
  18. package/bookshop-hugo-templates/errors/err.html +6 -0
  19. package/bookshop-hugo-templates/helpers/component.html +25 -0
  20. package/bookshop-hugo-templates/helpers/component_key.html +11 -0
  21. package/bookshop-hugo-templates/helpers/partial.html +25 -0
  22. package/bookshop-hugo-templates/helpers/partial_key.html +9 -0
  23. package/full-hugo-renderer/build.sh +34 -0
  24. package/full-hugo-renderer/go.mod +87 -0
  25. package/{hugo-renderer → full-hugo-renderer}/go.sum +204 -12
  26. package/full-hugo-renderer/hugo_renderer.wasm +0 -0
  27. package/full-hugo-renderer/hugo_renderer.wasm.gz +0 -0
  28. package/full-hugo-renderer/main.go +215 -0
  29. package/{hugo-renderer → full-hugo-renderer}/wasm_exec.js +6 -2
  30. package/lib/builder.js +2 -2
  31. package/lib/engine.js +109 -42
  32. package/lib/hugoIdentifierParser.js +5 -0
  33. package/lib/translateTextTemplate.js +3 -0
  34. package/lib/translateTextTemplate.test.js +22 -16
  35. package/package.json +4 -4
  36. package/.nyc_output/processinfo/e4df4511-7e66-4fa6-84ed-6bd96e3027fe.json +0 -1
  37. package/hugo-renderer/build.sh +0 -66
  38. package/hugo-renderer/deps/bookshop_modified_deps.go +0 -6
  39. package/hugo-renderer/go.mod +0 -19
  40. package/hugo-renderer/helpers/bookshop_modified_content.go +0 -98
  41. package/hugo-renderer/helpers/bookshop_modified_general.go +0 -33
  42. package/hugo-renderer/helpers/emoji.go +0 -96
  43. package/hugo-renderer/hugo_renderer.wasm +0 -0
  44. package/hugo-renderer/hugo_renderer.wasm.gz +0 -0
  45. package/hugo-renderer/main.go +0 -42
  46. package/hugo-renderer/tpl/bookshop_engine/bookshop_func_importer.go +0 -35
  47. package/hugo-renderer/tpl/bookshop_engine/bookshop_render.go +0 -64
  48. package/hugo-renderer/tpl/bookshop_library/bookshop_components.go +0 -129
  49. package/hugo-renderer/tpl/bookshop_library/bookshop_data.go +0 -53
  50. package/hugo-renderer/tpl/cast/cast.go +0 -63
  51. package/hugo-renderer/tpl/cast/init.go +0 -57
  52. package/hugo-renderer/tpl/collections/append.go +0 -37
  53. package/hugo-renderer/tpl/collections/apply.go +0 -131
  54. package/hugo-renderer/tpl/collections/collections.go +0 -768
  55. package/hugo-renderer/tpl/collections/complement.go +0 -55
  56. package/hugo-renderer/tpl/collections/index.go +0 -133
  57. package/hugo-renderer/tpl/collections/init.go +0 -214
  58. package/hugo-renderer/tpl/collections/merge.go +0 -126
  59. package/hugo-renderer/tpl/collections/reflect_helpers.go +0 -216
  60. package/hugo-renderer/tpl/collections/sort.go +0 -183
  61. package/hugo-renderer/tpl/collections/symdiff.go +0 -68
  62. package/hugo-renderer/tpl/collections/where.go +0 -517
  63. package/hugo-renderer/tpl/compare/compare.go +0 -324
  64. package/hugo-renderer/tpl/compare/init.go +0 -85
  65. package/hugo-renderer/tpl/crypto/crypto.go +0 -109
  66. package/hugo-renderer/tpl/crypto/init.go +0 -65
  67. package/hugo-renderer/tpl/debug/debug.go +0 -40
  68. package/hugo-renderer/tpl/debug/init.go +0 -45
  69. package/hugo-renderer/tpl/encoding/encoding.go +0 -90
  70. package/hugo-renderer/tpl/encoding/init.go +0 -59
  71. package/hugo-renderer/tpl/fmt/fmt.go +0 -66
  72. package/hugo-renderer/tpl/fmt/init.go +0 -77
  73. package/hugo-renderer/tpl/inflect/inflect.go +0 -79
  74. package/hugo-renderer/tpl/inflect/init.go +0 -60
  75. package/hugo-renderer/tpl/internal/bookshop_modified_templatefuncsRegistry.go +0 -88
  76. package/hugo-renderer/tpl/math/init.go +0 -134
  77. package/hugo-renderer/tpl/math/math.go +0 -164
  78. package/hugo-renderer/tpl/math/round.go +0 -61
  79. package/hugo-renderer/tpl/partials/init.go +0 -55
  80. package/hugo-renderer/tpl/partials/partials.go +0 -88
  81. package/hugo-renderer/tpl/path/init.go +0 -60
  82. package/hugo-renderer/tpl/path/path.go +0 -159
  83. package/hugo-renderer/tpl/reflect/init.go +0 -51
  84. package/hugo-renderer/tpl/reflect/reflect.go +0 -36
  85. package/hugo-renderer/tpl/safe/init.go +0 -80
  86. package/hugo-renderer/tpl/safe/safe.go +0 -72
  87. package/hugo-renderer/tpl/site/bookshop_site.go +0 -67
  88. package/hugo-renderer/tpl/site/init.go +0 -41
  89. package/hugo-renderer/tpl/strings/init.go +0 -229
  90. package/hugo-renderer/tpl/strings/regexp.go +0 -125
  91. package/hugo-renderer/tpl/strings/strings.go +0 -500
  92. package/hugo-renderer/tpl/strings/truncate.go +0 -157
  93. package/hugo-renderer/tpl/transform/bookshop_unmarshal.go +0 -39
  94. package/hugo-renderer/tpl/transform/init.go +0 -113
  95. package/hugo-renderer/tpl/transform/transform.go +0 -116
  96. package/hugo-renderer/update-from-hugo.sh +0 -19
@@ -1,113 +0,0 @@
1
- // Copyright 2017 The Hugo Authors. All rights reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
-
14
- package transform
15
-
16
- import (
17
- "hugo-renderer/deps"
18
- "hugo-renderer/tpl/internal"
19
- )
20
-
21
- const name = "transform"
22
-
23
- func init() {
24
- f := func(d *deps.Deps) *internal.TemplateFuncsNamespace {
25
- ctx := New(d)
26
-
27
- ns := &internal.TemplateFuncsNamespace{
28
- Name: name,
29
- Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
30
- }
31
-
32
- ns.AddMethodMapping(ctx.Emojify,
33
- []string{"emojify"},
34
- [][2]string{
35
- {`{{ "I :heart: Hugo" | emojify }}`, `I ❤️ Hugo`},
36
- },
37
- )
38
-
39
- ns.AddMethodMapping(ctx.Highlight,
40
- []string{"highlight"},
41
- [][2]string{},
42
- )
43
-
44
- ns.AddMethodMapping(ctx.HTMLEscape,
45
- []string{"htmlEscape"},
46
- [][2]string{
47
- {
48
- `{{ htmlEscape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>" | safeHTML}}`,
49
- `Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;`,
50
- },
51
- {
52
- `{{ htmlEscape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>"}}`,
53
- `Cathal Garvey &amp;amp; The Sunshine Band &amp;lt;cathal@foo.bar&amp;gt;`,
54
- },
55
- {
56
- `{{ htmlEscape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>" | htmlUnescape | safeHTML }}`,
57
- `Cathal Garvey & The Sunshine Band <cathal@foo.bar>`,
58
- },
59
- },
60
- )
61
-
62
- ns.AddMethodMapping(ctx.HTMLUnescape,
63
- []string{"htmlUnescape"},
64
- [][2]string{
65
- {
66
- `{{ htmlUnescape "Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;" | safeHTML}}`,
67
- `Cathal Garvey & The Sunshine Band <cathal@foo.bar>`,
68
- },
69
- {
70
- `{{"Cathal Garvey &amp;amp; The Sunshine Band &amp;lt;cathal@foo.bar&amp;gt;" | htmlUnescape | htmlUnescape | safeHTML}}`,
71
- `Cathal Garvey & The Sunshine Band <cathal@foo.bar>`,
72
- },
73
- {
74
- `{{"Cathal Garvey &amp;amp; The Sunshine Band &amp;lt;cathal@foo.bar&amp;gt;" | htmlUnescape | htmlUnescape }}`,
75
- `Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;`,
76
- },
77
- {
78
- `{{ htmlUnescape "Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;" | htmlEscape | safeHTML }}`,
79
- `Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;`,
80
- },
81
- },
82
- )
83
-
84
- ns.AddMethodMapping(ctx.Markdownify,
85
- []string{"markdownify"},
86
- [][2]string{
87
- {`{{ .Title | markdownify}}`, `<strong>BatMan</strong>`},
88
- },
89
- )
90
-
91
- ns.AddMethodMapping(ctx.Plainify,
92
- []string{"plainify"},
93
- [][2]string{
94
- {`{{ plainify "Hello <strong>world</strong>, gophers!" }}`, `Hello world, gophers!`},
95
- },
96
- )
97
-
98
- // Bookshop: remarshal has been intentionally removed due to instability
99
-
100
- // Bookshop: unmarshal has been removed (for now) due to tendrils
101
-
102
- ns.AddMethodMapping(ctx.BookshopUnmarshal,
103
- []string{"bookshopunmarshal"},
104
- [][2]string{
105
- {`{{ "{ hello = \"Hello World\" }" | transform.BookshopUnmarshal }}`, "map[hello:Hello World]"},
106
- },
107
- )
108
-
109
- return ns
110
- }
111
-
112
- internal.AddTemplateFuncsNamespace(f)
113
- }
@@ -1,116 +0,0 @@
1
- // Copyright 2017 The Hugo Authors. All rights reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
-
14
- // Package transform provides template functions for transforming content.
15
- package transform
16
-
17
- import (
18
- "html"
19
- "html/template"
20
-
21
- "github.com/gomarkdown/markdown"
22
-
23
- "hugo-renderer/deps"
24
-
25
- "hugo-renderer/helpers"
26
-
27
- "github.com/spf13/cast"
28
- )
29
-
30
- // New returns a new instance of the transform-namespaced template functions.
31
- func New(deps *deps.Deps) *Namespace {
32
- // Bookshop: Build listeners & cache intentionally removed
33
-
34
- return &Namespace{
35
- deps: deps,
36
- }
37
- }
38
-
39
- // Namespace provides template functions for the "transform" namespace.
40
- type Namespace struct {
41
- // Bookshop: Build listeners & cache intentionally removed
42
- deps *deps.Deps
43
- }
44
-
45
- // Emojify returns a copy of s with all emoji codes replaced with actual emojis.
46
- //
47
- // See http://www.emoji-cheat-sheet.com/
48
- func (ns *Namespace) Emojify(s interface{}) (template.HTML, error) {
49
- ss, err := cast.ToStringE(s)
50
- if err != nil {
51
- return "", err
52
- }
53
-
54
- return template.HTML(helpers.Emojify([]byte(ss))), nil
55
- }
56
-
57
- // Highlight returns a copy of s as an HTML string with syntax
58
- // highlighting applied.
59
- func (ns *Namespace) Highlight(s interface{}, lang string, opts ...interface{}) (template.HTML, error) {
60
- ss, err := cast.ToStringE(s)
61
- if err != nil {
62
- return "", err
63
- }
64
-
65
- // Bookshop: Highlighting logic intentionally removed for bloat
66
-
67
- return template.HTML(ss), nil
68
- }
69
-
70
- // HTMLEscape returns a copy of s with reserved HTML characters escaped.
71
- func (ns *Namespace) HTMLEscape(s interface{}) (string, error) {
72
- ss, err := cast.ToStringE(s)
73
- if err != nil {
74
- return "", err
75
- }
76
-
77
- return html.EscapeString(ss), nil
78
- }
79
-
80
- // HTMLUnescape returns a copy of with HTML escape requences converted to plain
81
- // text.
82
- func (ns *Namespace) HTMLUnescape(s interface{}) (string, error) {
83
- ss, err := cast.ToStringE(s)
84
- if err != nil {
85
- return "", err
86
- }
87
-
88
- return html.UnescapeString(ss), nil
89
- }
90
-
91
- // Markdownify renders a given input from Markdown to HTML.
92
- func (ns *Namespace) Markdownify(s interface{}) (template.HTML, error) {
93
- ss, err := cast.ToStringE(s)
94
- if err != nil {
95
- return "", err
96
- }
97
-
98
- // Bookshop: markdownify implementation has been intentionally modified for bloat
99
- // This includes using a different (smaller) markdown implementation.
100
- output := markdown.ToHTML([]byte(ss), nil, nil)
101
-
102
- // Strip if this is a short inline type of text.
103
- output = helpers.TrimShortHTML(output)
104
-
105
- return helpers.BytesToHTML(output), nil
106
- }
107
-
108
- // Plainify returns a copy of s with all HTML tags removed.
109
- func (ns *Namespace) Plainify(s interface{}) (string, error) {
110
- ss, err := cast.ToStringE(s)
111
- if err != nil {
112
- return "", err
113
- }
114
-
115
- return helpers.StripHTML(ss), nil
116
- }
@@ -1,19 +0,0 @@
1
- cd tpl
2
- HUGO_LOC="../../../../../../../Scratchpad/hugo/tpl"
3
-
4
- # Check Hugo loc
5
- if [ ! -d $HUGO_LOC ]; then
6
- echo "ERROR: hugo repo does not exist (on Liam's machine)"
7
- exit 1
8
- fi
9
-
10
- for LOCAL_FILE in **/*.go; do
11
- if [[ ! $LOCAL_FILE == *bookshop* ]]; then
12
- HUGO_FILE="$HUGO_LOC/$LOCAL_FILE"
13
- if [ ! -f $HUGO_FILE ]; then
14
- echo "WARN: File $LOCAL_FILE doesn't exist in Hugo as $HUGO_FILE"
15
- else
16
- cp $HUGO_FILE $LOCAL_FILE
17
- fi
18
- fi
19
- done