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

h is singled out in parsing #185

Open
RTUnreal opened this issue Oct 3, 2021 · 0 comments
Open

h is singled out in parsing #185

RTUnreal opened this issue Oct 3, 2021 · 0 comments

Comments

@RTUnreal
Copy link

RTUnreal commented Oct 3, 2021

I want to use this library for a changelog parser.

But while testing out the output structure of the parser, i found out, it singles out h's in text while using links or references in the text.

The following code sample is used as a baseline (dd is a function from symfony link):

class ChangelogParser extends GithubMarkdown
{
    public function parseChangelog(string $text)
    {
        parent::prepare();

        if (ltrim($text) === '') {
            return '';
        }

        $text = str_replace(["\r\n", "\n\r", "\r"], "\n", $text);

        parent::prepareMarkers($text);

        $blocks = parent::parseBlocks(explode("\n", $text));

        dd($blocks);
    }
}

the following markdown doesn't trigger the error:

qwertzuiopüasdfghjklöäyxcvbnm

output:

^ array:1 [▼
  0 => array:2 [▼
    0 => "paragraph"
    "content" => array:1 [▼
      0 => array:2 [▼
        0 => "text"
        1 => "qwertzuiopüasdfghjklöäyxcvbnm"
      ]
    ]
  ]
]

but these do:

qwertzuiopüasdfghjklöäyxcvbnm[test](https://github.com)

output:

^ array:1 [▼
  0 => array:2 [▼
    0 => "paragraph"
    "content" => array:5 [▼
      0 => array:2 [▼
        0 => "text"
        1 => "qwertzuiopüasdfg"
      ]
      1 => array:2 [▼
        0 => "text"
        1 => "h"
      ]
      2 => array:2 [▼
        0 => "text"
        1 => "jklöäyxcvbnm"
      ]
      3 => array:6 [▼
        0 => "link"
        "text" => array:1 [▼
          0 => array:2 [▼
            0 => "text"
            1 => "test"
          ]
        ]
        "url" => "https://github.com"
        "title" => null
        "refkey" => null
        "orig" => "[test](https://github.com)"
      ]
      4 => array:2 [▼
        0 => "text"
        1 => ""
      ]
    ]
  ]
]
qwertzuiopüasdfghjklöäyxcvbnm[test]

[test]: https://github.com

output:

^ array:1 [▼
  0 => array:2 [▼
    0 => "paragraph"
    "content" => array:5 [▼
      0 => array:2 [▼
        0 => "text"
        1 => "qwertzuiopüasdfg"
      ]
      1 => array:2 [▼
        0 => "text"
        1 => "h"
      ]
      2 => array:2 [▼
        0 => "text"
        1 => "jklöäyxcvbnm"
      ]
      3 => array:6 [▼
        0 => "link"
        "text" => array:1 [▼
          0 => array:2 [▼
            0 => "text"
            1 => "test"
          ]
        ]
        "url" => null
        "title" => null
        "refkey" => "test"
        "orig" => "[test]"
      ]
      4 => array:2 [▼
        0 => "text"
        1 => ""
      ]
    ]
  ]
]
qwertzuiopüasdfghjklöäyxcvbnm

[test]: https://github.com

output:

^ array:1 [▼
  0 => array:2 [▼
    0 => "paragraph"
    "content" => array:3 [▼
      0 => array:2 [▼
        0 => "text"
        1 => "qwertzuiopüasdfg"
      ]
      1 => array:2 [▼
        0 => "text"
        1 => "h"
      ]
      2 => array:2 [▼
        0 => "text"
        1 => "jklöäyxcvbnm"
      ]
    ]
  ]
]
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

No branches or pull requests

1 participant