<commit_before>require 'jekyll/filters'

module CppSamples
	module SampleFilters
		include Jekyll::Filters

		def sample_description(sample)
			description = sample['description']

			description.gsub!(/\[(\d+)\]/) do |match|
				line_num = $1.to_i - sample['code_offset']
				"<span class=\"lineref\" data-line=\"#{line_num}\">line #{line_num}</span>"
			end

			description.gsub!(/\[(\d+)\-(\d+)\]/) do |match|
				line_num_start = $1.to_i - sample['code_offset']
				line_num_end = $2.to_i - sample['code_offset']
				"<span class=\"lineref\" data-line=\"#{line_num_start}\" data-line-end=\"#{line_num_end}\">lines #{line_num_start}-#{line_num_end}</span>"
			end

			description.gsub!(/\[(.+?)\]\((c(pp)?\/.+?)\)/) do |match|
				"<a href=\"http://en.cppreference.com/w/#{$2}\">#{$1}</a>"
			end

			markdownify(description)
		end

		def sample_excerpt(sample)
			description = sample['description']
			blank_line_index = /\n[\t ]*\n/ =~ description

			if blank_line_index
				return markdownify(description[0..blank_line_index])<commit_msg>Change hyphen in line range to n-dash<commit_after>require 'jekyll/filters'

module CppSamples
	module SampleFilters
		include Jekyll::Filters

		def sample_description(sample)
			description = sample['description']

			description.gsub!(/\[(\d+)\]/) do |match|
				line_num = $1.to_i - sample['code_offset']
				"<span class=\"lineref\" data-line=\"#{line_num}\">line #{line_num}</span>"
			end

			description.gsub!(/\[(\d+)\-(\d+)\]/) do |match|
				line_num_start = $1.to_i - sample['code_offset']
				line_num_end = $2.to_i - sample['code_offset']
				"<span class=\"lineref\" data-line=\"#{line_num_start}\" data-line-end=\"#{line_num_end}\">lines #{line_num_start}&ndash;#{line_num_end}</span>"
			end

			description.gsub!(/\[(.+?)\]\((c(pp)?\/.+?)\)/) do |match|
				"<a href=\"http://en.cppreference.com/w/#{$2}\">#{$1}</a>"
			end

			markdownify(description)
		end

		def sample_excerpt(sample)
			description = sample['description']
			blank_line_index = /\n[\t ]*\n/ =~ description

			if blank_line_index
				return markdownify(description[0..blank_line_index])
{'fraction_non_alphanumeric': 0.2111215834118756, 'fraction_numerical': 0.005655042412818096, 'mean_word_length': 3.948717948717949, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3682388', 'n_tokens_mistral': 883, 'n_tokens_neox': 768, 'n_words': 121}