If using drush_html_to_text instead of drupal_html_to_text, and if the release notes are from a Drupal 7 project instead of a Drupal 6 project, then the releasenotes will be missing line breaks which are otherwise present.

Comments

moshe weitzman’s picture

Priority: Normal » Major

I've run into this too. To reproduce it, browse to some non drupal directory and run drush rln webform-7.x

greg.1.anderson’s picture

Status: Active » Needs review
StatusFileSize
new2.39 KB

This patch adjusts the formatting in the default implementation in drush_html_to_text to better handle linebreaks in Drupal release notes.

Also adds --html option, which is useful for debugging if nothing else.

jonhattan’s picture

Status: Needs review » Needs work

It still doesn't work for drush rln webform from a drupal7 site. I've traced drupal_html_to_text() with no luck and found this ugly workaround to work:

function drush_html_to_text($html, $allowed_tags = NULL) {
  if (function_exists('drupal_html_to_text')) {
    if (drush_drupal_major_version() == 7) {
      $html = str_replace('<br/>', "\n", $html);
    }
    return drupal_html_to_text($html, $allowed_tags);
  }
moshe weitzman’s picture

I find it odd that drupal.org would format drupal 7 releases differently. How do we know that this is the right condition?

moshe weitzman’s picture

Oh, I get it now. drupal_html_to_text() varies by release. That makes more sense. I'm fine with jonhattan's suggestion if it works for Greg.

greg.1.anderson’s picture

Status: Needs work » Needs review
StatusFileSize
new4.1 KB

Unfortunately, there are other problems, and they seem to be in d7. If you compare the releasenotes between webform and logintoboggan on d7, you'll see that the former breaks issues via
, and the later breaks via

  • . When html lists are used, there are CRs in the text before the replacement, but d7 takes them out when formatting the list, resulting in poor readability. This is a d7 problem.

    Since there does not seem to be a good way to work around the d7 problem, this patch invariantly uses our simple version of html to text to print release notes.

    Probably need to put an issue in the d7 queue too.

  • jonhattan’s picture

    Status: Needs review » Reviewed & tested by the community

    Other than this one, the patch looks good.

    +++ commands/pm/pm.drush.inc	3 Jan 2011 15:01:47 -0000
    @@ -1424,17 +1427,8 @@ function _drush_pm_releasenotes($request
    +      $break = '<br\>';
    
    jonhattan’s picture

    Status: Reviewed & tested by the community » Needs work

    Wait. It seems this is no longer needed...

    /**
     * Convert html to readable text.  Calls through
     * to drupal_html_to_text if it is available, or
     * reverts to a simpler algorithm when it is not.
     *
     * @param string $html
     *   The html text to convert.
     *
     * @return string
     *   The plain-text representation of the input.
     */
    function drush_html_to_text($html, $allowed_tags = NULL) {
      if (function_exists('drupal_html_to_text')) {
        return drupal_html_to_text($html, $allowed_tags);
      }
      else {
        return _drush_html_to_text($html, $allowed_tags);
      }
    }
    
    greg.1.anderson’s picture

    I left it that way on purpose, so that other code that may want to convert html to text still has access to the Drupal version. Should we just get rid of that in favor of consistency? The caller can always decide to call drupal_html_to_text if it is desired.

    jonhattan’s picture

    I prefer get rid of it.

    greg.1.anderson’s picture

    Status: Needs work » Needs review
    StatusFileSize
    new4.58 KB

    Here it is, all gone. As an added bonus, this patch also remembers to convert > and such to their plaintext equivalents.

    moshe weitzman’s picture

    Status: Needs review » Reviewed & tested by the community

    rtbc.

    greg.1.anderson’s picture

    Status: Reviewed & tested by the community » Fixed

    Committed.

    Status: Fixed » Closed (fixed)

    Automatically closed -- issue fixed for 2 weeks with no activity.