A simple script to convert Markdown to rich text?

Most of the relevant Markdown is converted to rich text, but the code blocks have some issues:

BEFORE execution of the script:

AFTER execution of the script:

What is wrong

The result in the code block contains extra empty lines added, which were not present in the original code.
These extra empty lines are above and under the code lines in the code block.

Here is the used script

const fibery = context.getService('fibery');
const yNoteDB = 'Yuri/Y Note';

async function unescapeMarkdownInYNoteDescription(currentEntityId) {
    try {
        // Get the current Y Note entity with its Description field
        const yNoteEntity = await fibery.getEntityById(yNoteDB, currentEntityId, ['Description']);
        let descriptionField = yNoteEntity['Description'];

        if (descriptionField && descriptionField.Secret) {
            // Get the Markdown content from the Description field
            let markdownContent = await fibery.getDocumentContent(descriptionField.Secret, 'md');

            // Unescape Markdown by removing backslashes before Markdown syntax, including code blocks
            let unescapedMarkdown = markdownContent.replace(/\\([#*`_~>\[\]])/g, '$1');

            // Update the Description field with the unescaped Markdown
            await fibery.setDocumentContent(descriptionField.Secret, unescapedMarkdown, 'md');

            console.log('Description field of Y Note has been updated.');
        } else {
            console.log('No Description field or content found for the Y Note entity.');
        }
    } catch (error) {
        console.error('Error in script:', error);
    }
}

// This unction is called with the current entity ID
await unescapeMarkdownInYNoteDescription(args.currentEntities[0].id);