Skip to content

Commit ffae9f6

Browse files
committed
Do not trim all lines
1 parent b01e20d commit ffae9f6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

build.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static string getSectionSlug(string sectionName) =>
254254

255255
foreach (var post in posts)
256256
{
257-
var postLines = post.Text.Split('\n').Select(l => l.Trim());
257+
var postLines = post.Text.Split('\n');
258258
var postBuilder = new StringBuilder();
259259
var sections = new List<object>();
260260
var isInContainingSection = false;
@@ -272,8 +272,9 @@ string getHeaderWithSectionLink(string sectionSlug, string line) =>
272272
foreach (var line in postLines)
273273
{
274274
var lineToAdd = line;
275+
var trimmedLine = lineToAdd.Trim();
275276

276-
if (Regex.Match(lineToAdd, @"(?:<h2>)([^<]*)(?:<\/h2>)$") is Match matchContainingHeader && matchContainingHeader.Success)
277+
if (Regex.Match(trimmedLine, @"(?:<h2>)([^<]*)(?:<\/h2>)$") is Match matchContainingHeader && matchContainingHeader.Success)
277278
{
278279
if (isInInnerSection)
279280
{
@@ -290,11 +291,11 @@ string getHeaderWithSectionLink(string sectionSlug, string line) =>
290291
var sectionSlug = getSectionSlug(sectionName);
291292

292293
addSection(sectionName, sectionSlug, 1);
293-
lineToAdd = getHeaderWithSectionLink(sectionSlug, lineToAdd);
294+
lineToAdd = getHeaderWithSectionLink(sectionSlug, trimmedLine);
294295

295296
isInContainingSection = true;
296297
}
297-
else if (Regex.Match(lineToAdd, @"(?:<h3>)([^<]*)(?:<\/h3>)$") is Match matchInnerHeader && matchInnerHeader.Success)
298+
else if (Regex.Match(trimmedLine, @"(?:<h3>)([^<]*)(?:<\/h3>)$") is Match matchInnerHeader && matchInnerHeader.Success)
298299
{
299300
if (isInInnerSection)
300301
{
@@ -305,7 +306,7 @@ string getHeaderWithSectionLink(string sectionSlug, string line) =>
305306
var sectionSlug = getSectionSlug(sectionName);
306307

307308
addSection(sectionName, sectionSlug, 2);
308-
lineToAdd = getHeaderWithSectionLink(sectionSlug, lineToAdd);
309+
lineToAdd = getHeaderWithSectionLink(sectionSlug, trimmedLine);
309310

310311
isInInnerSection = true;
311312
}

0 commit comments

Comments
 (0)