Trailing \n

therzog - February 20, 2008 - 06:03
Project:Markdown with SmartyPants
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hi: I'm having a small problem due to the fact that the Markdown() function adds extra carriage returns to the end of its rendered output:

Line 201:
# Make sure $text ends with a couple of newlines:
$text .= "\n\n";

This causes CCK to interpret the field as non-empty, and it displays the field label with no field value.

I worked around it by just wrapping the _marksmarty_process in a trim function.

#1

milianw - February 20, 2008 - 12:37

trim might not be a good idea, rtrim would be better. Take this markdown output for example:

    this is code
    this is code

rtrim would be finde, but trim would un-indent the first line.

An even better fix in my eyes would be to check for empty text in the process function:

<?php
function marksmarty_process($text, $format) {
  if (empty(
$text)) {
    return;
  }
 
// ...
}
?>

#2

moshe weitzman - February 20, 2008 - 18:08
Status:active» fixed

fixed this and moved include files

#3

Anonymous (not verified) - March 5, 2008 - 18:12
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.