@@ -78,6 +78,7 @@ const metricDistanceUnits = [/km/, /light-?years?/,
78
78
const metricWeightUnits = [ / k g s ? / , / g r a m s ? / , / k i l o g r a m s ? / ] ;
79
79
const metricVolumeUnits = [ / (?: m i l l i | c e n t i | d e c a | k i l o ) ? l i t (?: e r | r e ) s ? / , / (?: d e c a | k i l o ) ? m (?: e t e r s ? ) ? (?: \^ 3 | c u b e d ? ) / ] ;
80
80
const metricForceUnits = [ / n e w t o n s ? / , / d y n e s ? / ] ;
81
+ const liquidKeywords = [ 'liquid' , 'water' , 'tea' , 'beer' , 'soda' , 'cider' , 'juice' , 'coffee' , 'liquor' , 'milk' , 'bottle' , 'spirits' , 'rum' , 'vodka' , 'tequila' , 'wine' , 'oil' ] ;
81
82
82
83
const ukSubreddits = [ "britain" , "british" , "england" , "english" , "scotland" , "scottish" , "wales" , "welsh" , "ireland" , "irish" , "london" , "uk" ] ;
83
84
@@ -322,7 +323,27 @@ const unitLookupList = [
322
323
"isWeaklyInvalidInput" : isHyperbole ,
323
324
"conversionFunction" : ( i ) => volumeMap ( i * 0.0295735295625 ) ,
324
325
"ignoredUnits" : metricVolumeUnits ,
325
- "ignoredKeywords" : ukSubreddits
326
+ "ignoredKeywords" : ukSubreddits ,
327
+ "preprocess" : ( comment ) => {
328
+ const input = comment [ 'body' ] ;
329
+ const ozRegex = new RegExp ( ( rh . startRegex
330
+ + rh . numberRegex
331
+ + "[- ]?"
332
+ + rh . regexJoinToString ( [ / o z / , / o u n c e s ? / ] )
333
+ ) , 'gi' ) ;
334
+ const ozAndLiquidRegex = new RegExp ( ( ozRegex . source
335
+ + ".+?\\b"
336
+ + rh . regexJoinToString ( liquidKeywords )
337
+ ) , 'i' ) ;
338
+
339
+ if ( ! ozAndLiquidRegex . test ( input ) ) {
340
+ return input ;
341
+ }
342
+
343
+ return input . replace ( ozRegex , ( oz , offset , string ) => {
344
+ return " " + oz + " fl. oz" ;
345
+ } ) ;
346
+ }
326
347
} ,
327
348
{
328
349
"imperialUnits" : [ / o z / , / o u n c e s ? / ] ,
0 commit comments