github-issue-parser icon indicating copy to clipboard operation
github-issue-parser copied to clipboard

feat: improve body parsing logic

Open Ansuel opened this issue 1 year ago • 3 comments

Current body parsing logic with trim() + split("###") is too fragile and pose problems with some body that contains case with ### in the middle of the line or case with codeblock ``` section.

These case will cause the script to parse these as separate section and produce wrong outputs and in some case even prints error assuming things are checkbox and errors out on the concat function.

To make the parsing logic more solid, implement a dedicated function and parse with this logic:

  • We split the body for "\n"
  • We ignore codeblock ``` section
  • We check "###" only at the start of the line
  • We check for "### " (with the space included) as that is the correct section Github issue template expects.

With the following change case like:

root@OpenWrt:~# cat /boot/config.txt

Are correctly parsed as all part of a single section instead of being wrongly treated as different empty sections.

Signed-off-by: Christian Marangi [email protected]

Ansuel avatar Apr 26 '24 17:04 Ansuel

Discovered by this https://github.com/openwrt/openwrt/issues/15265

Made further research and found the root of the problem!

Ansuel avatar Apr 26 '24 17:04 Ansuel