Created
October 23, 2018 17:53
-
-
Save Janooba/caf7e440479b8fa613b53c26bc89dc8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int u = 0; u < blocks.Length; u++) | |
for (int v = 0; v < blocks[u].Span.Length; v++) | |
{ | |
Block block = blocks[u]; | |
Span span = blocks[u].Span[v]; | |
// If there is a style, it has a list style, and it's list type isn't "None" | |
if (span.Text.Trim().Length > 0 && | |
block.Style != null && | |
block.Style.ListStyle != null && | |
block.Style.ListStyle.ListType != "None") | |
{ | |
if (block.Style.ListStyle.ListType == "Bullet") | |
{ | |
stringBuilder.Append(block.Style.ListStyle.BulletChar + " "); | |
currentListNumber = 1; // Reset | |
} | |
else if (block.Style.ListStyle.ListType.Contains("ListNumbered")) | |
{ | |
stringBuilder.Append(currentListNumber++ + ". "); | |
} | |
else | |
{ | |
/* I don't know what other list types there are, | |
* but it's safe to say they aren't numbered. | |
*/ | |
currentListNumber = 1; | |
} | |
} | |
else // No list, reset to 1 | |
{ | |
currentListNumber = 1; | |
} | |
// Add a space between spans that aren't line-breaks | |
if (u > 0 && u < blocks.Length - 1 && !span.Text.EndsWith("\n")) | |
stringBuilder.Append(" "); | |
stringBuilder.Append(span.Text); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment