Search code examples
node.jsbotframeworkazure-qna-maker

ludown parse toqna command issue replaces comma with \r\n


I am using the following command to parse lu file to json file, which then can be given to QnA Maker service to generate kb. But I found that the command replaces comma with "\r\n". For example:

### ? start
        ```markdown
        Lorem ipsum dolor, Lorem ipsum dolor Lorem ipsum dolor.
        ```

The markdown syntax above is getting converted into the following:

{       
    "qnaList": [
        {
          "id": 0,
          "answer": "Lorem ipsum dolor\r\n",
          "source": "custom editorial",
          "questions": [
            "start"
          ],
          "metadata": []
        },
    ]
}

The text is also getting truncated. How do I resolve this issue ?

Thanks


Solution

  • I wasn't able to replicate the truncating of text, even with a direct copy/paste of your code. You may need to update ludown with npm i -g ludown. It may also help to ensure you're using the appropriate format, using these resources:

    1. Official format guidelines
    2. An example .lu file

    There's a PR on GitHub that just got merged yesterday that addresses the \r\n issue.

    It hasn't been pushed to npm yet. You might be able to pull a nightly build in the next couple of days.

    If you'd like to try something more immediate, you can replace the appropriate file in your installed npm package:

    1. Navigate to where NPM installed ludown. On Windows 10, this is %AppData%\Roaming\npm\node_modules\ludown\lib. Other OS locations.
    2. Copy the contents from the GitHub Repo and replace the contents of parseFileContents.js in your npm install directory.
    3. Try running the command again

    You can see my successful implementation of this:

    enter image description here