@bookshop/hugo-engine 3.3.2 → 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.
- package/.nyc_output/{396c364e-fec4-4f27-9ff2-8b236061ef8f.json → 0f70a16f-6a79-48c7-8b16-3b4665e247b2.json} +0 -0
- package/.nyc_output/{4ef43740-059b-4329-96cd-0643fd8fe8d8.json → 6285d5fa-be3d-49e4-8f2f-82157d95dcd8.json} +0 -0
- package/.nyc_output/{656275f4-66d6-4d27-bfab-c2f7a3087670.json → 8b5e1314-6e86-4197-a3ae-3c40e4c2f39e.json} +0 -0
- package/.nyc_output/{6aec5420-0b83-4260-b300-4d595dfd0660.json → c5490eb0-70c0-468f-a43f-e58c75dd34c8.json} +0 -0
- package/.nyc_output/{874bd79b-45da-4726-9afc-1f6cab44be1f.json → ee1a9bec-d318-4aea-af93-7269debcf6df.json} +0 -0
- package/.nyc_output/processinfo/{396c364e-fec4-4f27-9ff2-8b236061ef8f.json → 0f70a16f-6a79-48c7-8b16-3b4665e247b2.json} +1 -1
- package/.nyc_output/processinfo/6285d5fa-be3d-49e4-8f2f-82157d95dcd8.json +1 -0
- package/.nyc_output/processinfo/{4ef43740-059b-4329-96cd-0643fd8fe8d8.json → 8b5e1314-6e86-4197-a3ae-3c40e4c2f39e.json} +1 -1
- package/.nyc_output/processinfo/{656275f4-66d6-4d27-bfab-c2f7a3087670.json → c5490eb0-70c0-468f-a43f-e58c75dd34c8.json} +1 -1
- package/.nyc_output/processinfo/{874bd79b-45da-4726-9afc-1f6cab44be1f.json → ee1a9bec-d318-4aea-af93-7269debcf6df.json} +1 -1
- package/.nyc_output/processinfo/index.json +1 -1
- package/bookshop-hugo-templates/bookshop.html +56 -0
- package/bookshop-hugo-templates/bookshop_bindings.html +29 -0
- package/bookshop-hugo-templates/bookshop_component_browser.html +30 -0
- package/bookshop-hugo-templates/bookshop_partial.html +42 -0
- package/bookshop-hugo-templates/bookshop_scss.html +9 -0
- package/bookshop-hugo-templates/errors/bad_bookshop_tag.html +39 -0
- package/bookshop-hugo-templates/errors/err.html +6 -0
- package/bookshop-hugo-templates/helpers/component.html +25 -0
- package/bookshop-hugo-templates/helpers/component_key.html +11 -0
- package/bookshop-hugo-templates/helpers/partial.html +25 -0
- package/bookshop-hugo-templates/helpers/partial_key.html +9 -0
- package/full-hugo-renderer/build.sh +34 -0
- package/full-hugo-renderer/go.mod +87 -0
- package/{hugo-renderer → full-hugo-renderer}/go.sum +204 -12
- package/full-hugo-renderer/hugo_renderer.wasm +0 -0
- package/full-hugo-renderer/hugo_renderer.wasm.gz +0 -0
- package/full-hugo-renderer/main.go +215 -0
- package/{hugo-renderer → full-hugo-renderer}/wasm_exec.js +6 -2
- package/lib/builder.js +2 -2
- package/lib/engine.js +109 -42
- package/lib/hugoIdentifierParser.js +5 -0
- package/lib/translateTextTemplate.js +3 -0
- package/lib/translateTextTemplate.test.js +22 -16
- package/package.json +4 -4
- package/.nyc_output/processinfo/6aec5420-0b83-4260-b300-4d595dfd0660.json +0 -1
- package/hugo-renderer/build.sh +0 -66
- package/hugo-renderer/deps/bookshop_modified_deps.go +0 -6
- package/hugo-renderer/go.mod +0 -19
- package/hugo-renderer/helpers/bookshop_modified_content.go +0 -98
- package/hugo-renderer/helpers/bookshop_modified_general.go +0 -33
- package/hugo-renderer/helpers/emoji.go +0 -96
- package/hugo-renderer/hugo_renderer.wasm +0 -0
- package/hugo-renderer/hugo_renderer.wasm.gz +0 -0
- package/hugo-renderer/main.go +0 -42
- package/hugo-renderer/tpl/bookshop_engine/bookshop_func_importer.go +0 -35
- package/hugo-renderer/tpl/bookshop_engine/bookshop_render.go +0 -64
- package/hugo-renderer/tpl/bookshop_library/bookshop_components.go +0 -129
- package/hugo-renderer/tpl/bookshop_library/bookshop_data.go +0 -53
- package/hugo-renderer/tpl/cast/cast.go +0 -63
- package/hugo-renderer/tpl/cast/init.go +0 -57
- package/hugo-renderer/tpl/collections/append.go +0 -37
- package/hugo-renderer/tpl/collections/apply.go +0 -131
- package/hugo-renderer/tpl/collections/collections.go +0 -768
- package/hugo-renderer/tpl/collections/complement.go +0 -55
- package/hugo-renderer/tpl/collections/index.go +0 -133
- package/hugo-renderer/tpl/collections/init.go +0 -214
- package/hugo-renderer/tpl/collections/merge.go +0 -126
- package/hugo-renderer/tpl/collections/reflect_helpers.go +0 -216
- package/hugo-renderer/tpl/collections/sort.go +0 -183
- package/hugo-renderer/tpl/collections/symdiff.go +0 -68
- package/hugo-renderer/tpl/collections/where.go +0 -517
- package/hugo-renderer/tpl/compare/compare.go +0 -324
- package/hugo-renderer/tpl/compare/init.go +0 -85
- package/hugo-renderer/tpl/crypto/crypto.go +0 -109
- package/hugo-renderer/tpl/crypto/init.go +0 -65
- package/hugo-renderer/tpl/debug/debug.go +0 -40
- package/hugo-renderer/tpl/debug/init.go +0 -45
- package/hugo-renderer/tpl/encoding/encoding.go +0 -90
- package/hugo-renderer/tpl/encoding/init.go +0 -59
- package/hugo-renderer/tpl/fmt/fmt.go +0 -66
- package/hugo-renderer/tpl/fmt/init.go +0 -77
- package/hugo-renderer/tpl/inflect/inflect.go +0 -79
- package/hugo-renderer/tpl/inflect/init.go +0 -60
- package/hugo-renderer/tpl/internal/bookshop_modified_templatefuncsRegistry.go +0 -88
- package/hugo-renderer/tpl/math/init.go +0 -134
- package/hugo-renderer/tpl/math/math.go +0 -164
- package/hugo-renderer/tpl/math/round.go +0 -61
- package/hugo-renderer/tpl/partials/init.go +0 -55
- package/hugo-renderer/tpl/partials/partials.go +0 -88
- package/hugo-renderer/tpl/path/init.go +0 -60
- package/hugo-renderer/tpl/path/path.go +0 -159
- package/hugo-renderer/tpl/reflect/init.go +0 -51
- package/hugo-renderer/tpl/reflect/reflect.go +0 -36
- package/hugo-renderer/tpl/safe/init.go +0 -80
- package/hugo-renderer/tpl/safe/safe.go +0 -72
- package/hugo-renderer/tpl/site/bookshop_site.go +0 -67
- package/hugo-renderer/tpl/site/init.go +0 -41
- package/hugo-renderer/tpl/strings/init.go +0 -229
- package/hugo-renderer/tpl/strings/regexp.go +0 -125
- package/hugo-renderer/tpl/strings/strings.go +0 -500
- package/hugo-renderer/tpl/strings/truncate.go +0 -157
- package/hugo-renderer/tpl/transform/bookshop_unmarshal.go +0 -39
- package/hugo-renderer/tpl/transform/init.go +0 -113
- package/hugo-renderer/tpl/transform/transform.go +0 -116
- 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 & The Sunshine Band <cathal@foo.bar>`,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
`{{ htmlEscape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>"}}`,
|
|
53
|
-
`Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&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 & The Sunshine Band <cathal@foo.bar>" | safeHTML}}`,
|
|
67
|
-
`Cathal Garvey & The Sunshine Band <cathal@foo.bar>`,
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
`{{"Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;" | htmlUnescape | htmlUnescape | safeHTML}}`,
|
|
71
|
-
`Cathal Garvey & The Sunshine Band <cathal@foo.bar>`,
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
`{{"Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;" | htmlUnescape | htmlUnescape }}`,
|
|
75
|
-
`Cathal Garvey & The Sunshine Band <cathal@foo.bar>`,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
`{{ htmlUnescape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>" | htmlEscape | safeHTML }}`,
|
|
79
|
-
`Cathal Garvey & The Sunshine Band <cathal@foo.bar>`,
|
|
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
|