Discourse Units - Convert durations, lengths and masses

Discourse Units

discourse-units is a theme component that automatically detects and converts durations, lengths and masses between various scales to make them easier to comprehend.

Example:

The theme component can be found on GitHub:

https://github.com/udan11/discourse-units

How to install it?

The repository link is:

https://github.com/udan11/discourse-units.git
37개의 좋아요

I think the words recognized as units can be done better. Here is an example where the word, “invites” is being catched as “inches”.

image

4개의 좋아요

I remember this being a bit tricky. I did not check for the “unit” to be a whole word because I wanted to avoid defining all forms (singular and plural) of measurement units (min, minute, mins, minutes). I will have to do it.

2개의 좋아요

Hi @dan

Might be a good idea (1) not to convert or display your conversion for any number which does not have units behind it; and (2) to have a white list of acceptable units and only convert those; to save you from having an intractable problem.

HTH

1개의 좋아요

One plan of attack would be to have a few “acceptable full forms” and only accept truncations of those - so mins, minutes and ins, inchesin yes, inside no (there are extra letters on the end).

2개의 좋아요

Would be useful if you can limit the type of units you would like to convert, for instance to just limit to convert weight measurements, and if possible be more specific and limit to specifics units like just pounds to kilos and kilos to pounds.

2개의 좋아요