Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ _site
.claude/
.idea/
.run/
_posts_bak/

# Editor and toolchain leftovers
node_modules/
Expand Down
10 changes: 3 additions & 7 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,7 @@ social:


protocols:
# Default social card image, used only when a page sets no `cover`. The old
# value was my_logo.png declared as 612x605 — the file is actually 192x192,
# below the 200x200 floor Facebook/LinkedIn need to render a card at all.
# my_header_image.jpg is the site cover and its declared size is real.
# Default social card image, used only when a page sets no `cover` (the site
# cover; at least 200x200, or Facebook/LinkedIn render no card). head.html
# reads its size from the file.
fb_image: /assets/my_header_image.jpg
fb_image_width: 1920
fb_image_height: 600
fb_image_type: image/jpeg
44 changes: 24 additions & 20 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
{%- assign page_description = page.description | default: site.description | shorten_meta -%}

{%- comment -%}
A page `cover` is a wide banner of unknown size, so its dimensions are not
declared — crawlers measure it themselves. Only the configured default image
ships width/height, because those values are verified against the file.
The page's cover, else the site's default image. Its size is read from the
file (image_size, _plugins/image_dimensions.rb), so a link preview can lay
out before the image arrives.
{%- endcomment -%}
{%- if page.cover -%}
{%- assign social_image = page.cover | prepend: site.baseurl | prepend: site.url -%}
{%- else -%}
{%- assign social_image = site.protocols.fb_image | prepend: site.baseurl | prepend: site.url -%}
{%- endif -%}
{%- assign social_src = page.cover | default: site.protocols.fb_image -%}
{%- assign social_image = social_src | prepend: site.baseurl | prepend: site.url -%}
{%- assign social_size = social_src | image_size -%}

{%- assign page_lang = page.lang | default: site.lang -%}
{%- if page_lang == 'en' -%}
Expand Down Expand Up @@ -122,10 +120,10 @@
<meta property="og:locale" content="{{ og_locale }}" />
<meta property="og:image" content="{{ social_image }}" />
<meta property="og:image:alt" content="{{ page_title | escape }}" />
{% unless page.cover %}<meta property="og:image:type" content="{{ site.protocols.fb_image_type }}" />
<meta property="og:image:width" content="{{ site.protocols.fb_image_width }}" />
<meta property="og:image:height" content="{{ site.protocols.fb_image_height }}" />
{% endunless %}
<meta property="og:image:type" content="image/{% if social_src contains '.png' %}png{% else %}jpeg{% endif %}" />
{% if social_size %}<meta property="og:image:width" content="{{ social_size[0] }}" />
<meta property="og:image:height" content="{{ social_size[1] }}" />
{% endif %}
{% if page.layout == 'post' %}
<meta property="article:published_time" content="{{ page.posted_at | date_to_xmlschema }}" />
{% if page.last_modified_at %}<meta property="article:modified_time" content="{{ page.last_modified_at | date_to_xmlschema }}" />
Expand Down Expand Up @@ -185,6 +183,10 @@
"image": "{{ social_image }}",
"author": { "@type": "Person", "name": {{ site.author | jsonify }}, "url": "{{ '/about/' | prepend: site.baseurl | prepend: site.url }}" },
"publisher": { "@type": "Person", "name": {{ site.author | jsonify }} },
{%- comment -%} The paper a paper post is about, by its DOI. {%- endcomment -%}
{%- if page.paper_doi %}
"about": { "@type": "ScholarlyArticle", "name": {{ page.title | jsonify | replace: '<', '\u003c' }}, "identifier": {{ page.paper_doi | jsonify }}, "sameAs": {{ page.paper_doi | prepend: 'https://doi.org/' | jsonify }} },
{%- endif %}
"keywords": {{ page.tags | join: ', ' | replace: '-', ' ' | jsonify | replace: '<', '\u003c' }}
}
</script>
Expand Down Expand Up @@ -219,12 +221,12 @@
<script>
MathJax = {
tex: {
// NOTE: single '$' is intentionally NOT an inline delimiter. kramdown emits
// all math as \(...\) / \[...\], so '$' is unneeded here — and enabling it
// makes MathJax mis-render prose currency on a line (e.g. "$1.2B ... $29B")
// as a formula. processEscapes lets a literal "\$" render as a dollar sign.
// kramdown emits all math as \(...\) / \[...\], so no '$' delimiter is
// needed: '$' would mis-render prose currency on a line ("$1.2B ... $29B"),
// and '$$' would turn one in a title or a related-post link into math.
// processEscapes lets a literal "\$" render as a dollar sign.
inlineMath: [['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\\[', '\\]']],
displayMath: [['\\[', '\\]']],
processEscapes: true,
macros: {
llbracket: '[\\![',
Expand Down Expand Up @@ -268,11 +270,13 @@
el.scrollWidth > el.clientWidth;
if (scrolls && el.getAttribute('tabindex') !== '0') {
el.setAttribute('tabindex', '0');
el.setAttribute('role', 'region');
// A group, not a region: a long post has dozens of these, and as
// landmarks they drowned the page's real ones (tables stay regions).
el.setAttribute('role', 'group');
el.setAttribute('aria-label', display
? (english ? 'Equation ' + n + ', scrollable' : '수식 ' + n + ', 가로 스크롤')
: (english ? 'Inline equation ' + n + ', scrollable' : '인라인 수식 ' + n + ', 가로 스크롤'));
} else if (!scrolls && el.getAttribute('role') === 'region') {
} else if (!scrolls && el.getAttribute('role') === 'group') {
el.removeAttribute('tabindex');
el.removeAttribute('role');
el.removeAttribute('aria-label');
Expand All @@ -292,7 +296,7 @@
};
</script>
<!-- Pinned to an exact version with an integrity hash, like the other
versioned CDN files (GLightbox, simple-jekyll-search). A floating alias
versioned CDN file (GLightbox). A floating alias
such as `mathjax@3` cannot carry an SRI hash, so the bytes it serves could
change without a commit. The fonts MathJax fetches later are not covered. -->
<script id="MathJax-script" async
Expand Down
21 changes: 17 additions & 4 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,30 @@ <h1 class="title">{{ page.title | escape }}</h1>

{%- comment -%} From the post's h2s (_plugins/post_toc.rb), when there are 3 or more. {%- endcomment -%}
{%- assign toc = content | post_toc -%}
{% if toc.size >= 3 %}
{% if toc.size >= 3 %}{%- comment -%} PostTocFilter::MIN {%- endcomment -%}
<details id="post-toc" class="post-toc" open>
<summary lang="{{ site.ui_lang }}">
<span class="post-toc-title">Contents</span>
<span class="post-toc-count">{{ toc.size }}</span>
<span class="post-toc-chevron" aria-hidden="true"></span>
</summary>
{%- comment -%}
h3s (level 3, _plugins/post_toc.rb) nest under the h2 before them, so
a screen reader hears the sections and their parts.
{%- endcomment %}
<ul>
{%- for entry in toc %}
<li><a href="#{{ entry.id }}">{% if entry.num %}<span class="toc-num">{{ entry.num }}</span>{% endif %}{{ entry.text }}</a></li>
{%- endfor %}
{%- assign sub_open = false -%}
{%- for entry in toc -%}
{%- if entry.level == 3 -%}
{%- unless sub_open %}<ul>{% assign sub_open = true %}{% endunless %}
<li><a href="#{{ entry.id }}">{{ entry.text }}</a></li>
{%- else -%}
{%- if sub_open %}</ul>{% assign sub_open = false %}{% endif -%}
{%- unless forloop.first %}</li>{% endunless %}
<li><a href="#{{ entry.id }}">{% if entry.num %}<span class="toc-num">{{ entry.num }}</span>{% endif %}{{ entry.text }}</a>
{%- endif -%}
{%- endfor -%}
{%- if sub_open %}</ul>{% endif %}</li>
</ul>
</details>
{% endif %}
Expand Down
13 changes: 13 additions & 0 deletions _plugins/image_dimensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ def self.svg(root)
private_class_method :jpeg, :svg
end

# Liquid filter: {{ "/assets/images/x.jpg" | image_size }} → [width, height]
# of that repo file, or nil. _includes/head.html declares the social image's
# size with it, so a link preview can lay out before the image arrives.
module ImageSizeFilter
def image_size(src)
site = @context.registers[:site]
path = ImageDimensions.source_file(src.to_s, site.source, "")
File.file?(path) ? ImageDimensions.read(File.binread(path)) : nil
end
end

Liquid::Template.register_filter(ImageSizeFilter) if defined?(Liquid::Template)

# Guarded so test/ can require this file without Jekyll loaded.
if defined?(Jekyll::Hooks)
Jekyll::Hooks.register [:posts, :pages], :post_render do |doc|
Expand Down
3 changes: 0 additions & 3 deletions _plugins/lazy_images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
# Runs as a post-render hook (after kramdown produces HTML), so it covers both
# Markdown ![](...) images and hand-written <img> tags. Tags that already set a
# loading attribute are left untouched.
#
# This repo builds via GitHub Actions (not the github-pages gem sandbox), so
# custom _plugins are allowed.
module LazyImages
# Negative lookahead on `loading=` so an explicit loading="eager" (used for an
# above-the-fold image) survives.
Expand Down
24 changes: 18 additions & 6 deletions _plugins/post_toc.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# frozen_string_literal: true
#
# Liquid filter: {{ content | post_toc }} → the post's table of contents, one
# { "id", "text", "num" } per <h2 id> in the rendered body.
# { "id", "text", "num", "level" } per <h2 id> in the rendered body. A post
# with fewer than MIN h2s but sections inside them gets its h3s too, in order
# (level 3), so a long post split into two parts still has a contents list.
# _layouts/post.html shows the list when it has MIN entries.
#
# Built at build time, so the list is in the first paint (filled by a script it
# would push the article down) and there without JavaScript.
Expand All @@ -11,14 +14,23 @@
# nil when most headings number themselves ("1. 배경"), which would otherwise
# read "2 1. 배경". A lone "1. …" among plain headings keeps the numbers.
module PostTocFilter
H2 = %r{<h2\b[^>]*\sid="([^"]+)"[^>]*>(.*?)</h2>}m.freeze
HEADING = %r{<h([23])\b[^>]*\sid="([^"]+)"[^>]*>(.*?)</h\1>}m.freeze
SELF_NUMBERED = /\A\s*\d+[.)]\s/.freeze
MIN = 3

def post_toc(html)
heads = html.to_s.scan(H2).map { |id, inner| [id, inner.gsub(/<[^>]+>/, "").strip] }
numbered = heads.count { |_, text| text.match?(SELF_NUMBERED) } > heads.size / 2.0
heads.each_with_index.map do |(id, text), i|
{ "id" => id, "text" => text, "num" => (numbered ? nil : i + 1) }
heads = html.to_s.scan(HEADING).map { |level, id, inner| [level.to_i, id, inner.gsub(/<[^>]+>/, "").strip] }
top = heads.select { |level, _, _| level == 2 }
heads = top if top.size >= MIN
# An h3 before the first h2 has no section to sit under: list it as one.
first_h2 = heads.index { |level, _, _| level == 2 } || heads.size
heads = heads.each_with_index.map { |(level, id, text), i| [i < first_h2 ? 2 : level, id, text] }
# Numbers count h2s only: with h3s among them, "1 … 14" would number sections
# and their parts alike, so the list goes unnumbered and the h3s indented.
unnumbered = heads.count { |_, _, text| text.match?(SELF_NUMBERED) } > heads.size / 2.0 ||
heads.any? { |level, _, _| level == 3 }
heads.each_with_index.map do |(level, id, text), i|
{ "id" => id, "text" => text, "num" => (unnumbered ? nil : i + 1), "level" => level }
end
end
end
Expand Down
1 change: 1 addition & 0 deletions _sass/_dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible { outline-color: $link; }

// $medium-gray (#767676) is 4.17:1 here and 3.81:1 on $surface. The dark rules
Expand Down
11 changes: 10 additions & 1 deletion _sass/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,18 @@ blockquote {
.theme-toggle {
margin: 0;
padding: 0;
// The icon alone is 15x20px; this is the 24px minimum target size.
// The icon alone is 15x20px; this is the 24px minimum target size, and a
// 44px touch target in the phone menu, beside items of about that height.
min-width: 24px;
min-height: 24px;
@media (max-width: $tablet - 1px) {
// The menu's items are right-aligned: the icon keeps that edge.
display: inline-flex;
align-items: center;
justify-content: flex-end;
min-width: 44px;
min-height: 44px;
}
font-size: 1.15em;
line-height: 1;
color: $medium-gray;
Expand Down
22 changes: 21 additions & 1 deletion _sass/_post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@
font-size: 0.92em;
}

// h3s, listed under their h2 when the post has too few h2s
// (_plugins/post_toc.rb).
ul ul {
padding: 0 0 0 1.2em;
li { font-size: inherit; } // not 0.92em of 0.92em
a { font-weight: 400; }
}

a {
display: inline-flex;
align-items: center;
Expand Down Expand Up @@ -274,8 +282,14 @@
}
}

// A 44px touch target around the 20px icon.
.social-link {
margin: 0 0.5em;
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 44px;
min-height: 44px;
margin: 0;
color: $medium-gray;
transition: $transition-color;

Expand Down Expand Up @@ -416,6 +430,12 @@
background-color: #fff;
}

// Above a phone the controls sit in the corners; a figure the full height of
// the window ran under the close button.
body:not(.glightbox-mobile) .glightbox-container .gslide-image img {
max-height: calc(100vh - 6rem);
}

// On a black band, so the ring holds 3:1 over a white figure too.
.glightbox-container .gbtn.focused,
.glightbox-container .gbtn:focus-visible {
Expand Down
3 changes: 3 additions & 0 deletions _sass/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

.result-snippet { line-height: 1.6; }

// The site's button (base/_buttons.scss).
.search-more { margin-top: 0.5em; }

.result-tags {
margin: 0.4em 0 0;
color: $medium-gray;
Expand Down
Loading
Loading