Compare commits

..

20 Commits

Author SHA1 Message Date
952502e690 Re-enable syntax highlighting in light mode
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2025-04-12 17:56:03 -07:00
388a4f1589 style: Fix inconsistent indentation in SCSS files for clarity 2025-04-05 19:54:25 -07:00
806d3a318f Switch TODO to be a quote syntax to avoid shortcodes
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2025-03-30 23:11:35 -07:00
b06b695653 Use mutable variables instead of scratch where possible
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2025-03-30 22:45:24 -07:00
4ff04221b0 Adjust summaries to account for Hugo breaking changes
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2025-03-02 18:59:45 -08:00
c5c57405b0 Update to newer Hugo release
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2025-03-02 13:39:41 -08:00
2beded7c14 Remove bold inconsolata font
A few bold keywords aren't worth the font

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2025-02-23 14:13:25 -08:00
2b7645a572 Generate instances of variable fonts
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2025-02-23 11:28:05 -08:00
98a9d78273 Generate source offset in HTML
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-12-26 12:33:59 -08:00
0cdd2fbf64 Bundle fonts instead of using Google fonts, and patch in missing math symbols
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-12-26 11:50:13 -08:00
431d4b0990 Add new internal ref shortcodes
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-12-25 19:03:05 -08:00
9536c9fb25 Allow stripping leading whitespace from code blocks
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-12-25 19:02:44 -08:00
85ea55402e Add side-by-side shortcode
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-11-28 20:41:05 -08:00
7a263ce2e5 Do not wrap text around icon on small screens
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-11-26 19:51:40 -08:00
8b8d3c7fd0 Implement collapsing consecutive posts in a series
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-11-25 19:15:07 -08:00
dde3fb61ae Move all bergamot partials and shortcodes into theme
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-09-15 20:09:47 -07:00
378a6f2ae1 Load custom JS scripts if page specifies them
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-09-15 20:03:05 -07:00
aae8912c08 Add support for custom input modes
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-09-15 19:48:32 -07:00
84278b2e91 Update theme with missing file 2024-09-15 16:39:00 -07:00
3a281dfa8a Load presets from front matter + allow both bundled and global bergamot files
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-09-15 16:18:48 -07:00
45 changed files with 530 additions and 202 deletions

View File

@@ -42,7 +42,7 @@ const ensureObjectLanguage = () => {
} }
return window.Bergamot.ObjectLanguage; return window.Bergamot.ObjectLanguage;
} }
const parseString = (str) => { const parseBergamotObjectLanguage = (str) => {
if (!(str in parsingPromiseResolvers)) { if (!(str in parsingPromiseResolvers)) {
parsingPromiseResolvers[str] = []; parsingPromiseResolvers[str] = [];
} }
@@ -54,20 +54,21 @@ const parseString = (str) => {
} }
window.Bergamot = {}; window.Bergamot = {};
window.Bergamot.run = (inputGroup, nodeId, inputPrompt, rules, renderPreset, input) => { window.Bergamot.run = (inputGroup, nodeId, inputModes, inputPrompt, rules, renderPreset, input) => {
var app = Elm.Main.init({ var app = Elm.Main.init({
node: document.getElementById(nodeId), node: document.getElementById(nodeId),
flags: { flags: {
inputModes: { inputModes,
"Languge Term": { "custom": "Language Term" },
"Query": "query"
},
renderRules: window.Bergamot.renderPresets[renderPreset], renderRules: window.Bergamot.renderPresets[renderPreset],
rules, input rules, input
} }
}); });
app.ports.convertInput.subscribe(async ({ mode, input }) => { app.ports.convertInput.subscribe(async ({ mode, input }) => {
let query = await parseString(input); if (!(mode in window.Bergamot.inputModes)) {
app.ports.receiveConverted.send({ input, result: { error: "Improperly configured desugaring function (this is the website developer's fault)" } });
}
let query = await (window.Bergamot.inputModes[mode])(input);
if (query !== null) { if (query !== null) {
query = inputPrompt.replace("TERM", query); query = inputPrompt.replace("TERM", query);
app.ports.receiveConverted.send({ input, result: { query } }); app.ports.receiveConverted.send({ input, result: { query } });
@@ -80,7 +81,7 @@ window.Bergamot.run = (inputGroup, nodeId, inputPrompt, rules, renderPreset, inp
}; };
window.Bergamot.runPreset = (inputGroup, nodeId, presetName) => { window.Bergamot.runPreset = (inputGroup, nodeId, presetName) => {
const preset = window.Bergamot.presets[presetName]; const preset = window.Bergamot.presets[presetName];
window.Bergamot.run(inputGroup, nodeId, preset.inputPrompt, preset.rules, preset.renderPreset, preset.query || ""); window.Bergamot.run(inputGroup, nodeId, preset.inputModes, preset.inputPrompt, preset.rules, preset.renderPreset, preset.query || "");
}; };
window.Bergamot.close = (inputGroup, nodeId) => { window.Bergamot.close = (inputGroup, nodeId) => {
if (!(nodeId in loadedWidgets)) return; if (!(nodeId in loadedWidgets)) return;
@@ -94,5 +95,8 @@ window.Bergamot.close = (inputGroup, nodeId) => {
delete loadedWidgets[nodeId]; delete loadedWidgets[nodeId];
setRunning(inputGroup, false); setRunning(inputGroup, false);
} }
window.Bergamot.inputModes = {
"Bergamot Object Language": parseBergamotObjectLanguage
};
window.Bergamot.presets = {}; window.Bergamot.presets = {};
window.Bergamot.renderPresets = {}; window.Bergamot.renderPresets = {};

View File

@@ -104,12 +104,10 @@ pre code {
} }
.kr, .kd, .k { .kr, .kd, .k {
font-weight: bold;
@include var(color, code-keyword-color); @include var(color, code-keyword-color);
} }
.kt { .kt {
font-weight: bold;
@include var(color, code-type-color); @include var(color, code-type-color);
} }

45
assets/scss/fonts.scss Normal file
View File

@@ -0,0 +1,45 @@
@mixin font-inconsolata($weight) {
@font-face {
font-family: 'Inconsolata';
font-display: swap;
font-weight: $weight;
src: local('Inconsolata'),
url('../fonts/gen/Inconsolata-#{$weight}.woff2');
}
}
@mixin font-lora {
@font-face {
font-family: 'Lora';
font-display: swap;
src: local('Lora'),
url('../fonts/gen/Lora-Regular.woff2'),
url('../fonts/gen/Lora-Italic.woff2');
}
}
@mixin font-raleway($weight) {
@font-face {
font-family: 'Raleway';
font-display: swap;
font-weight: $weight;
src: local('Raleway'),
url('../fonts/gen/Raleway-#{$weight}.woff2'),
url('../fonts/gen/Raleway-#{$weight}-Italic.woff2');
}
}
@mixin font-stixgeneral {
@font-face {
font-family: 'STIXGeneral';
font-display: swap;
src: local('STIXGeneral-Regular'),
url('../fonts/STIXGeneral-Regular.ttf');
}
}
@include font-inconsolata(400);
@include font-lora();
@include font-raleway(400);
@include font-raleway(700);
@include font-stixgeneral();

View File

@@ -247,7 +247,25 @@ ul.post-list {
p.post-wordcount, p.post-status { p.post-wordcount, p.post-status {
text-align: center; text-align: center;
margin-bottom: 0.6rem; margin-bottom: 1rem;
}
.series-link {
display: flex;
align-items: center;
margin-top: 1rem;
font-size: 1.1rem;
border-top: $standard-border;
padding-top: 1rem;
.feather {
fill: none;
flex-shrink: 0;
width: 1em;
height: 1em;
margin-right: 0.5em;
}
} }
} }
@@ -312,8 +330,7 @@ figure {
That's because firefox reader mode doesn't play nice with them, and That's because firefox reader mode doesn't play nice with them, and
it seems to ignore all styles in <head>. Then, the inline style it seems to ignore all styles in <head>. Then, the inline style
in <head> uses !important to restore the display of icons, but provides in <head> uses !important to restore the display of icons, but provides
limited styling. Here, we finally apply the full extent of the feather limited styling. Here, we finally apply the full extent of the feather styles.
styles.
*/ */
.feather { .feather {
width: 1rem; width: 1rem;
@@ -384,7 +401,6 @@ figure {
} }
} }
a, .ongoing-placeholder { a, .ongoing-placeholder {
@include bordered-block; @include bordered-block;
padding: 0.5em 1em 0.5em 1em; padding: 0.5em 1em 0.5em 1em;
@@ -452,3 +468,32 @@ blockquote {
.early-navigation-wrapper { .early-navigation-wrapper {
margin-bottom: 3rem; margin-bottom: 3rem;
} }
.side-by-side {
display: flex;
}
.side-by-side-item {
flex-basis: 0;
}
.internal-ref {
text-decoration: underline;
break-inside: avoid;
&:target {
@include var(background-color, target-background-color);
border-radius: 1rem;
.internal-ref-counter {
@include var(background-color, target-background-color);
}
}
}
.internal-ref-counter {
display: inline-block;
border: $standard-border;
border-radius: 0.5rem;
padding: 0 0.25rem 0 0.25rem;
}

View File

@@ -11,7 +11,7 @@ $standard-border: $standard-border-width solid $border-color;
$font-heading: "Lora", serif; $font-heading: "Lora", serif;
$font-body: "Raleway", serif; $font-body: "Raleway", serif;
$font-code: "Inconsolata", monospace; $font-code: "Inconsolata", monospace, "STIXGeneral";
$warning-background-color: #ffee99; $warning-background-color: #ffee99;
$warning-border-color: #f5c827; $warning-border-color: #f5c827;
@@ -23,7 +23,7 @@ $target-background-color-dark: #55511c;
$code-color: #f0f0f0; $code-color: #f0f0f0;
$code-color-dark: lighten($background-color-dark, 10%); $code-color-dark: lighten($background-color-dark, 10%);
$code-token-color: black; $code-token-color: darken($primary-color, 25%);
$code-token-color-dark: $primary-color; $code-token-color-dark: $primary-color;
$code-highlight-color: #fffd99; $code-highlight-color: #fffd99;
$code-highlight-color-dark: #555538; $code-highlight-color-dark: #555538;

69
chatgpt-instance-fonts.py Normal file
View File

@@ -0,0 +1,69 @@
#!/usr/bin/env python3
"""
Instantiate variable fonts at specific weights/styles, producing static TTF files.
No subsetting, no recursive searching—just direct calls with hardcoded axis values.
Requires fontTools >= 4.0.
Genererated by ChatGTP o3-mini-high. Not human-modified.
"""
from fontTools.ttLib import TTFont
from fontTools.varLib.instancer import instantiateVariableFont
def instantiate_variable_font(input_font_path, axis_values, output_font_path):
"""
1) Loads a variable font from `input_font_path`.
2) Instantiates (flattens) it at the specified axis values (e.g. {"wght": 400}).
3) Saves the result as a static TTF at `output_font_path`.
"""
print(f"Instantiating {input_font_path} with axes={axis_values} -> {output_font_path}")
vf = TTFont(input_font_path)
static_font = instantiateVariableFont(vf, axis_values)
static_font.flavor = "woff2"
static_font.save(output_font_path)
def main():
# Inconsolata (Variable)
instantiate_variable_font(
"Inconsolata-VariableFont_wdth,wght.ttf",
{"wght": 400},
"Inconsolata-400.woff2"
)
# Lora (Variable, normal and italic)
instantiate_variable_font(
"Lora-VariableFont_wght.ttf",
{"wght": 400},
"Lora-Regular.woff2"
)
instantiate_variable_font(
"Lora-Italic-VariableFont_wght.ttf",
{"wght": 400},
"Lora-Italic.woff2"
)
# Raleway (Variable, normal and italic)
instantiate_variable_font(
"Raleway-VariableFont_wght.ttf",
{"wght": 400},
"Raleway-400.woff2"
)
instantiate_variable_font(
"Raleway-VariableFont_wght.ttf",
{"wght": 700},
"Raleway-700.woff2"
)
instantiate_variable_font(
"Raleway-Italic-VariableFont_wght.ttf",
{"wght": 400},
"Raleway-400-Italic.woff2"
)
instantiate_variable_font(
"Raleway-Italic-VariableFont_wght.ttf",
{"wght": 700},
"Raleway-700-Italic.woff2"
)
if __name__ == "__main__":
main()

View File

@@ -27,6 +27,9 @@
one = "about one minute to read" one = "about one minute to read"
other = "about {{ .Count }} minutes to read" other = "about {{ .Count }} minutes to read"
[latestInSeries]
other = "Latest in series:"
[recentPosts] [recentPosts]
other = "Recent posts" other = "Recent posts"

View File

@@ -0,0 +1,9 @@
{{ if and (eq .Type "alert") (eq .AlertType "todo") -}}
<div style="background-color: tomato; color: white; padding: 10px;">
<em>TODO: </em>{{- .Text | plainify -}}
</div>
{{- else -}}
<blockquote {{- with .Attributes.id }} id="{{ . }}"{{ end }}>
{{ .Text -}}
</blockquote>
{{- end }}

View File

@@ -1,24 +1,25 @@
{{- $scratch := newScratch -}} {{- $class := "" -}}
{{- $icon := "" -}}
{{- $absoluteDest := absLangURL .Destination -}} {{- $absoluteDest := absLangURL .Destination -}}
{{- $siteRootUrl := absLangURL "" -}} {{- $siteRootUrl := absLangURL "" -}}
{{- $isExternal := not (hasPrefix $absoluteDest $siteRootUrl) -}} {{- $isExternal := not (hasPrefix $absoluteDest $siteRootUrl) -}}
{{- $isSamePage := hasPrefix .Destination "#" -}} {{- $isSamePage := hasPrefix .Destination "#" -}}
{{- if $isSamePage -}} {{- if $isSamePage -}}
{{- $scratch.Set "class" "same-page-link" -}} {{- $class = "same-page-link" -}}
{{- if index (.Page.Scratch.Get "definedSections") .Destination -}} {{- if index (.Page.Scratch.Get "definedSections") .Destination -}}
{{- $scratch.Set "icon" "arrow-up" -}} {{- $icon = "arrow-up" -}}
{{- else -}} {{- else -}}
{{- /* Do not render "down" links because don't know how to distinguish unseen titles from paragraph links. */ -}} {{- /* Do not render "down" links because don't know how to distinguish unseen titles from paragraph links. */ -}}
{{- /* $scratch.Set "icon" "arrow-down" */ -}} {{- /* $icon = "arrow-down" */ -}}
{{- end -}} {{- end -}}
{{- else if $isExternal -}} {{- else if $isExternal -}}
{{- $scratch.Set "class" "external-link" -}} {{- $class = "external-link" -}}
{{- $scratch.Set "icon" "external-link" -}} {{- $icon = "external-link" -}}
{{- end -}} {{- end -}}
<a href="{{ .Destination | safeURL }}" <a href="{{ .Destination | safeURL }}"
{{- with .Title }} title="{{ . }}"{{ end -}} {{- with .Title }} title="{{ . }}"{{ end -}}
{{- with $scratch.Get "class" -}} {{- with $class -}}
class="{{ . }}" class="{{ . }}"
{{- end -}} {{- end -}}
{{- if (and site.Params.externalLinksInNewTab $isExternal) -}} {{- if (and site.Params.externalLinksInNewTab $isExternal) -}}
@@ -26,6 +27,6 @@
{{- end -}} {{- end -}}
> >
{{- with .Text | safeHTML }}{{ . }}{{ end -}} {{- with .Text | safeHTML }}{{ . }}{{ end -}}
{{- with $scratch.Get "icon" -}}{{- partial "icon.html" . -}}{{- end -}} {{- with $icon -}}{{- partial "icon.html" . -}}{{- end -}}
</a> </a>
{{- /* chomp trailing newline */ -}} {{- /* chomp trailing newline */ -}}

View File

@@ -2,9 +2,10 @@
{{ .Content }} {{ .Content }}
{{ i18n "recentPosts" }}: {{ i18n "recentPosts" }}:
{{ partial "uniquebyseries.html" (dict "scratch" .Scratch) }}
<ul class="post-list"> <ul class="post-list">
{{ range first 10 (where (where .Site.Pages.ByDate.Reverse "Section" "blog") ".Kind" "!=" "section") }} {{ range first 10 (.Scratch.Get "pages") }}
{{ partial "post.html" (dict "page" .) }} {{ partial "post.html" (dict "page" . "linkSeries" true) }}
{{ end }} {{ end }}
</ul> </ul>

View File

@@ -0,0 +1,6 @@
<script>
window.addEventListener('load', function() {
window.Bergamot.inputModes['{{ .name }}'] = {{ .fn | safeJS }};
});
</script>

View File

@@ -0,0 +1,17 @@
{
{{ if . }}
{{ range $name := split . ";" }}
{{ if eq $name "query" }}
"Query": "query",
{{ else }}
{{ $pieces := split $name ":" }}
{{ $name := index $pieces 0 }}
{{ $modestring := index $pieces 1 }}
"{{ $name }}": { "custom": "{{ $modestring }}" },
{{ end }}
{{ end }}
{{ else }}
"Languge Term": { "custom": "Bergamot Object Language" },
"Query": "query",
{{ end }}
}

View File

@@ -0,0 +1,11 @@
<script>
window.addEventListener('load', function() {
window.Bergamot.presets['{{ .name }}'] = {
rules: {{ .file }},
inputModes: {{ partial "bergamotparseinputmodes.js" .modes | safeJS }},
inputPrompt: '{{ .prompt }}',
query: '{{ .query }}',
renderPreset: '{{ default "default" .renderPreset }}'
};
});
</script>

View File

@@ -1,6 +1,6 @@
<script> <script>
window.addEventListener('load', function() { window.addEventListener('load', function() {
window.Bergamot.renderPresets['{{ .name }}'] = window.Bergamot.renderPresets['{{ .name }}'] =
{{ readFile (printf "static/bergamot/rendering/%s" .file) }}; {{ .file }};
}); });
</script> </script>

View File

@@ -15,7 +15,8 @@
<!-- Fonts --> <!-- Fonts -->
{{ if not (.Site.Params.noCss) }} {{ if not (.Site.Params.noCss) }}
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inconsolata:wght@400;700&family=Raleway:wght@400;700&family=Lora&display=block" media="screen"> {{ $fonts := resources.Get "scss/fonts.scss" | css.Sass | resources.Minify }}
<link rel="stylesheet" href="{{ $fonts.Permalink }}" media="screen">
{{ end }} {{ end }}
<!-- External CSS (normalize and KaTeX --> <!-- External CSS (normalize and KaTeX -->
@@ -30,9 +31,9 @@
{{ end -}} {{ end -}}
<!-- In-house CSS --> <!-- In-house CSS -->
{{ $style := resources.Get "scss/style.scss" | resources.ToCSS | resources.Minify }} {{ $style := resources.Get "scss/style.scss" | css.Sass | resources.Minify }}
{{ $sidenotes := resources.Get "scss/sidenotes.scss" | resources.ToCSS | resources.Minify }} {{ $sidenotes := resources.Get "scss/sidenotes.scss" | css.Sass | resources.Minify }}
{{ $code := resources.Get "scss/code.scss" | resources.ToCSS | resources.Minify }} {{ $code := resources.Get "scss/code.scss" | css.Sass | resources.Minify }}
{{ $icon := resources.Get "img/favicon.png" }} {{ $icon := resources.Get "img/favicon.png" }}
<style>.feather { display: inline !important; width: 10px; height: 10px; }</style> <style>.feather { display: inline !important; width: 10px; height: 10px; }</style>
<style>img { max-width: 70%; }</style> <style>img { max-width: 70%; }</style>
@@ -43,6 +44,12 @@
{{ end }} {{ end }}
<link rel="icon" type="image/png" href="{{ $icon.Permalink }}"> <link rel="icon" type="image/png" href="{{ $icon.Permalink }}">
{{ if .Params.custom_js }}
{{ range $customJs := .Params.custom_js }}
<script src="{{ page.Resources.Get $customJs }}"></script>
{{ end }}
{{ end }}
{{ if hugo.IsServer }} {{ if hugo.IsServer }}
<!-- KaTeX auto-rendering for when we don't have a post-processing step. --> <!-- KaTeX auto-rendering for when we don't have a post-processing step. -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.js" integrity="sha384-X/XCfMm41VSsqRNQgDerQczD69XqmjOOOwYQvr/uuC+j4OPoNhVgjdGFwhvN02Ja" crossorigin="anonymous"></script> <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.js" integrity="sha384-X/XCfMm41VSsqRNQgDerQczD69XqmjOOOwYQvr/uuC+j4OPoNhVgjdGFwhvN02Ja" crossorigin="anonymous"></script>
@@ -59,14 +66,27 @@
<script defer src="{{ .Site.Params.bergamotObjectLanguageJsUrl }}"></script> <script defer src="{{ .Site.Params.bergamotObjectLanguageJsUrl }}"></script>
{{ $bergamotHelpers := resources.Get "js/bergamot-helpers.js" | resources.Minify }} {{ $bergamotHelpers := resources.Get "js/bergamot-helpers.js" | resources.Minify }}
<script defer src="{{ $bergamotHelpers.Permalink }}"></script> <script defer src="{{ $bergamotHelpers.Permalink }}"></script>
{{ $bergamotStyle := resources.Get "scss/bergamot.scss" | resources.ToCSS | resources.Minify }} {{ $bergamotStyle := resources.Get "scss/bergamot.scss" | css.Sass | resources.Minify }}
{{ partial "defercss.html" (dict "url" $bergamotStyle.Permalink "extra" "") }} {{ partial "defercss.html" (dict "url" $bergamotStyle.Permalink "extra" "") }}
{{ if .Params.bergamot.render_presets }} {{ if .Params.bergamot.render_presets }}
{{ range $name, $rulefile := .Params.bergamot.render_presets }} {{ range $name, $rulefile := .Params.bergamot.render_presets }}
{{ partial "bergamotrenderpreset.html" (dict "name" $name "file" $rulefile) }} {{ $file := default (resources.Get $rulefile) (page.Resources.Get $rulefile) }}
{{ partial "bergamotrenderpreset.html" (dict "name" $name "file" $file.Content) }}
{{ end }} {{ end }}
{{ else }} {{ else }}
{{ partial "bergamotrenderpreset.html" (dict "name" "default" "file" "minimal.bergamot") }} {{ partial "bergamotrenderpreset.html" (dict "name" "default" "file" (resources.Get "bergamot/rendering/minimal.bergamot").Content) }}
{{ end }}
{{ if .Params.bergamot.presets }}
{{ range $name, $preset := .Params.bergamot.presets }}
{{ $file := default (resources.Get $preset.file) (page.Resources.Get $preset.file) }}
{{ $info := dict "name" $name "prompt" $preset.prompt "query" $preset.query "file" $file.Content "renderPreset" $preset.render_preset "inputModes" $preset.input_modes }}
{{ partial "bergamotpreset.html" $info }}
{{ end }}
{{ end }}
{{ if .Params.bergamot.input_modes }}
{{ range $mode := .Params.bergamot.input_modes }}
{{ partial "bergamotinputmode.html" (dict "name" $mode.name "fn" $mode.fn) }}
{{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}

View File

@@ -1,9 +1,11 @@
{{- $scratch := newScratch -}} {{- $highlightGroupAttrs := (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}}
{{- $scratch.Set "highlightGroupAttrs" (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}}
{{- if (or .firstLine .lastLine) -}} {{- if (or .firstLine .lastLine) -}}
{{- $scratch.Add "highlightGroupAttrs" (printf " data-first-line=\"%v\" data-last-line=\"%v\"" .firstLine .lastLine) -}} {{- $highlightGroupAttrs = add $highlightGroupAttrs (printf " data-first-line=\"%v\" data-last-line=\"%v\"" .firstLine .lastLine) -}}
{{- end -}} {{- end -}}
{{- if eq (lower .language) "agda" -}} {{- if eq (lower .language) "agda" -}}
{{- $scratch.Add "highlightGroupAttrs" " data-agda-block" -}} {{- $highlightGroupAttrs = add $highlightGroupAttrs " data-agda-block" -}}
{{- end -}} {{- end -}}
{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" ($scratch.Get "highlightGroupAttrs")) }} {{- with .offset -}}
{{- $highlightGroupAttrs = add $highlightGroupAttrs (printf " data-source-offset=\"%v\"" .) -}}
{{- end -}}
{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" $highlightGroupAttrs) }}

View File

@@ -14,5 +14,14 @@
{{ partial "seriesstatus.html" .page.Params.status }} {{ partial "seriesstatus.html" .page.Params.status }}
</p> </p>
{{ end }} {{ end }}
<p class="post-preview">{{ .page.Summary }} {{ if .page.Truncated }}...{{ end }}</p> <p class="post-preview">{{ partial "summary" .page }}</p>
{{- if .linkSeries -}}
{{- $term := index (.page.GetTerms "series") 0 -}}
{{- with $term -}}
<div class="series-link">
{{- partial "icon.html" "corner-down-right" -}}
<p>{{- i18n "latestInSeries" }} <a href="{{ $term.Permalink }}">{{ $term.Title }}</a></p>
</div>
{{- end -}}
{{- end }}
</li> </li>

View File

@@ -0,0 +1,5 @@
{{- if .Params.summary -}}
{{ .Params.summary }}
{{- else -}}
{{ .Summary | plainify | truncate 180 }}
{{- end -}}

View File

@@ -0,0 +1,14 @@
{{- $scratch := .scratch -}}
{{- $scratch.Set "pages" slice -}}
{{- $tmpScratch := newScratch -}}
{{- range $post := (where (where site.Pages.ByDate.Reverse "Section" "blog") ".Kind" "!=" "section") -}}
{{- $term := index ($post.GetTerms "series") 0 -}}
{{- if $term -}}
{{- if not ($tmpScratch.Get $term.Permalink) -}}
{{- $tmpScratch.Set $term.Permalink true -}}
{{- $scratch.Add "pages" $post -}}
{{- end -}}
{{- else -}}
{{- $scratch.Add "pages" $post -}}
{{- end -}}
{{- end -}}

View File

@@ -2,7 +2,7 @@
<h2>{{ .Title }} </h2> <h2>{{ .Title }} </h2>
{{ .Content }} {{ .Content }}
{{ $search := resources.Get "scss/search.scss" | resources.ToCSS | resources.Minify }} {{ $search := resources.Get "scss/search.scss" | css.Sass | resources.Minify }}
<link rel="stylesheet" href="{{ $search.Permalink }}" media="screen"> <link rel="stylesheet" href="{{ $search.Permalink }}" media="screen">
<div class="stork-wrapper"> <div class="stork-wrapper">

View File

@@ -7,7 +7,7 @@
<p>{{ partial "seriesstatus.html" .Params.status }}</p> <p>{{ partial "seriesstatus.html" .Params.status }}</p>
<p>{{ i18n "postsFromTo" (dict "from" $startYear "to" $endYear) }}</p> <p>{{ i18n "postsFromTo" (dict "from" $startYear "to" $endYear) }}</p>
</div> </div>
<p>{{ .Summary }}</p> <p>{{ partial "summary" . }}</p>
<ul class="post-list"> <ul class="post-list">
{{ range $pages }} {{ range $pages }}

View File

@@ -0,0 +1,21 @@
<div class="bergamot-exercise">
<details open>
<summary>
<span class="bergamot-exercise-label">
<span class="bergamot-exercise-number"></span>
{{ if or (eq (.Get "label") "") (eq (.Get "label") nil) }}{{ else }}({{ .Get "label" }}){{ end }}:
</span>
</summary>
{{ transform.Markdownify .Inner }}
<div class="bergamot-button-group">
{{ if or (eq (.Get "preset") "") (eq (.Get "preset") nil) }}
{{ else }}
<button class="bergamot-button bergamot-play" onclick='window.Bergamot.runPreset(this.parentElement, "bergamot-widget-container-{{ .Get "id" }}", "{{ .Get "preset" }}")'>{{ partial "icon.html" "play" }}Start Bergamot</button>
<button class="bergamot-button bergamot-close bergamot-hidden" onclick='window.Bergamot.close(this.parentElement, "bergamot-widget-container-{{ .Get "id" }}")'>{{ partial "icon.html" "x" }}Close Bergamot</button>
{{ end }}
</div>
<div id="bergamot-widget-container-{{ .Get "id" }}"></div>
</details>
</div>

View File

@@ -0,0 +1,8 @@
<div id="{{ .Get "id" }}"></div>
<script>
window.addEventListener('load', function() {
window.Bergamot.run(null, '{{ .Get "id" }}',
{{ partial "bergamotparseinputmodes.js" (.Get "modes") | safeJS }},
'{{ .Get "prompt" }}', '{{ .Inner }}', '{{ default "default" (.Get "rendering") }}', '{{ .Get "query" }}');
});
</script>

View File

@@ -1,23 +1,40 @@
{{- $source := (readFile (printf "code/%s" (.Get 1))) -}} {{- $source := (readFile (printf "code/%s" (.Get 1))) -}}
{{- $allLines := split $source "\n" -}} {{- $allLines := split $source "\n" -}}
{{- $scratch := newScratch -}} {{- $scratch := newScratch -}}
{{- $remLines := $allLines -}}
{{- if not (eq (int (.Get 2)) 1) -}} {{- if not (eq (int (.Get 2)) 1) -}}
{{- $scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) -}} {{- $remLines = after (sub (int (.Get 2)) 1) $allLines -}}
{{- else -}}
{{- $scratch.Set "remLines" $allLines -}}
{{- end -}} {{- end -}}
{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) ($scratch.Get "remLines") -}} {{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) $remLines -}}
{{- $opts := "" -}}
{{- if (.Get 4) -}} {{- if (.Get 4) -}}
{{- $scratch.Set "opts" (printf ",%s" (.Get 4)) -}} {{- $opts = printf ",%s" (.Get 4) -}}
{{- else -}}
{{- $scratch.Set "opts" "" -}}
{{- end -}} {{- end -}}
{{- if (.Get 5) -}} {{- if (.Get 5) -}}
{{- $scratch.Set "hidden" (.Get 5) -}} {{- $scratch.Set "hidden" (.Get 5) -}}
{{- end -}} {{- end -}}
{{- $prefixLength := "" -}}
{{- $joinedLines := "" -}}
{{- if or (.Page.Params.left_align_code) (.Get 6) -}}
{{- $prefixLength = -1 -}}
{{- range $line := $lines -}}
{{- $leading := sub (len $line) (len (strings.TrimLeft " " $line)) -}}
{{- if and (ne $line "") (or (eq $prefixLength -1) (le $leading $prefixLength)) -}}
{{- $prefixLength = $leading -}}
{{- end -}}
{{- end -}}
{{- range $line := $lines -}}
{{- $joinedLines = add $joinedLines (substr $line $prefixLength) -}}
{{- $joinedLines = add $joinedLines "\n" -}}
{{- end -}}
{{- else -}}
{{- $joinedLines = delimit $lines "\n" -}}
{{- end -}}
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1) "lines" (slice (.Get 2) (.Get 3))) -}} {{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1) "lines" (slice (.Get 2) (.Get 3))) -}}
{{- partial "linerangestr.html" (dict "scratch" $scratch "from" (.Get 2) "to" (.Get 3)) -}} {{- partial "linerangestr.html" (dict "scratch" $scratch "from" (.Get 2) "to" (.Get 3)) -}}
@@ -29,11 +46,12 @@
"basePath" ($scratch.Get "bestPath") "basePath" ($scratch.Get "bestPath")
"path" (.Get 1) "path" (.Get 1)
"comment" ($scratch.Get "comment") "comment" ($scratch.Get "comment")
"code" (delimit $lines "\n") "code" $joinedLines
"firstLine" (int (.Get 2)) "firstLine" (int (.Get 2))
"lastLine" (int (.Get 3)) "lastLine" (int (.Get 3))
"language" (.Get 0) "language" (.Get 0)
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) ($scratch.Get "opts")) "offset" $prefixLength
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) $opts)
-}} -}}
{{- partial "highlightgroup.html" $groupconfig -}} {{- partial "highlightgroup.html" $groupconfig -}}
{{- with ($scratch.Get "hidden") -}} {{- with ($scratch.Get "hidden") -}}

View File

@@ -0,0 +1,12 @@
{{- $name := .Get 0 -}}
{{- $number := 1 -}}
{{- with .Page.Scratch.Get "internal-ref-counter" -}}
{{- $number = add . 1 }}
{{- end -}}
{{- .Page.Scratch.Set "internal-ref-counter" $number -}}
{{- .Page.Scratch.SetInMap "internal-ref" $name $number -}}
<span class="internal-ref" id="internal-ref-{{ $name }}">
{{ .Inner }}
<span class="internal-ref-counter">{{ $number }}</span></span>
{{- /* chomp whitespace at the end */ -}}

View File

@@ -0,0 +1,7 @@
{{- $name := .Get 0 -}}
{{- $number := index (.Page.Scratch.Get "internal-ref") $name -}}
<a href="#internal-ref-{{ $name }}">
{{ .Inner }}
<span class="internal-ref-counter">{{ $number }}</span></a>
{{- /* chomp whitespace at the end */ -}}

View File

@@ -0,0 +1,3 @@
<div class="side-by-side">
{{ .Inner }}
</div>

View File

@@ -0,0 +1,3 @@
<div class="side-by-side-item" {{ with .Get "weight" }} style="flex-grow: {{ . }};" {{ end }}>
{{ .Inner }}
</div>

View File

@@ -1,3 +0,0 @@
<div style="background-color: tomato; color: white; padding: 10px;">
<em>TODO: </em>{{- .Inner -}}
</div>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.