Commit Graph

1515 Commits (db7564d72ace45cc95e5046c69d81dadb4e191a2)

Author SHA1 Message Date
Matt Miller db7564d72a Conversions: do not encode entities on numbers.
This otherwise encodes the <sup> tags, rendering them impotent. This
might not be exactly the right solution, either.
2014-07-28 09:43:05 +08:00
Matt Miller cabd9c8c8a NumberStyle: add with_html method.
This also required some additional changes to how number_regex is
computed.  That was sort of overdue, anyway.

HTML styling is simply display styling plus super-scripted exponents, at
thispoint.
2014-07-28 09:24:40 +08:00
Matt Miller 1676300aed NumberStyler: improve number-matching regex.
The major change is matching the exponentials more carefully.  They only
count if they have <number>E<integer> otherwise they won't work.

Also include a suggested change from @mintsoft to better handle the
spacing of numbers and units in Conversions, by separating them using
our defined regexes.

All-in-all, much more resilient!
2014-07-28 08:17:49 +08:00
Matt Miller 65d6f76978 NumberStyle: tighten up check for exponentials.
Also, some adjustments to Calculator to allow its tests to pass.
Still clearly not properly factored, but at least everything "works"
for the moment.
2014-07-27 22:23:04 +08:00
Matt Miller 31f49268b8 Conversions: style the factors as well as the results
This may (or may not) give a nicer look and more clear understanding of
how the input was interpreted.

Looking for feedback from @mintsoft on whether or not this is actually
better.  (Take a look at the test changes in particular to see the
effects.)
2014-07-27 21:15:45 +08:00
Matt Miller f4a7c0c857 NumberStyle: add rudimentary support for exponentials.
Also, minor updates to Conversions to make it work there.

NB: This is clearly not properly factored, yet! This is the first step
to get feedback and improvements from @mintsoft.

- Make number style stuff aware of how to deal with case-insensitive
  expoentials.
- Produce consistent output of such strings.

The display format was chosen to be consistent with the output for
Calculator.  Also, the parsing is not quite correct as you can't have a
mantissa in the exponent, but this won't catch that.

Should we also do "for_display" on the factors for consistency?

Any and all feedback or improvements are appreciated.

This also breaks the Calculator tests, but I will worry about fixing
those once everything stabilizes.
2014-07-27 20:58:05 +08:00
Rob Emery d7569e6d82 Conversions: Minor cleanup 2014-07-26 23:06:50 +01:00
Rob Emery eee3b51734 Merge remote-tracking branch mwmiller's 'style_role/style_role' into mintsoft/conversion_calcs
Conflicts:
	lib/DDG/Goodie/Calculator.pm
2014-07-26 22:52:49 +01:00
Jag Talon f9c3c07aa2 Merge pull request #536 from gdrooid/anagram-fix
[WIP] Anagram: read words only once.
2014-07-22 10:33:01 -04:00
Zaahir Moolla f40727f2f0 Merge pull request #554 from DavidMascio/lower
Adding Lowercase.pm
2014-07-18 23:09:59 -04:00
Jag Talon 4830b4450a Merge pull request #550 from killerfish/md5fix
MD5 fix for issue #546
2014-07-18 16:36:17 -04:00
DavidMascio 4a5f24136f Added new triggers lc, strtolower, and tolower 2014-07-17 08:44:14 -04:00
DavidMascio 22d2d1a962 Add Lowercase.pm 2014-07-16 22:57:33 -04:00
Usman Raza 717098e742 removed whitespace 2014-07-13 19:56:36 +05:00
Usman Raza 0b1923d1b7 updated check 2014-07-13 19:46:16 +05:00
Usman Raza 7daca07b8f added test and updated RE 2014-07-13 18:20:21 +05:00
Usman Raza d87be41e31 added test 2014-07-13 16:25:17 +05:00
Usman Raza d0bb378092 added condition on fail 2014-07-13 13:49:51 +05:00
Usman Raza 7464279740 MD5fix 2014-07-13 13:25:15 +05:00
gdrooid 8d25f5c0dc Anagram: Tell the user if we found no anagrams. 2014-07-11 17:58:33 +02:00
Jag Talon ee621a7985 Merge pull request #520 from duckduckgo/mintsoft/private_network
Styling and HTML updates for PrivateNetwork
2014-07-10 16:26:53 -04:00
Jag Talon bf5922bd1c Merge pull request #524 from wilkox/convert_latlon
Add latitude/longitude conversion Goodie
2014-07-10 13:34:26 -04:00
Jag Talon d821456406 Merge pull request #517 from duckduckgo/dylan/HexToDec
wrote HexToDec & test
2014-07-10 13:33:38 -04:00
Matt Miller 239bdb9072 Calculator: ignore attempts at subnet notation.
This one is much harder to hit, because the dotted quads must have 3
digits in each of the last 3 positions and they tend to start zero-ing
the mask earlier, but might as well cover this better, too.

Thanks to @mintsoft for the heads-up.
2014-07-10 05:33:43 +08:00
Matt Miller 89b900c5b1 Calculator: ignore probable attempts at CIDR notation.
If we get a dotted quad, slash and a number in the range of 0-32, it
seems more likely this is talking about network addresses, than trying
to do a calculation.

I, personally, think it's unlikely we ever should be dealing with dotted
quads, but I want to leave in the possiblity of a pasted-in euro-style
value.

Fixes #541.
2014-07-10 05:05:04 +08:00
gdrooid 334f504f3c Anagram: hardcoded joke 2014-07-09 22:53:24 +02:00
Matt Miller efad091e9d Calculator: ignore probable attempts at hex notation.
This regex overreaches a bit, because query_nowhitespace doesn't
guarantee we'll see word-breaks exactly where we might expect.  This is
sufficient for now, but this triggering needs a general rethink.

Addresses some concerns in issue #517.
2014-07-10 04:32:04 +08:00
gdrooid fde0cf24e0 Anagram: Don't join the same thing twice. 2014-07-09 17:35:30 +02:00
gdrooid 674d2536d8 Anagram: Add comments to the code. 2014-07-09 17:31:01 +02:00
Zaahir Moolla fec94ad170 refactor of #543 2014-07-09 10:51:15 -04:00
jagtalon ef7a86d7d0 Parcelforce: Skip queries that start with ISBN.
Also added a check if `$parcel_number` exists in the first place.
2014-07-09 13:55:21 +00:00
gdrooid d882640321 Anagram: Add myself to the attribution list. :D 2014-07-09 15:38:34 +02:00
Jag Talon 9c61d96fa7 Merge pull request #535 from gdrooid/md5-fix
MD5: 'md5 of' works as expected
2014-07-07 14:51:06 -04:00
gdrooid df89fb3099 Anagram: Add support for quotes. Fix issue with uppercase and include test for it. 2014-07-07 20:24:25 +02:00
gdrooid 8fc6c203aa MD5: Support quotes. Add test. 2014-07-07 20:10:36 +02:00
gdrooid 7e5b3e49e6 Anagram: modified style to match other IAs. 2014-07-07 19:42:56 +02:00
gdrooid cafd4f9574 Anagram: check if shuffle returns the same word. 2014-07-07 15:15:34 +02:00
gdrooid d4b01d20cf Anagram: Code refactoring. 2014-07-07 14:57:11 +02:00
David Wilkins 4c8e8bdb8d Correct misspelling 2014-07-06 15:32:30 +08:00
David Wilkins 7fb27ad92b Bigger, better, faster, stronger regexes 2014-07-05 20:19:53 +08:00
David Wilkins e9a5c523da Allow cardinals in decimal form 2014-07-05 15:20:26 +08:00
David Wilkins 228a094be3 Support multiple lat/lons 2014-07-05 13:00:59 +08:00
David Wilkins 54148bae21 Four-space soft indenting 2014-07-05 11:51:17 +08:00
Zaahir Moolla 71cf4afab8 Make sure we don't cache results for random goodies 2014-07-04 19:20:48 -04:00
Zaahir Moolla 1e2740ad70 Add srand() to other goodies using rand 2014-07-04 19:06:43 -04:00
Zaahir Moolla 64122adb09 ensure consistent indentation 2014-07-04 18:59:22 -04:00
Zaahir Moolla 39fae8a17c Add srand() to handle fn for Goodies using rand() 2014-07-04 18:30:29 -04:00
gdrooid 801c3d561c MD5: Add tests and fix previous commit. 2014-07-04 23:05:13 +02:00
gdrooid 0aa023c079 MD5: 'md5 of' works as expected 2014-07-04 22:58:54 +02:00
jagtalon 989b1eb8ce Reverse: Limit the trigger word to "reverse text".
This is triggering very often, and it's probably best to limit the trigger word to "reverse text". It triggers with:

- "reverse dns 8.8.8.8."
- "reverse parameter sniffing"
- 'put car in reverse'
2014-07-04 14:43:19 +00:00