Skip to content
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

Add support for GitHub style tables #111

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ekblom
Copy link

@ekblom ekblom commented Mar 21, 2017

Hi,

I took the code from #90 and tried to fix your comments.

Would close #42.

/ekblom

@Knagis
Copy link
Owner

Knagis commented Mar 22, 2017

Thank you! I will review as soon as I can find enough free time. The worst case scenario ir right after Easter when I have some free days though I hope to do so sooner.

@ekblom
Copy link
Author

ekblom commented Mar 22, 2017

No problem if you don't have time in a while, gives me time to correct some failing tests regarding https://github.github.com/gfm/#tables-extension- and the examples there.

@ekblom
Copy link
Author

ekblom commented Mar 25, 2017

@Knagis i have implemented GFM:s task lists (https://github.github.com/gfm/#task-list-items-extension-), should i merge those changed to this PR or should i make a new PR for that?

Copy link
Owner

@Knagis Knagis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finished reviewing the code. There are few files that should be reformatted so that it does not show every line as a change. Other than that the one big problem is relying on StringPart representing a whole line - which is not a guarantee.

CommonMarkConverter.ProcessStage3(ast, str, WriteSettings);
html = str.ToString();
}
Assert.AreEqual("<table><thead><tr><th>First Header</th><th>Second Header</th></tr></thead><tbody><tr><td>Content Cell</td><td>Content Cell</td></tr><tr><td>Content Cell</td><td>Content Cell</td></tr></tbody></table>", html);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be better if every would be followed by a newline? Perhaps even each cell?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is according to the GHFM-specs, i think its better to leave it as is to have it the same as the spec.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, agree

/// The parser will recognize syntax <c>[foo]</c>, which will be encoded in a separate AST node that the host application may evaluate as desired.
/// <summary>
/// The parser will recognize syntax <c>[foo]</c>, which will be encoded in a separate AST node that the host application may evaluate as desired.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indent

///
/// Refer to https://help.github.com/articles/organizing-information-with-tables/ for more examples
/// </summary>
GithubStyleTables = 3,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub - capital "H"

/// <summary>
/// The parser will recognize
///
/// First Header | Second Header
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add <code> around the example (I suppose that is the correct tag as otherwise the intellisense could format the example).

@@ -0,0 +1,48 @@
using System;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file should be deleted

private static void MakeCell(string text, Block row, ref int offset)
{
int length = text.Length;
string trimmedText = text.TrimStart();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a new string copy trimmedText should not be created - instead the whitespaces should be counted within the text and then the StringContent created from the text instance.

Though as before, it could be left as a //TODO:

continue;

var lineLength = line.Length;
string actualLine = line.Source.Substring(line.StartIndex, line.Length);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not create the string copy actualLine, instead use the string part as is.

{
if ((settings.AdditionalFeatures & CommonMarkAdditionalFeatures.GithubStyleTables) == 0) return false;

var parts = b.StringContent.RetrieveParts().Array;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the RetrieveParts() do not guarantee that they will be split on the line. A single part could contain multiple lines and also a single line could consist of multiple parts.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me an example of when a line would be multiple parts?

@@ -0,0 +1,234 @@
using System;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this file


System.Diagnostics.Debug.WriteLine(message, "Warning");
}
/// <summary>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please reformat using 4 space indent

@qJake
Copy link

qJake commented Oct 18, 2017

What is the status of this? Does CommonMark.NET support tables yet?

@ekblom
Copy link
Author

ekblom commented Oct 18, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CommonMarkAdditionalFeatures like tables
4 participants