<commit_before># This script was used to output the markdown for a table of contents for
# a manual for a github project I was looking at. Nothing exciting.

require 'net/http'
require 'nokogiri'
require 'open-uri'

def main
  source_html = open('https://github.com/louismullie/treat/wiki/Manual')
  n = Nokogiri::HTML(source_html.read)
  anchor_tags = n.css('div#wiki-content a.anchor')
  index = build_index_for_anchor_tags(anchor_tags)
end

def build_index_for_anchor_tags(anchor_tags)
  index = ''
  anchor_tags.each { |anchor_tag| index = index + make_li(anchor_tag) }
  puts index
end

def make_li(anchor)

  # Hacked because lack of uniformity in wiki styles
  li = anchor.parent.name == 'h3' ? ' '*4 : ''

  #NOTE: I added 'Manual' because of this issue:
  #          https://github.com/gollum/gollum/issues/666
  #      Prepending the page shouldn't be necessary.
  li = li + %(* [#{anchor.parent.text.strip}](Manual#{anchor.get_attribute('href')})\n)
end
<commit_msg>Made a minor tweak to table_of_contents_maker.rb<commit_after># This script was used to output the markdown for a table of contents for
# a manual for a github project I was looking at. Nothing exciting.

require 'net/http'
require 'nokogiri'
require 'open-uri'

def main
  source_html = open('https://github.com/louismullie/treat/wiki/Manual')
  n = Nokogiri::HTML(source_html.read)
  anchor_tags = n.css('div#wiki-content a.anchor')
  index = build_index_for_anchor_tags(anchor_tags)
  puts index
end

def build_index_for_anchor_tags(anchor_tags)
  index = ''
  anchor_tags.each { |anchor_tag| index = index + make_li(anchor_tag) }
  return index
end

def make_li(anchor)

  # Hacked because lack of uniformity in wiki styles
  li = anchor.parent.name == 'h3' ? ' '*4 : ''

  #NOTE: I added 'Manual' because of this issue:
  #          https://github.com/gollum/gollum/issues/666
  #      Prepending the page shouldn't be necessary.
  li = li + %(* [#{anchor.parent.text.strip}](Manual#{anchor.get_attribute('href')})\n)
end

{'fraction_non_alphanumeric': 0.11926147704590818, 'fraction_numerical': 0.00499001996007984, 'mean_word_length': 4.154241645244216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '2103609', 'n_tokens_mistral': 704, 'n_tokens_neox': 685, 'n_words': 185}