diff --git a/_includes/ingredients.html b/_includes/ingredients.html
index 16c3287..265a4ab 100644
--- a/_includes/ingredients.html
+++ b/_includes/ingredients.html
@@ -12,13 +12,13 @@
{%- assign end = "" -%}
{%- if item[0][0] -%}
- {%- assign to = item[0][1] | fractionalise -%}
- {%- assign amount = item[0][0] | fractionalise | append: " to " | append: to | append: " " -%}
+ {%- assign to = item[0][1] | fractionalise: 10 -%}
+ {%- assign amount = item[0][0] | fractionalise: 10 | append: " to " | append: to | append: " " -%}
{%- elsif item[0] == 0 -%}
{%- assign amount = "" -%}
{%- assign end = " to taste" -%}
{%- else -%}
- {%- assign amount = item[0] | fractionalise | append: " " -%}
+ {%- assign amount = item[0] | fractionalise: 10 | append: " " -%}
{%- endif -%}
<{{ tag }}>{{ amount }} {%- if item[2] %}{{ item[2] }} of {% endif -%} {{ item[1] }}{{ end }}
diff --git a/_plugins/custom_stuff.rb b/_plugins/custom_stuff.rb
index f9e026c..a5f932b 100644
--- a/_plugins/custom_stuff.rb
+++ b/_plugins/custom_stuff.rb
@@ -3,7 +3,7 @@ require "jekyll"
module Jekyll
module FractionaliseFilter
- def fractionalise(input)
+ def fractionalise(input, limit = 0)
input = input.to_s
if not input.include? "."
@@ -29,6 +29,11 @@ module Jekyll
decimal.to_r
end
+ if limit != 0 and rational.denominator > limit
+ # apply a maximum size for the denominator to avoid the (imo) much more readable "0.41" becoming "41/100" unless wanted
+ return input
+ end
+
"#{leading_integer != "0" ? "#{leading_integer} " : ""}#{rational.numerator}#{rational.denominator}"
end
diff --git a/assets/style.css b/assets/style.css
index 8298174..a5ae6bc 100644
--- a/assets/style.css
+++ b/assets/style.css
@@ -160,6 +160,9 @@ a.recipe-listing {
width: min-content;
vertical-align: top;
}
+.fraction .numerator {
+ text-align: center;
+}
.fraction .denominator {
border-top: thin black solid;
}