Skip to content

Commit

Permalink
Merge pull request #767 from carpentries/frog-links-1
Browse files Browse the repository at this point in the history
Fix cross-refs and language links
  • Loading branch information
froggleston authored Jan 23, 2025
2 parents dbe65be + f065da4 commit ccec578
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Build and Deploy Glossary Website

jobs:
build-and-deploy:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04 # pyicu build fails on python 3.12
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
5 changes: 3 additions & 2 deletions _includes/glossary.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% assign language = page.permalink | replace: '/', '' %}

{% assign all_gloss = site.data.glossary %}
{% assign gloss = site.data.[language].glossary %}

{% assign direction = 'ltr' %}
Expand Down Expand Up @@ -48,7 +49,7 @@ <h4 id="{{item.slug}}">{{item[language].term}}{% if item[language].acronym %} ({
&larr;
{% endif %}
{% for other_key in item.ref -%}
{%- assign other = gloss | where: "slug", other_key | first -%}
{%- assign other = all_gloss | where: "slug", other_key | first -%}
<a href="#{{other_key}}">
{%- if other[language] -%}
{{other[language].term}}
Expand All @@ -62,7 +63,7 @@ <h4 id="{{item.slug}}">{{item[language].term}}{% if item[language].acronym %} ({
{%- comment -%} Translations {%- endcomment -%}
{% assign others = '' | split: ',' %}
{% for lang in site.languages %}
{% if lang.key != language and item[lang.key] %}
{% if lang.key != language and other[lang.key] %}
{% assign others = others | push: lang %}
{% endif %}
{% endfor %}
Expand Down
23 changes: 16 additions & 7 deletions utils/sort-glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ def _setup_dict(glossary, data_path):
}
)

if "ref" in slug:
count_dict[lang]["term_entry_map"][slug[lang]["term"]]["ref"] = slug["ref"]

# return the data structure including sorted terms
return _sort_terms(count_dict, data_path)

Expand All @@ -264,14 +267,20 @@ def _build_lang_glossary(count_dict):
slug = term_map["slug"]
_def = term_map["def"]

od = OrderedDict({
"slug": slug,
lang: {
"term": sorted_term,
"def": _def
}
})

if "ref" in term_map:
_ref = term_map["ref"]
od["ref"] = _ref

# use an OrderedDict to retain insertion order
sorted_glossary.append(OrderedDict({
"slug": slug,
lang: {
"term": sorted_term,
"def": _def
}
}))
sorted_glossary.append(od)

# only include languages with terms
if sorted_glossary:
Expand Down

0 comments on commit ccec578

Please sign in to comment.