-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved Multi-Line Quoting, you can now separate two quotes. #1974
Improved Multi-Line Quoting, you can now separate two quotes. #1974
Conversation
-Updated InitialContent with some examples.
It is one line away from CommonMark conformance, but it means that a Quote can't go back to indentation 1 after going up to indentation 2. |
I think CommonMark is the expected output. @WilliamABradley You can come back to outer Quote. Try this
Output And multiline for nested Quote would be
Output |
else if (paragraphText.Length > 0 && ((markdown[startOfLine - 2] == '>' || markdown[startOfLine - 1] == '>') || inQuoteNewLine)) | ||
{ | ||
// If the start of the line is a QuoteBlock, and the Paragraph has already been started, Create a new line. | ||
paragraphText.Append("\r\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Environment.NewLine
?
@@ -96,6 +96,9 @@ internal static List<MarkdownBlock> Parse(string markdown, int start, int end, i | |||
int previousStartOfLine = start; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parse method seems really large, do we have a work item to split it up into other methods that we can more easily unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would likely happen if we go through with #1767
@@ -154,7 +157,16 @@ internal static List<MarkdownBlock> Parse(string markdown, int start, int end, i | |||
// But it doesn't matter if this is not the start of a new paragraph. | |||
if (!lineStartsNewParagraph || nonSpaceChar == '\0') | |||
{ | |||
break; | |||
// Continue the Quote if the previous line was a quote. | |||
if (((previousStartOfLine - 2) >= 0 && markdown[previousStartOfLine - 2] == '>') || ((previousStartOfLine - 1) >= 0 && markdown[previousStartOfLine - 1] == '>')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are spaces allowed before the >
? Or is there a trim somewhere?
@@ -277,6 +289,12 @@ internal static List<MarkdownBlock> Parse(string markdown, int start, int end, i | |||
paragraphText[paragraphText.Length - 2] = '\r'; | |||
paragraphText[paragraphText.Length - 1] = '\n'; | |||
} | |||
else if (paragraphText.Length > 0 && ((markdown[startOfLine - 2] == '>' || markdown[startOfLine - 1] == '>') || inQuoteNewLine)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a bounds check here as well?
I updated my test markdown, and I have been attempting to mimic CommonMark, it is nearly done, however, I am struggling to get the Parser to go back out of the nest after a nest, as you can see from the new behavior image. Quote2.3 should be part of the rest of Quote2. |
/// <param name="searchString">String to search through</param> | ||
/// <param name="toFind">Substring to find</param> | ||
/// <returns>Number of times the substring occurs</returns> | ||
public static int Occurrences(this string searchString, string toFind) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this method is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I'm not sure it does what it's being documented. Why are you checking every character in toFind with every character in searchString?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the current logic only works in the single character case (which is how it's used in the PR). If we want a function like this, we should add unit tests and make sure it works for the other scenarios. Though it'd probably be easier/faster to use the built-in IndexOf
or Split
methods to do this, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
@michael-hawker @nmetulev Fixed the CommonMark conformance issue, this is now ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vijay-Nirmal fixed that issue, let me know if you discover any more. It is pretty mind bending logic. |
@Vijay-Nirmal, up to you now. |
-Updated InitialContent with some examples.
Issue: #1761
Testing with:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
Icon has been created (if new sample) following the Thumbnail Style Guide and templatesOther information
The current implementation is a bit of a selection of different styles, as all Renderers differ in their results, this discussion can be continued to determine a better conformance if need be:
StackEdit
GitHub
CommonMark.js
Reddit
Dillinger.io
VS Code