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

Streamline figure markdown #1236

merged 40 commits into from
Sep 21, 2020

Conversation

tunetheweb
Copy link
Member

@tunetheweb tunetheweb commented Aug 20, 2020

Makes progress on #1138

At present this does not:

  • change the anchor links as the ids (will need to think how we handle 2019 links if we do change these and update all the 2019 chapters to the new format - which I'd like to do for consistency).
  • do much for the tables (though ids are automated and fig-caption is automated a little).
  • add the menu or query links suggested in Streamline figures in markdown #1138

It definitely does clear up a lot of the repetition and makes it a lot easier to add figures and have consistency in the mark up used for figures.

At the moment I've only moved two of the 2019 chapters to show how they work. Can add the other chapters to this PR once it's been reviewed, or open a new PR for them.

@tunetheweb tunetheweb added the development Building the Almanac tech stack label Aug 20, 2020
@tunetheweb tunetheweb added this to the 2020 Platform Development milestone Aug 20, 2020
@tunetheweb tunetheweb requested review from rviscomi and a team August 20, 2020 23:25
@tunetheweb tunetheweb added this to TODO in 2020 via automation Aug 20, 2020
src/templates/base/2019/base.html Show resolved Hide resolved
src/templates/base/2019/base.html Outdated Show resolved Hide resolved
src/content/en/2019/css.md Outdated Show resolved Hide resolved
<div id="fig1-description" class="visually-hidden">Bar chart showing the adoption of HSL, HSLA, RGB, RGBA, and hex color formats. Hex is used on 93% of desktop pages, RGBA on 83%, RGB on 22%, HSLA 19%, and HSL 1%. Desktop and mobile adoption is similar for all color formats except HSL, for which mobile adoption is 9% (9 times higher).</div>
<figcaption id="fig1-caption">Figure 1. Popularity of color formats.</figcaption>
</figure>
{{ figure_markup(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about leaving all of the 2019 contents as-is and only using these function for 2020? Not sure if it's worth the maintenance cost to edit everything.

Copy link
Member Author

@tunetheweb tunetheweb Aug 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like having the consistency. I have some regexs worked out to make this relatively easy. Also have a feeling we may forget how this works, or may stop testing it between now and 2020 figures being ready. Having old chapters as examples would be good.

Also makes translations easier as there is a lot of duplication and confusing syntax.

Also means any new features we add (like your menu) are automatically backported. Though I do agree that adding extra meta-data (e.g. links to SQL or specific sheets) isn't worth the effort to add to the old years so may not benefit that much from it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this create a discrepancy in figure numbering between CSS/JS and the rest of the 2019 chapters? The former will use the new chapter number prefixes (eg "Figure 1.1").

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just committed the other chapters there - for English anyway (will do the other languages now). Have some regexes that makes this easy and even spotted a few longstanding typos as part of that when the regexes didn't work!

The only question is that two of our chapters (Markdown and Performance) had different figure anchors (#fig1 instead of #fig-1 like the other 18 chapters use). Previously, when we automated this a little, we catered for this:

//Some of our 2019 chapters (markdown and performance) had different fig ids
const figcaption_regex = /<figcaption(.*?)>(.*?)([0-9]+)\./gi;
if (html.includes('<figure id="fig1"')) {
return html.replace(figcaption_regex, '<figcaption$1><a href="#fig$3" class="anchor-link">$2 $3.</a>');
} else {
return html.replace(figcaption_regex, '<figcaption$1><a href="#fig-$3" class="anchor-link">$2 $3.</a>');
}

I think we shouldn't complicate the logic by catering for it this time by adding "if 2019 and (markdown or performance)" and should just be consistent across the chapters despite the fact that this might be that anchor links for these chapters will change. You OK with that? And don't let the fact you authored one of these chapters sway you too much 😉

src/content/en/2019/css.md Outdated Show resolved Hide resolved
Copy link
Member

@rviscomi rviscomi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, sorry for the delay.

Just one comment about figure numbering consistency for 2019.

<div id="fig1-description" class="visually-hidden">Bar chart showing the adoption of HSL, HSLA, RGB, RGBA, and hex color formats. Hex is used on 93% of desktop pages, RGBA on 83%, RGB on 22%, HSLA 19%, and HSL 1%. Desktop and mobile adoption is similar for all color formats except HSL, for which mobile adoption is 9% (9 times higher).</div>
<figcaption id="fig1-caption">Figure 1. Popularity of color formats.</figcaption>
</figure>
{{ figure_markup(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this create a discrepancy in figure numbering between CSS/JS and the rest of the 2019 chapters? The former will use the new chapter number prefixes (eg "Figure 1.1").

2020 automation moved this from TODO to In progress Sep 20, 2020
Copy link
Member

@rviscomi rviscomi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you also be up for documenting the figure_markup interface for authors, either in the wiki or a README?

@tunetheweb
Copy link
Member Author

All chapters updated. Merging and yes I'll document in the wiki. Who owns this? Analysts? Authors? Editors?

@tunetheweb tunetheweb merged commit 440a69b into main Sep 21, 2020
2020 automation moved this from In progress to Done Sep 21, 2020
@tunetheweb tunetheweb deleted the streamline_figure_markdown branch September 21, 2020 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Building the Almanac tech stack
Projects
No open projects
2020
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants