<commit_before>import markdown
import os.path
import codecs
import string
import time
from functions import get_canonical, get_basename

# Configuration
time_formula = "%d %B %Y"

# Code Start

arguments = [
	{
		"name": "--md-template",
		"dest": "template_path",
		"method": "store",
		"help": "choose a different template (default 'template.htm')",
		"default": "template.htm"
	}
]

def generate(doc, config, args):
	out_file = os.path.join(args.output_path, get_basename(doc)) + ".htm"
	print("writing " + out_file)
	with codecs.open(args.template_path, mode="r", encoding="utf-8") as template_file:
		template = string.Template(template_file.read())
	ad_code = ""
	if doc["metadata"]["ads"][0] == "yes":
		ad_code = config["ad_code"]
	html_output = template.substitute(
		ad_code = ad_code,
		canonical = get_canonical(doc, config),
		description = doc["metadata"]["description"][0],
		head_title = doc["metadata"]["title"][0] + " &middot; " + config["website_name"],
		html_content = doc["content"],
		tags = get_tags(doc),
		title = doc["metadata"]["title"][0],
		update_time = time.strftime(time_formula, time.localtime(doc["mod_time"]))
	)
	with codecs.open(out_file, mode="w", encoding="utf-8") as f:
		f.write(html_output)
	return True

# Utility Functions

def get_tags(doc):
	if (doc["metadata"]["tags"] == ['']) or (get_basename(doc) == "index"):
		return ""
	tags = ["<p>Tagged as: "]
	for tag in sorted(doc["metadata"]["tags"]):
		tags.append("<a href=\"/tag/" + tag + "\">" + tag + "</a>")
	tags.append("</p>")
	return "\n".join(tags)
<commit_msg>Tags do not need their own paragraph.<commit_after>import markdown
import os.path
import codecs
import string
import time
from functions import get_canonical, get_basename

# Configuration
time_formula = "%d %B %Y"

# Code Start

arguments = [
	{
		"name": "--md-template",
		"dest": "template_path",
		"method": "store",
		"help": "choose a different template (default 'template.htm')",
		"default": "template.htm"
	}
]

def generate(doc, config, args):
	out_file = os.path.join(args.output_path, get_basename(doc)) + ".htm"
	print("writing " + out_file)
	with codecs.open(args.template_path, mode="r", encoding="utf-8") as template_file:
		template = string.Template(template_file.read())
	ad_code = ""
	if doc["metadata"]["ads"][0] == "yes":
		ad_code = config["ad_code"]
	html_output = template.substitute(
		ad_code = ad_code,
		canonical = get_canonical(doc, config),
		description = doc["metadata"]["description"][0],
		head_title = doc["metadata"]["title"][0] + " &middot; " + config["website_name"],
		html_content = doc["content"],
		tags = get_tags(doc),
		title = doc["metadata"]["title"][0],
		update_time = time.strftime(time_formula, time.localtime(doc["mod_time"]))
	)
	with codecs.open(out_file, mode="w", encoding="utf-8") as f:
		f.write(html_output)
	return True

# Utility Functions

def get_tags(doc):
	if (doc["metadata"]["tags"] == ['']) or (get_basename(doc) == "index"):
		return ""
	tags = ["Tagged as: "]
	for tag in sorted(doc["metadata"]["tags"]):
		tags.append("<a href=\"/tag/" + tag + "\">" + tag + "</a>")
	return "\n".join(tags)

{'fraction_non_alphanumeric': 0.1934143222506394, 'fraction_numerical': 0.0038363171355498722, 'mean_word_length': 5.208333333333333, 'pattern_counts': {'":': 12, '<': 9, '<?xml version=': 0, '>': 9, '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': '6367635', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1125, 'n_words': 241}