savannah-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[savannah-help-public] [sr #109696] markdown verbatim (for code snippets


From: Ineiev
Subject: [savannah-help-public] [sr #109696] markdown verbatim (for code snippets) does not respect white-space
Date: Fri, 7 Jun 2019 03:34:56 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0

Update of sr #109696 (project administration):

                  Status:                    None => In Progress            
             Assigned to:                    None => ineiev                 

    _______________________________________________________

Follow-up Comment #1:

First, we want to wrap those verbatim elements at reasonable width --- if they
aren't, long lines break rendering of whole item.

Then, it's desirable to make this work with CSS-unaware browsers as well. I'd
rather reformat spaces using   like this:

function markup_verbatim_spaces ($ns)
{
  if ($ns < 1)
    return "";
  if ($ns < 2)
    return " ";
  $ret = " <span>";
  $ns--;
  while ($ns)
    {
      $ns--;
      $ret .= '&nbsp;';
    }
  return $ret . "</span>";
}
...
          $verbatim_buffer = str_replace ("\r\n", "\n", $verbatim_buffer);
          $verbatim_buffer = str_replace ("\n\r", "\n", $verbatim_buffer);
          $verbatim_buffer = str_replace ("\r", "\n", $verbatim_buffer);
          # Hopefully preserve spaces in HTML allowing line breaking.
          $verb_out = "";
          $ns = 0;
          for ($i = 0; $i < strlen ($verbatim_buffer); $i++)
            {
              $next_char = substr ($verbatim_buffer, $i, 1);
              if ($next_char === ' ')
                {
                  $ns++;
                  continue;
                }
              if ($ns)
                {
                  $verb_out .= markup_verbatim_spaces ($ns);
                  $ns = 0;
                }
              $verb_out .= $next_char;
            }
          $verbatim_buffer = $verb_out . markup_verbatim_spaces ($ns);

          $verbatim_buffer = str_replace ("\t",
            "<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>\t",
                                          $verbatim_buffer);
          $verbatim_buffer = str_replace ("\n", "<br />\n", $verbatim_buffer);

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/support/?109696>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]