8000 Markdown support for Perl by fperrad · Pull Request #399 · cucumber/gherkin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Markdown support for Perl #399

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

fperrad
Copy link
Contributor
@fperrad fperrad commented May 21, 2025

🤔 What's changed?

Adding Markdown with Gherkin (MDG) support for Perl.

⚡️ What's your motivation?

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

Javascript is the reference implementation for MDG, but it lacks the gherkin-generate-tokens (and the corresponding tests).

So, I am not confident with the test suite.

Some points need clarification:

  • with MDG, the messages Comment are skipped when building the AST : bug or feature ?
  • I try to reuse testdata/good/*.feature.md.tokens from Markdown support for java #377, but there need some changes. So, these files need a review / validation.

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

fperrad added 6 commits May 21, 2025 13:47
like with Javascript (the MDG reference implementation),
but as there is no `gherkin-generate-tokens` with it,
I don't know if it is a feature or a bug.
@@ -60,7 +60,7 @@ sub build {
Cucumber::Messages::Comment->new(
location => $self->get_location($token),
text => $token->matched_text
);
) unless $self->{uri} =~ m/\.md$/;
Copy link
Contributor
@mpkorstanje mpkorstanje May 21, 2025

Choose a reason for hiding this comment

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

This looks weird. Using Javascript as the reference implementation, I can't find and equivalent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

without this change, I got these 2 failures with AST:

diff --unified <(jq "." ../testdata/good/datatables.feature.md.ast.ndjson) <(jq "." acceptance/testdata/good/datatables.feature.md.ast.ndjson)
--- /dev/fd/63	2025-05-22 10:03:41.040493690 +0200
+++ /dev/fd/62	2025-05-22 10:03:41.057491668 +0200
@@ -1,6 +1,14 @@
 {
   "gherkinDocument": {
-    "comments": [],
+    "comments": [
+      {
+        "location": {
+          "column": 1,
+          "line": 7
+        },
+        "text": "  | --- | --- |"
+      }
+    ],
     "feature": {
       "children": [
         {
diff --unified <(jq "." ../testdata/good/tags.feature.md.ast.ndjson) <(jq "." acceptance/testdata/good/tags.feature.md.ast.ndjson)
--- /dev/fd/63	2025-05-22 10:06:50.779264232 +0200
+++ /dev/fd/62	2025-05-22 10:06:50.779264232 +0200
@@ -1,6 +1,21 @@
 {
   "gherkinDocument": {
-    "comments": [],
+    "comments": [
+      {
+        "location": {
+          "column": 1,
+          "line": 19
+        },
+        "text": "  | ---------- |"
+      },
+      {
+        "location": {
+          "column": 1,
+          "line": 26
+        },
+        "text": "  | ---------- |"
+      }
+    ],
     "feature": {
       "children": [
         {

So, currently the Javascript implementation doesn't populate comments.

I agree with you, this is done in another way that I do with Perl.

Perl implementation has a gherkin-generate-tokens, so all tokens must fully populate

        $self->_set_token_matched( $token,
            Comment => { text => $token->line->line_text, indent => 0 } );

With Javascript, it seems that the token Comment is not complete, and nothing is pushed in the method build of AstBuilder.
With token Comment, token.matchedText is populated in GherkinClassicTokenMatcher but not in GherkinInMarkdownTokenMatcher.

I don't fully understand the Javascript implementation.

@mpkorstanje
Copy link
Contributor

with MDG, the messages Comment are skipped when building the AST : bug or feature ?

I'm not sure if I understand this. I don't think Markdown supports comments. What would a comment in Markdown look like?

Javascript is the reference implementation for MDG, but it lacks the gherkin-generate-tokens (and the corresponding tests).

Would you be able to add the functionality to generate tokens to the JS implementation?

Copy link
Contributor
@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

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

I've given this a once over. Other than my remark on the AST builder I don't see anything too odd. But this PR also exceeds my current capacity for in-depth review.

@ehuelsmann would you be so kind?

@mpkorstanje mpkorstanje requested a review from ehuelsmann May 21, 2025 22:24
@ehuelsmann ehuelsmann self-assigned this May 22, 2025
@fperrad
Copy link
Contributor Author
fperrad commented May 22, 2025

Would you be able to add the functionality to generate tokens to the JS implementation?

sorry, I can't.

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.

3 participants
0