<commit_before>#!/usr/bin/perl -w

# convert plain ascii to Yacas manual code
# Syntax of ascii files is described in "txt2yacasdoc" essay
#
# Use with care, test output with manualmaker

$have_Text = 0;	# Means we have a Text() declared somewhere above
$have_par = 1;	# Means we already have a new paragraph
$in_text = 0;	# Means we are inside quotes of the Text()
$in_itemized = 0;
$in_enum = 0;
$in_htmlcommand = 0;

while (<STDIN>) {
	chomp;
	s/\\/\\\\/g;
	s/"/\\"/g;
	# First deal with TAB-indented lines
	if (not $in_htmlcommand and /^\t\t\t\t([^ ].*)$/) {	# Book
		&finish_text();
		print "\tBook()\"", &escape_term($1), "\";\n\n";
		$have_par = 1;
	} elsif (not $in_htmlcommand and /^\t\t\t([^ ].*)$/) {	# Chapter
		&finish_text();
		print "\tChapter()\"", &escape_term($1), "\";\n\n";
		$have_par = 1;
	} elsif (not $in_htmlcommand and /^\t\t([^ ].*)$/) {	# Section
		&finish_text();
		print "\tSection()\"", &escape_term($1), "\";\n\n";
		$have_par = 1;
	} elsif (not $in_htmlcommand and /^\t    ([^ ].*)$/) {	# Subsection
		&finish_text();
		print "\tSubSection()\"", &escape_term($1), "\";\n\n";
		$have_par = 1;
	} elsif ((not $in_htmlcommand and /^\t( {0,2}[^ \t].*)$/) or ($in_htmlcommand and /^\t(.*)$/)) {	# Sample code (HtmlCommand); cannot start with empty line
		&start_text();
		if (not $in_htmlcommand) {
			&close_quote();
			print ":HtmlCommand(\"\n";
			$in_htmlcommand = 1;
		}
		print "$1\n";
		$have_par = 0;
		$in_text = 1;
	}	# Now not TAB-indented lines
	elsif (/^\s*$/) {	# New paragraph
	if (0 == 1) {	# This is for debugging only: breaks HTML docs
		&finish_text();
		&start_text();
	}
		if (not $have_par) {
			&close_quote();
			&start_text();
			if ($in_itemized or $in_enum or $in_htmlcommand) {
				print ")\n";
				$in_itemized = $in_enum = $in_htmlcommand = 0;<commit_msg>a small change to support debugging output<commit_after>#!/usr/bin/perl -w

# convert plain ascii to Yacas manual code
# Syntax of ascii files is described in "txt2yacasdoc" essay
#
# Use with care, test output with manualmaker

$debug_pars = 0;	# This is for debugging only: breaks HTML docs, but it is useful because it makes all paragraphs into separate Text() invocations and then it's a lot easier to debug book2TeX or manualmaker in Yacas - just look at the resulting .tex or .book file to see where it stopped generating.

$have_Text = 0;	# Means we have a Text() declared somewhere above
$have_par = 1;	# Means we already have a new paragraph
$in_text = 0;	# Means we are inside quotes of the Text()
$in_itemized = 0;
$in_enum = 0;
$in_htmlcommand = 0;

while (<STDIN>) {
	chomp;
	s/\\/\\\\/g;
	s/"/\\"/g;
	# First deal with TAB-indented lines
	if (not $in_htmlcommand and /^\t\t\t\t([^ ].*)$/) {	# Book
		&finish_text();
		print "\tBook()\"", &escape_term($1), "\";\n\n";
		$have_par = 1;
	} elsif (not $in_htmlcommand and /^\t\t\t([^ ].*)$/) {	# Chapter
		&finish_text();
		print "\tChapter()\"", &escape_term($1), "\";\n\n";
		$have_par = 1;
	} elsif (not $in_htmlcommand and /^\t\t([^ ].*)$/) {	# Section
		&finish_text();
		print "\tSection()\"", &escape_term($1), "\";\n\n";
		$have_par = 1;
	} elsif (not $in_htmlcommand and /^\t    ([^ ].*)$/) {	# Subsection
		&finish_text();
		print "\tSubSection()\"", &escape_term($1), "\";\n\n";
		$have_par = 1;
	} elsif ((not $in_htmlcommand and /^\t( {0,2}[^ \t].*)$/) or ($in_htmlcommand and /^\t(.*)$/)) {	# Sample code (HtmlCommand); cannot start with empty line
		&start_text();
		if (not $in_htmlcommand) {
			&close_quote();
			print ":HtmlCommand(\"\n";
			$in_htmlcommand = 1;
		}
		print "$1\n";
		$have_par = 0;
		$in_text = 1;
	}	# Now not TAB-indented lines
	elsif (/^\s*$/) {	# New paragraph
	if ($debug_pars) {
		&finish_text();
		&start_text();
	}
		if (not $have_par) {
			&close_quote();
			&start_text();
			if ($in_itemized or $in_enum or $in_htmlcommand) {
				print ")\n";
				$in_itemized = $in_enum = $in_htmlcommand = 0;
{'fraction_non_alphanumeric': 0.2013285641287685, 'fraction_numerical': 0.012263668880940215, 'mean_word_length': 3.433748584371461, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '6503852', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1548, 'n_words': 437}