<commit_before>var React = require("react");
var {Type, Node, packed} = require("./base");
var {View} = require("./workbench");


function VTOC({toc}) {
	return new View("toc", function renderTOC() {
		return toc.render();
	});
}

class TOC {
	constructor() {
		this._children = [];
	}
	add(fragment, heading, child) {
		this._children.push({fragment, heading, child});
	}
	get children() {
		return this._children;
	}
	render() {
		var children = this._children;
		return children.length === 0 ? undefined : <ul>{[
			for ({fragment, heading, child} of children) <li>
				<div>
					<a href={"#"+fragment}>{heading}</a>
					{child.render()}
				</div>
			</li>
		]}</ul>;
	}
}

function CTOCEntry(name, headingFn, type) {
	return new Type("tocEntry", function makeTOCEntry(ctx) {
		var fragment = ctx.path.ext(name).toString();
		var subTOC = new TOC();
		var node = type.makeNode({...ctx, toc: subTOC});
		ctx.toc.add(fragment, headingFn(node, ctx), subTOC);
		return new TOCNode({fragment, node});
	});
}

class TOCNode extends Node {
	renderHB() {
		var {fragment, node} = this.__options
		var rendered = {...node.renderHB()};
		var {head, body} = rendered;
		if (head != undefined)
			head = <a id={fragment}>{head}</a>;
		else
			body = <div><a id={fragment}></a>{body}</div>;
		return {head, body};
	}
}
<commit_msg>Don't wrap TOC-target <a> elements around other elements to avoid interference with react-bootstrap.<commit_after>var React = require("react");
var {Type, Node, packed} = require("./base");
var {View} = require("./workbench");


function VTOC({toc}) {
	return new View("toc", function renderTOC() {
		return toc.render();
	});
}

class TOC {
	constructor() {
		this._children = [];
	}
	add(fragment, heading, child) {
		this._children.push({fragment, heading, child});
	}
	get children() {
		return this._children;
	}
	render() {
		var children = this._children;
		return children.length === 0 ? undefined : <ul>{[
			for ({fragment, heading, child} of children) <li>
				<div>
					<a href={"#"+fragment}>{heading}</a>
					{child.render()}
				</div>
			</li>
		]}</ul>;
	}
}

function CTOCEntry(name, headingFn, type) {
	return new Type("tocEntry", function makeTOCEntry(ctx) {
		var fragment = ctx.path.ext(name).toString();
		var subTOC = new TOC();
		var node = type.makeNode({...ctx, toc: subTOC});
		ctx.toc.add(fragment, headingFn(node, ctx), subTOC);
		return new TOCNode({fragment, node});
	});
}

class TOCNode extends Node {
	renderHB() {
		var {fragment, node} = this.__options
		var rendered = {...node.renderHB()};
		var {head, body} = rendered;
		if (head != undefined)
			head = <span><a id={fragment}></a>{head}</span>;
		else
			body = <div><a id={fragment}></a>{body}</div>;
		return {head, body};
	}
}

{'fraction_non_alphanumeric': 0.19395924308588064, 'fraction_numerical': 0.000727802037845706, 'mean_word_length': 3.882770870337478, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4168608', 'n_tokens_mistral': 1054, 'n_tokens_neox': 954, 'n_words': 242}