Skip to content

getMarkdownHeadersInCell does not handle headers with HTML tags #210520

@DonJayamanne

Description

@DonJayamanne

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions