npm/newww — pull request #431 by ceejbot (2014-12-13 01:22:39+00:00)
Title: Fixed #417: rendering applet file tags from readmes

The readme sanitization code was effectively a no-op because of a
code sequencing error. elevateLatestVersionInfo() was being called
*after* readme sanitization and replacing all the cleaned data with
unsanitized original content. Because it wasn't being called, the
markdown & sanitization process was likely always failing anyway.

Made several changes to improve code readability & clarity, as well
as to fix the bug:

- Changed the name of package() to match how it's used: presentPackage()
- Moved elevateLatestVersionInfo() to much earlier in presentPackage()
- Changed parseReadme() to no longer require a callback, since it isn't
actually async
- Restructured parseReadme() so that all paths through it, including the
code path where marked parsing fails, return sanitized data. It no longer
can return an error.
- Defended against null readme blocks being passed into parseReadme().
- Fixed a problem in the package route where the `pkg` variable from a
callback was shadowing an existing variable.

The package to use when testing this fix is `benchmark`, which has now been added to the list of common packages that a dev installation will replicate.