# SDL: wikiheaders.pl: Fix some wordwrap whitespace issues.

**URL:** <https://discourse.libsdl.org/t/sdl-wikiheaders-pl-fix-some-wordwrap-whitespace-issues/32141>\
**Category:** SDL Commits\
**Created:** [July 14, 2021, 3:04pm UTC](https://discourse.libsdl.org/t/sdl-wikiheaders-pl-fix-some-wordwrap-whitespace-issues/32141 "2021-07-14T15:04:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [July 14, 2021, 3:04pm UTC](https://discourse.libsdl.org/t/sdl-wikiheaders-pl-fix-some-wordwrap-whitespace-issues/32141/1 "2021-07-14T15:04:41Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/bab0eb71cee63a85bd296a1ec3ae8a2c9dd303e6>

```diff
From bab0eb71cee63a85bd296a1ec3ae8a2c9dd303e6 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Wed, 14 Jul 2021 10:03:31 -0400
Subject: [PATCH] wikiheaders.pl: Fix some wordwrap whitespace issues.

---
 build-scripts/wikiheaders.pl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/build-scripts/wikiheaders.pl b/build-scripts/wikiheaders.pl
index 80a15d3d6..59b093542 100755
--- a/build-scripts/wikiheaders.pl
+++ b/build-scripts/wikiheaders.pl
@@ -28,11 +28,15 @@ sub wordwrap_with_bullet_indent { # don't call this directly.
     my $str = shift;
     my $retval = '';
 
+ #print("WORDWRAP BULLET ('$bullet'):\n\n$str\n\n");
+
     # You _can't_ (at least with Pandoc) have a bullet item with a newline in
     # MediaWiki, so _remove_ wrapping!
     if ($wordwrap_mode eq 'mediawiki') {
         $retval = "$bullet$str";
         $retval =~ s/\n/ /gms;
+ $retval =~ s/\s+$//gms;
+ #print("WORDWRAP BULLET DONE:\n\n$retval\n\n");
         return "$retval\n";
     }
 
@@ -105,6 +109,8 @@ sub wordwrap {
 
     #print("\n\nWORDWRAP:\n\n$str\n\n\n");
 
+ $str =~ s/\A\n+//ms;
+
     while ($str =~ s/(.*?)(\`\`\`.*?\`\`\`|\<syntaxhighlight.*?\<\/syntaxhighlight\>)//ms) {
         #print("\n\nWORDWRAP BLOCK:\n\n$1\n\n ===\n\n$2\n\n\n");
         $retval .= wordwrap_paragraphs($1); # wrap it.

```
