<commit_before>#!/usr/bin/env python

from . import parse_link
from docutils import nodes
from docutils.parsers import rst

def gh_internal(account, ref, title, link):
    base_url = "https://github.com/{}/{}/{}/{}"
    if '#' in ref:
        project, _, issue = ref.partition('#')
        url = base_url.format(account, project, "issues", issue)
        if not title: title = link
    elif '@' in ref:
        project, _, commit = ref.partition('@')
        url = base_url.format(account, project, "commit", commit)
        if not title: title = account + "/" + project + "@" + commit[0:7]
    elif '$' in ref:
        project, _, branch = ref.partition('$')
        url = base_url.format(account, project, "tree", branch)
        if not title: title = url
    elif '^' in ref:
        project, _, branch = ref.partition('^')
        url = base_url.format(account, project, "releases/tag", branch)
        if not title: title = url
    else:
        url = "https://github.com/{}/{}".format(account, ref)
        if not title: title = url

    return title, url

def gh(name, rawtext, text, lineno, inliner, options={}, content=[]):
    title, link = parse_link(text)
    account, _, ref = link.partition('/')
    if not ref:
        url = "https://github.com/{}".format(account)
        if not title: title = "@{}".format(account)<commit_msg>m.gh: repository link title doesn't need to be a full URL.<commit_after>#!/usr/bin/env python

from . import parse_link
from docutils import nodes
from docutils.parsers import rst

def gh_internal(account, ref, title, link):
    base_url = "https://github.com/{}/{}/{}/{}"
    if '#' in ref:
        project, _, issue = ref.partition('#')
        url = base_url.format(account, project, "issues", issue)
        if not title: title = link
    elif '@' in ref:
        project, _, commit = ref.partition('@')
        url = base_url.format(account, project, "commit", commit)
        if not title: title = account + "/" + project + "@" + commit[0:7]
    elif '$' in ref:
        project, _, branch = ref.partition('$')
        url = base_url.format(account, project, "tree", branch)
        if not title: title = url
    elif '^' in ref:
        project, _, branch = ref.partition('^')
        url = base_url.format(account, project, "releases/tag", branch)
        if not title: title = url
    else:
        url = "https://github.com/{}/{}".format(account, ref)
        if not title:
            # if simple profile link, no need to expand to full URL
            title = link if not '/' in ref else url

    return title, url

def gh(name, rawtext, text, lineno, inliner, options={}, content=[]):
    title, link = parse_link(text)
    account, _, ref = link.partition('/')
    if not ref:
        url = "https://github.com/{}".format(account)
        if not title: title = "@{}".format(account)
{'fraction_non_alphanumeric': 0.1567453328636844, 'fraction_numerical': 0.0014089468122578373, 'mean_word_length': 2.6178343949044587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, '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': '5653730', 'n_tokens_mistral': 885, 'n_tokens_neox': 866, 'n_words': 270}