Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline figure markdown #1236

Merged
merged 40 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a5f43e9
Move figure markup to a macro
tunetheweb Aug 20, 2020
ead1a46
Revert test_status_codes as opened under separate PR
tunetheweb Aug 20, 2020
fc2dadf
Remove unnecessary defaults
tunetheweb Aug 20, 2020
6af3308
Fix typo
tunetheweb Aug 20, 2020
c7e3f29
Fix ebook
tunetheweb Aug 20, 2020
07014e7
Avoid duplication of code
tunetheweb Aug 21, 2020
a53b688
Merge branch 'main' into streamline_figure_markdown
tunetheweb Aug 24, 2020
0e048d4
Merge branch 'main' into streamline_figure_markdown
tunetheweb Aug 25, 2020
d57f926
Review Feedback
tunetheweb Aug 25, 2020
17d4403
Review feedback
tunetheweb Aug 25, 2020
76a4d8b
Fix linting
tunetheweb Aug 25, 2020
9037084
Oh shut up linter!
tunetheweb Aug 25, 2020
95a0af6
Update src/templates/base/2019/base.html
tunetheweb Aug 25, 2020
c80431b
Merge branch 'main' into streamline_figure_markdown
tunetheweb Aug 25, 2020
e1b7e4f
Refactor and fix ebooks
tunetheweb Aug 26, 2020
a8d379c
Increment figure ids
tunetheweb Aug 26, 2020
9c22978
Figure references and figure_lock logic
tunetheweb Aug 27, 2020
bead9c5
Linting errors
tunetheweb Aug 27, 2020
2f20ca1
Revert formating changes
tunetheweb Aug 27, 2020
bcdf0a4
Remove duplicated formatting
tunetheweb Aug 27, 2020
0cbabd6
Merge branch 'main' into streamline_figure_markdown
rviscomi Sep 4, 2020
33e54b5
Remove figref code
tunetheweb Sep 4, 2020
794709f
Add sheets and SQL params (not used currently)
tunetheweb Sep 14, 2020
70c3bbb
Merge branch 'main' into streamline_figure_markdown
tunetheweb Sep 14, 2020
d1cbf1b
Correct typo
tunetheweb Sep 14, 2020
63d5b7c
Merge branch 'main' into streamline_figure_markdown
tunetheweb Sep 16, 2020
5c2b08a
Remove figure_lock
tunetheweb Sep 16, 2020
e2e25cb
Handle links, video and ebook
tunetheweb Sep 17, 2020
0d44c0d
Linting fixes
tunetheweb Sep 17, 2020
5258368
Linting fix
tunetheweb Sep 17, 2020
92e2604
Fix linting
tunetheweb Sep 17, 2020
d4c896f
Linting fixes
tunetheweb Sep 17, 2020
b2f245b
Merge branch 'main' into streamline_figure_markdown
tunetheweb Sep 20, 2020
2a26a8f
Convert 2019 en chapters to new format
tunetheweb Sep 20, 2020
777231e
Migrate Spanish chapters to new format
tunetheweb Sep 20, 2020
2aa07e7
French chapters migration
tunetheweb Sep 20, 2020
5897694
Move Japanese chapters to new format
tunetheweb Sep 21, 2020
2f7be27
Chinese plus cleanup
tunetheweb Sep 21, 2020
e41e936
Clean up
tunetheweb Sep 21, 2020
62d5a82
Remove old figure if logic
tunetheweb Sep 21, 2020
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
528 changes: 289 additions & 239 deletions src/content/en/2019/css.md

Large diffs are not rendered by default.

264 changes: 141 additions & 123 deletions src/content/en/2019/javascript.md

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions src/templates/base/2019/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,41 @@
{% endmacro %}
{% endif %}

{%- macro figure_markup(
tunetheweb marked this conversation as resolved.
Show resolved Hide resolved
id=0,
image="",
caption="",
alt=caption,
description="",
sheets_url="",
width=600,
height=371,
data_width=width,
data_height=height,
big_number="",
really_big_number=""
tunetheweb marked this conversation as resolved.
Show resolved Hide resolved
)
%}
<figure id="fig-{{ id }}">
{%- if image != "" %}
<a href="{{ image }}">
{%- if sheets_url != "" %}
<img src="{{ image }}" alt="{{ caption|striptags }}" aria-labelledby="fig{{ id }}-caption" aria-describedby="fig{{ id }}-description" width="{{ width }}" height="{{ height }}" data-width="{{ data_width }}" data-height="{{ data_height }}" data-seamless="" data-frameborder="0" data-scrolling="no" data-iframe="{{ sheets_url|safe }}" loading="lazy" />
{%- else %}
<img src="{{ image }}" alt="{{ caption|striptags }}" aria-labelledby="fig{{ id }}-caption" aria-describedby="fig{{ id }}-description" width="{{ width }}" height="{{ height }}" loading="lazy" />
{%- endif %}
</a>
<button hidden="" class="fig-description-button" aria-expanded="false" aria-controls="fig{{ id }}-description" data-show-text="{{ show_description(id) }}" data-hide-text="{{ hide_description(id) }}">{{ show_description(id) }}</button>
<div id="fig{{ id }}-description" class="visually-hidden">{{ description|safe }}</div>
{%- elif big_number != "" %}
<div class="big-number">{{ big_number }}</div>
{%- elif really_big_number != "" %}
<div class="really-big-number">{{ really_big_number }}</div>
{%- endif %}
<figcaption id="fig{{ id }}-caption">{{ figure_link( id, caption) }}</figcaption>
</figure>
{%- endmacro %}

{% block index_menu_script %}
<script nonce="{{ csp_nonce() }}">

Expand Down
1 change: 0 additions & 1 deletion src/templates/base/2019/base_chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
</a>
{% endmacro %}


{% macro render_byline() %}
<div class="byline">{{ self.written_by_before() }}
{% for author in metadata.get('authors') %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/base/2019/base_ebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -502,4 +502,4 @@ <h2 class="title">{{ self.intro_title() }}</h2>

</div>
{% endif %}
{% endblock %}
{% endblock %}
6 changes: 4 additions & 2 deletions src/templates/en/2019/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
{% block open %}Open{% endblock %}
{% block close %}Close{% endblock %}

{% macro show_description(id) %}Show description of Figure {{ id }}{% endmacro %}
{% macro hide_description(id) %}Hide description of Figure {{ id }}{% endmacro %}
{% macro figure(id, caption) %}Figure {{ metadata.chapter_number }}.{{ id }}. {{ caption|safe }}{% endmacro %}
{% macro figure_link(id, caption) %}<a href="#fig-{{ id }}" class="anchor-link">Figure {{ metadata.chapter_number }}.{{ id }}.</a> {{ caption|safe }}{% endmacro %}
{% macro show_description(id) %}Show description of Figure {{ metadata.chapter_number }}.{{ id }}{% endmacro %}
{% macro hide_description(id) %}Hide description of Figure {{ metadata.chapter_number }}.{{ id }}{% endmacro %}

{% block written_by_before %}Written by{% endblock %}
{% block reviewed_by_before %}Reviewed by{% endblock %}
Expand Down
6 changes: 4 additions & 2 deletions src/templates/es/2019/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
{% block open %}Abre{% endblock %}
{% block close %}Cierra{% endblock %}

{% macro show_description(id) %}Mostrar descripción de la Figura {{ id }}{% endmacro %}
{% macro hide_description(id) %}Ocultar descripción de la Figura {{ id }}{% endmacro %}
{% macro figure(id, caption) %}Figura {{ metadata.chapter_number }}.{{ id }}. {{ caption|safe }}{% endmacro %}
{% macro figure_link(id,caption) %}<a href="#fig-{{ id }}" class="anchor-link">Figura {{ metadata.chapter_number }}.{{ id }}.</a> {{ caption|safe }}{% endmacro %}
{% macro show_description(id) %}Mostrar descripción de la Figura {{ metadata.chapter_number }}.{{ id }}{% endmacro %}
{% macro hide_description(id) %}Ocultar descripción de la Figura {{ metadata.chapter_number }}.{{ id }}{% endmacro %}

{% block written_by_before %}Escrito por{% endblock %}
{% block reviewed_by_before %}Revisado por{% endblock %}
Expand Down
6 changes: 4 additions & 2 deletions src/templates/fr/2019/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
{% block open %}Ouvrez{% endblock %}
{% block close %}Fermez{% endblock %}

{% macro show_description(id) %}Afficher la description de la figure {{ id }}{% endmacro %}
{% macro hide_description(id) %}Masquer la description de la figure {{ id }}{% endmacro %}
{% macro figure(id, caption) %}Figure {{ metadata.chapter_number }}.{{ id }}. {{ caption|safe }}{% endmacro %}
{% macro figure_link(id,caption) %}<a href="#fig-{{ id }}" class="anchor-link">Figure {{ metadata.chapter_number }}.{{ id }}.</a> {{ caption|safe }}{% endmacro %}
{% macro show_description(id) %}Afficher la description de la figure {{ metadata.chapter_number }}.{{ id }}{% endmacro %}
{% macro hide_description(id) %}Masquer la description de la figure {{ metadata.chapter_number }}.{{ id }}{% endmacro %}

{% block written_by_before %}Écrit par{% endblock %}
{% block reviewed_by_before %}Relu par{% endblock %}
Expand Down
6 changes: 4 additions & 2 deletions src/templates/ja/2019/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@
{% block author %}著者{% endblock %}
{% block authors %}著者{% endblock %}

{% macro show_description(id) %}図{{ id }}の説明を表示{% endmacro %}
{% macro hide_description(id) %}図{{ id }}の説明を非表示{% endmacro %}
{% macro figure(id, caption) %}図{{ metadata.chapter_number }}.{{ id }}{{ caption|safe }}{% endmacro %}
{% macro figure_link(id,caption) %}<a href="#fig-{{ id }}" class="anchor-link">図{{ metadata.chapter_number }}.{{ id }}.</a>{{ caption|safe }}{% endmacro %}
{% macro show_description(id) %}図{{ metadata.chapter_number }}.{{ id }}の説明を表示{% endmacro %}
{% macro hide_description(id) %}図{{ metadata.chapter_number }}.{{ id }}の説明を非表示{% endmacro %}

{% macro onTwitter(twitterHandle) %}Twitterの@{{twitterHandle}}{% endmacro %}
{% macro onGitHub(gitHubHandle) %}GitHubの{{gitHubHandle}}{% endmacro %}
Expand Down
6 changes: 4 additions & 2 deletions src/templates/pt/2019/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
{% block open %}Abrir{% endblock %}
{% block close %}Fechar{% endblock %}

{% macro show_description(id) %}Mostrar descrição da figura {{ id }}{% endmacro %}
{% macro hide_description(id) %}Ocultar descrição da figura {{ id }}{% endmacro %}
{% macro figure(id, caption) %}Figura {{ metadata.chapter_number }}.{{ id }}. {{ caption|safe }}{% endmacro %}
{% macro figure_link(id,caption) %}<a href="#fig-{{ id }}" class="anchor-link">Figura {{ metadata.chapter_number }}.{{ id }}.</a> {{ caption|safe }}{% endmacro %}
{% macro show_description(id) %}Mostrar descrição da figura {{ metadata.chapter_number }}.{{ id }}{% endmacro %}
{% macro hide_description(id) %}Ocultar descrição da figura {{ metadata.chapter_number }}.{{ id }}{% endmacro %}

{% block written_by_before %}Escrito por{% endblock %}
{% block reviewed_by_before %}Revisado por{% endblock %}
Expand Down
6 changes: 4 additions & 2 deletions src/templates/zh-CN/2019/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
{% block open %}打开{% endblock %}
{% block close %}关闭{% endblock %}

{% macro show_description(id) %}显示图像描述 {{ id }}{% endmacro %}
{% macro hide_description(id) %}隐藏图像描述 {{ id }}{% endmacro %}
{% macro figure(id, caption) %}图 {{ metadata.chapter_number }}.{{ id }}. {{ caption|safe }}{% endmacro %}
{% macro figure_link(id,caption) %}<a href="#fig-{{ id }}" class="anchor-link">图 {{ metadata.chapter_number }}.{{ id }}.</a> {{ caption|safe }}{% endmacro %}
{% macro show_description(id) %}显示图像描述 {{ metadata.chapter_number }}.{{ id }}{% endmacro %}
{% macro hide_description(id) %}隐藏图像描述 {{ metadata.chapter_number }}.{{ id }}{% endmacro %}

{% block written_by_before %}作者: {% endblock %}
{% block reviewed_by_before %}审稿者: {% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/tools/generate/remove_unnecessary_markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
const remove_unnecessary_markup = (html) => {
// Remove pointless paragraph tags added by JSON in wrap_tables
html = html.replace(/<p><\/p>/g, '');
// Remove pointless paragraph tags added around Jinja figure calls
html = html.replace(/\n*<p>({{ figure_markup.*?)<\/p>\n*/gis, '$1');
return html
}

Expand Down