Jekyll on github pages displays division result as fraction

I am creating a blog powered by jekyll and github pages. I am trying to display the read time of each message this way: (assuming the average reading speed is 180 wpm)

{% for post in paginator.posts %}
    {% capture readtime %}{{ post.content | number_of_words | plus:91 | divided_by:180 }}{% endcapture %}
    ...
    {{ readtime }} min. read
{% endfor %}

      

When I check this code locally everything is fine. For a message with 200 words: 291/180 = 1.61 (6) The result of jekyll is:

1 min. read

      

But when I push this code to github pages something strange happens. As a result of the division, I see some fraction that will give me the same result. So jekyll on github generates the result:

97/60 min. read

      

In fact: 97/60 = 1.61 (6)

What should I do to have the same output on github as locally?

+3


source to share


1 answer


This seems to be a bug.

It works

{% assign number = 200 %}
{{ number | divided_by: 10 }}

      

outputs: 20

This does not work

{% assign text = "a text with words" %}
{% assign division = text | number_of_words | divided_by: 3 %}
{{ division }}

      



outputs: 4/3

I have filled in bugs in Jekyll and Liquid and I will post here as soon as I have information about this resolution.

Considering this bug is reproduced on the github page and knowing how serious the github community is, I'm sure we'll be fixing this bug soon.

Edit:

This is a Jekyll bug and has now been fixed in master. Now we need to wait for this commit to be implemented in the next version of Jekyll, v2.1 I assume, and then bubble to the Github pages.

Stay with us.

+2


source







All Articles