Skip to content

<code> block not honoured #62

@wdoekes

Description

@wdoekes

I see that the block does (a) not get a

-style layout and (b) gets whitespace trimmed.

Here is a suboptimal, yet working, fix. All that whitespace trimming that you were doing is not really needed for html, and not doing that keeps the blocks looking like they should.

diff --git a/doclets/standard/stylesheet.css b/doclets/standard/stylesheet.css
index ec4b868..871e275 100644
--- a/doclets/standard/stylesheet.css
+++ b/doclets/standard/stylesheet.css
@@ -196,6 +196,11 @@ code.signature {
     margin: 10px 0;
 }

+/* Inline <code> blocks in descriptions */
+div.comment p code {
+    white-space: pre;
+}
+
 div.details {
     margin: 10px 0 10px 20px;
 }
diff --git a/formatters/htmlStandardFormatter.php b/formatters/htmlStandardFormatter.php
index 69ccc61..7d314fa 100644
--- a/formatters/htmlStandardFormatter.php
+++ b/formatters/htmlStandardFormatter.php
@@ -13,10 +13,10 @@
         function toFormattedText($text)
         {
             $text = $this->_addListMarkupUL($text);
-            $text = '<p>'.str_replace("\n\n", '</p><p>', $this->toPlainText($text)).'</p>';
+            $text = preg_replace("/[ \t\r]+\n/", "\n", $text); // trim only trailing WS
+            $text = '<p>'.str_replace("\n\n", '</p><p>', $text).'</p>';
             $text = str_replace('<ul>', "</p>\n<ul>", $text);
             $text = str_replace('</ul>', "</ul>\n<p>", $text);
-            $text = $this->_removeWhitespace($text);
             return $text;
         }

Regards,
Walter Doekes
OSSO B.V.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions