Skip to content

The command 'markdown.api.render' generates different html content for the same markdown string. #103076

@jdneo

Description

@jdneo

Version: 1.47.2 (system setup)
Commit: 17299e4
Date: 2020-07-15T18:22:06.216Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363

Steps to Reproduce:

  1. I have a markdown file with a ToC of it. Basically it looks like:
## Table of Content
- [Introduction](#introduction)

## Introduction
....
  1. I'm using 'markdown.api.render' command to render the markdown string to html string, something like this:
let markdownString: string = await fse.readFile(markdownFilePath, 'utf8');
const html = await commands.executeCommand('markdown.api.render', markdownString);
  1. I found out that, start from the second time calling this command, the ToC won't work anymore. After checking the generated html string, I found that the id for the Introduction will appended by a number:
<ul>
  <li data-line="3" class="code-line"><a href="#introduction" data-href="#introduction" title="#introduction">Introduction</a></li>
</ul>
...
<h2 id="introduction-1" data-line="32" class="code-line">Introduction</h2>

Is this expected? And what's the suggested way to use this command to render the same markdown string multiple time?

Thanks.

Does this issue occur when all extensions are disabled?: Yes/No

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bughelp wantedIssues identified as good community contribution opportunitiesinsiders-releasedPatch has been released in VS Code InsidersmarkdownMarkdown support issuesverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions