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

getMarkdownHeadersInCell does not handle headers with HTML tags #210520

Open
DonJayamanne opened this issue Apr 17, 2024 · 1 comment
Open

getMarkdownHeadersInCell does not handle headers with HTML tags #210520

DonJayamanne opened this issue Apr 17, 2024 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug notebook-folding notebook-toc-outline

Comments

@DonJayamanne
Copy link
Contributor

The notebookOutlineEntryFactory.ts handles markdown headers with HTML tags, but not other parts (such as collapsing mardown header cells, see foldingModel.ts).

			const fullContent = cell.getText().substring(0, 10000);
			for (const { depth, text } of getMarkdownHeadersInCell(fullContent)) {
				hasHeader = true;
				entries.push(new OutlineEntry(index++, depth, cell, text, false, false));
			}

			if (!hasHeader) {
				// no markdown syntax headers, try to find html tags
				const match = fullContent.match(/<h([1-6]).*>(.*)<\/h\1>/i);
				if (match) {
					hasHeader = true;
					const level = parseInt(match[1]);
					const text = match[2].trim();
					entries.push(new OutlineEntry(index++, level, cell, text, false, false));
				}
			}

Thus, if we have HTML tags for outline headers, then we do not render collapsible regions in markdown for such headers.
Not sure if this is a bug or not, but filing this here,

Feel free to close this if this is invalid.

@Yoyokrazy Yoyokrazy added the bug Issue identified by VS Code Team member as probable bug label Apr 29, 2024
@Yoyokrazy
Copy link
Contributor

Good catch, I'll see about unifying that behavior. We should likely just support html tags in the folding model. Might've just been an oversight way back when this was written and didn't grab the updates with the outlineEntryFactory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug notebook-folding notebook-toc-outline
Projects
None yet
Development

No branches or pull requests

2 participants