<commit_before>
var tape = require('tape')

var markdown = require('../')

tape('toUrl behaves with markdown link', function (t) {

  var LINK = '%qcdW859vSp/bQCA8qiPsirrCrjlIUHeq80QRjhCKYvU=.sha256'
  t.equal(
    markdown.block(
      '[link](' + LINK +')',
      {toUrl: function (url) {
        t.equal(url, LINK)
        return '/thread?id='+LINK
      }}
    ),
    '<p><a href="/thread?id='+LINK+'" target="_blank">link</a></p>\n'
  )
  t.end()


})

tape('toUrl behaves with raw link', function (t) {

  var LINK = '%qcdW859vSp/bQCA8qiPsirrCrjlIUHeq80QRjhCKYvU=.sha256'
  t.equal(
    markdown.block(
      'hello: ' + LINK,
      {toUrl: function (url) {
        t.equal(url, LINK)
        return '/thread?id='+LINK
      }}
    ).trim(),
    '<p>hello: <a href="/thread?id='+LINK+'" target="_blank">'+LINK.substring(0, 6)+'...</a></p>'
  )
  t.end()

})

tape('toUrl falls back if return false', function (t) {

  var LINK = 'http://example.com'
  t.equal(
    markdown.block(
      'hello: ' + LINK,
      {toUrl: function (url) {
        t.equal(url, LINK)
        return false
      }}
    ).trim(),
    '<p>hello: <a href="http://example.com" target="_blank">http://example.com</a></p>'.trim()
  )
  t.end()

})
<commit_msg>use t.plan(2) because toUrl was being called twice!<commit_after>
var tape = require('tape')

var markdown = require('../')

tape('toUrl behaves with markdown link', function (t) {

  var LINK = '%qcdW859vSp/bQCA8qiPsirrCrjlIUHeq80QRjhCKYvU=.sha256'
  t.equal(
    markdown.block(
      '[link](' + LINK +')',
      {toUrl: function (url) {
        t.equal(url, LINK)
        return '/thread?id='+LINK
      }}
    ),
    '<p><a href="/thread?id='+LINK+'" target="_blank">link</a></p>\n'
  )
  t.end()


})

tape('toUrl behaves with raw link', function (t) {
  t.plan(2)
  var LINK = '%qcdW859vSp/bQCA8qiPsirrCrjlIUHeq80QRjhCKYvU=.sha256'
  t.equal(
    markdown.block(
      'hello: ' + LINK,
      {toUrl: function (url) {
        t.equal(url, LINK)
        return '/thread?id='+LINK
      }}
    ).trim(),
    '<p>hello: <a href="/thread?id='+LINK+'" target="_blank">'+LINK.substring(0, 6)+'...</a></p>'
  )
  t.end()

})

tape('toUrl falls back if return false', function (t) {

  var LINK = 'http://example.com'
  t.equal(
    markdown.block(
      'hello: ' + LINK,
      {toUrl: function (url) {
        t.equal(url, LINK)
        return false
      }}
    ).trim(),
    '<p>hello: <a href="http://example.com" target="_blank">http://example.com</a></p>'.trim()
  )
  t.end()

})

{'fraction_non_alphanumeric': 0.2079207920792079, 'fraction_numerical': 0.016633663366336635, 'mean_word_length': 2.7147058823529413, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '2588375', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1004, 'n_words': 184}