<commit_before>import React from 'react';

import 'style!css!highlight.js/styles/github.css';

function addLineNumbers(el) {
	// console.log("adding line-numbers to", el);
	el.parentNode.classList.add("line-numbers");
	
	const lines = el.textContent.split("\n").length - 1;
	// console.log("found", lines, "lines");
	
	const linesRow = document.createElement("span");
	linesRow.classList.add("line-numbers__row");
	
	for (let i = 0; i < lines; ++i) {
		linesRow.appendChild(document.createElement("span"));
	}
	
	
	el.appendChild(linesRow);
}

class Marked extends React.Component {
	componentDidMount() {
		for (let el of this.marked.querySelectorAll("[class*=language-]")) {
			addLineNumbers(el);
		}
	}
	
	render() {
		return (
			<div className="markdown" dangerouslySetInnerHTML={{__html: this.props.mark}} ref={c => this.marked = c}/><commit_msg>fix(line-numbers): Fix line-numbers not being added on Marked component update<commit_after>import React from 'react';

import 'style!css!highlight.js/styles/github.css';

function addLineNumbers(el) {
	el.parentNode.classList.add("line-numbers");
	
	const lines = el.textContent.split("\n").length - 1;
	
	const linesRow = document.createElement("span");
	linesRow.classList.add("line-numbers__row");
	
	for (let i = 0; i < lines; ++i) {
		linesRow.appendChild(document.createElement("span"));
	}
	
	
	el.appendChild(linesRow);
}

class Marked extends React.Component {
	markCodeBlocks = () => {
		for (let el of this.marked.querySelectorAll("[class*=language-]")) {
			addLineNumbers(el);
		}
	}
	
	componentDidMount() {
		this.markCodeBlocks();
	}
	
	componentDidUpdate() {
		this.markCodeBlocks();
	}
	
	render() {
		return (
			<div className="markdown" dangerouslySetInnerHTML={{__html: this.props.mark}} ref={c => this.marked = c}/>
{'fraction_non_alphanumeric': 0.16629464285714285, 'fraction_numerical': 0.002232142857142857, 'mean_word_length': 4.692063492063492, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '3710749', 'n_tokens_mistral': 636, 'n_tokens_neox': 577, 'n_words': 111}