<commit_before>require('./printPage.less');
const React = require('react');
const createClass = require('create-react-class');
const _     = require('lodash');
const cx    = require('classnames');
const { Meta } = require('vitreum/headtags');
const Markdown = require('naturalcrit/markdown.js');

const PrintPage = createClass({
	getDefaultProps : function() {
		return {
			query : {},
			brew  : {
				text : '',
			}
		};
	},

	getInitialState : function() {
		return {
			brewText : this.props.brew.text
		};
	},

	componentDidMount : function() {
		if(this.props.query.local){
			this.setState((prevState, prevProps)=>({
				brewText : localStorage.getItem(prevProps.query.local)
			}));
		}

		if(this.props.query.dialog) window.print();
	},

	renderPages : function(){
		return _.map(this.state.brewText.split('\\page'), (page, index)=>{
			return <div
				className='phb'
				id={`p${index + 1}`}
				dangerouslySetInnerHTML={{ __html: Markdown.render(page) }}
				key={index} />;
		});
	},

	render : function(){
		return <div>
			<Meta name='robots' content='noindex, nofollow' />
			{this.renderPages()}
		</div>;
	}
});

module.exports = PrintPage;<commit_msg>Apply Legacy\v3 renderer to print page (#1235)<commit_after>require('./printPage.less');
const React = require('react');
const createClass = require('create-react-class');
const _     = require('lodash');
const cx    = require('classnames');
const { Meta } = require('vitreum/headtags');
const MarkdownLegacy = require('naturalcrit/markdownLegacy.js');
const Markdown = require('naturalcrit/markdown.js');

const PrintPage = createClass({
	getDefaultProps : function() {
		return {
			query : {},
			brew  : {
				text     : '',
				renderer : 'legacy'
			}
		};
	},

	getInitialState : function() {
		return {
			brewText : this.props.brew.text
		};
	},

	componentDidMount : function() {
		if(this.props.query.local){
			this.setState((prevState, prevProps)=>({
				brewText : localStorage.getItem(prevProps.query.local)
			}));
		}

		if(this.props.query.dialog) window.print();
	},

	renderPages : function(){
		if(this.props.brew.renderer == 'legacy') {
			return _.map(this.state.brewText.split('\\page'), (page, index)=>{
				return <div
					className='phb'
					id={`p${index + 1}`}
					dangerouslySetInnerHTML={{ __html: MarkdownLegacy.render(page) }}
					key={index} />;
			});
		} else {
			return _.map(this.state.brewText.split(/^\\page/gm), (page, index)=>{
				return <div
					className='phb3'
					id={`p${index + 1}`}
					dangerouslySetInnerHTML={{ __html: Markdown.render(page) }}
					key={index} />;
			});
		}

	},

	render : function(){
		return <div>
			<Meta name='robots' content='noindex, nofollow' />
			{this.renderPages()}
		</div>;
	}
});

module.exports = PrintPage;
{'fraction_non_alphanumeric': 0.18529199711607786, 'fraction_numerical': 0.0032444124008651765, 'mean_word_length': 3.6638655462184873, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 17, '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': '968529', 'n_tokens_mistral': 1082, 'n_tokens_neox': 933, 'n_words': 162}