<commit_before>// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import expect = require('expect.js');

import {
  JSONObject, JSONValue
} from '@phosphor/coreutils';

import {
  Widget
} from '@phosphor/widgets';

import {
  defaultSanitizer
} from '../../../lib/apputils';

import {
  LatexRenderer, PDFRenderer, JavaScriptRenderer,
  SVGRenderer, MarkdownRenderer, TextRenderer, HTMLRenderer, ImageRenderer
} from '../../../lib/renderers';

import {
  MimeModel, RenderMime
} from '../../../lib/rendermime';


const EXPECTED_MD = `<h1 id="Title-first-level">Title first level<a class="jp-InternalAnchorLink" href="#Title-first-level" target="_self">¶</a></h1>\n<h2 id="Title-second-Level">Title second Level<a class="jp-InternalAnchorLink" href="#Title-second-Level" target="_self">¶</a></h2>\n<h3 id="Title-third-level">Title third level<a class="jp-InternalAnchorLink" href="#Title-third-level" target="_self">¶</a></h3>\n<h4 id="Title-fourth-level">Title fourth level<a class="jp-InternalAnchorLink" href="#Title-fourth-level" target="_self">¶</a></h4>\n<h5 id="Title-fifth-level">Title fith level<a class="jp-InternalAnchorLink" href="#Title-fifth-level" target="_self">¶</a></h5>\n<h6 id="Title-sixth-level">Title sixth level<a class="jp-InternalAnchorLink" href="#Title-sixth-level" target="_self">¶</a></h6>\n<h1 id="h1">h1<a class="jp-InternalAnchorLink" href="#h1" target="_self">¶</a></h1>\n<h2 id="h2">h2<a class="jp-InternalAnchorLink" href="#h2" target="_self">¶</a></h2>\n<h3 id="h3">h3<a class="jp-InternalAnchorLink" href="#h3" target="_self">¶</a></h3>\n<h4 id="h4">h4<a class="jp-InternalAnchorLink" href="#h4" target="_self">¶</a></h4>\n<h5 id="h6">h6<a class="jp-InternalAnchorLink" href="#h6" target="_self">¶</a></h5>\n<p>This is just a sample paragraph\nYou can look at different level of nested unorderd list ljbakjn arsvlasc asc asc awsc asc ascd ascd ascd asdc asc</p>\n<ul>\n<li>level 1<ul>\n<li>level 2</li>\n<li>level 2</li>\n<li>level 2<ul>\n<li>level 3</li>\n<li>level 3<ul>\n<li>level 4<ul>\n<li>level 5<ul>\n<li>level 6</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n</li>\n<li>level 2</li>\n</ul>\n</li>\n<li>level 1</li>\n<li>level 1</li>\n<li>level 1\nOrdered list</li>\n<li>level 1<ol>\n<li>level 1</li>\n<li>level 1<ol>\n<li>level 1</li>\n<li>level 1</li>\n<li>level 1<ol>\n<li>level 1</li>\n<li>level 1<ol>\n<li>level 1</li>\n<li>level 1</li>\n<li>level 1</li>\n</ol>\n</li>\n</ol>\n</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>level 1</li>\n<li>level 1\nsome Horizontal line</li>\n</ul>\n<hr>\n<h2>and another one</h2>\n<p>Colons can be used to align columns.</p>\n<table>\n<thead>\n<tr>\n<th>Tables</th>\n<th>Are</th>\n<th>Cool</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>col 3 is</td>\n<td>right-aligned</td>\n<td>1600</td>\n</tr>\n<tr>\n<td>col 2 is</td>\n<td>centered</td>\n<td>12</td>\n</tr>\n<tr>\n<td>zebra stripes</td>\n<td>are neat</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>\n<p>There must be at least 3 dashes separating each header cell.\nThe outer pipes (|) are optional, and you don\'t need to make the\nraw Markdown line up prettily. You can also use inline Markdown.</p>\n`;


function runCanRunder(renderer: RenderMime.IRenderer, trusted: boolean): boolean {
  let canRender = true;
  let data: JSONObject = Object.create(null);
  for (let mimeType in renderer.mimeTypes) {
    data[mimeType] = 'test';
  }
  data['fizz/buzz'] = 'test';
  let model = new MimeModel({ data, trusted });

  for (let mimeType of renderer.mimeTypes) {
    let options = { model, mimeType, sanitizer };
    if (!renderer.canRender(options)) {
      canRender = false;
    }
  }
  let options = { model, mimeType: 'fizz/buzz', sanitizer };
  expect(renderer.canRender(options)).to.be(false);
  return canRender;
}


function createModel(mimeType: string, source: JSONValue, trusted=false): RenderMime.IMimeModel {
  let data: JSONObject = {};<commit_msg>Correct order of attributes<commit_after>// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import expect = require('expect.js');

import {
  JSONObject, JSONValue
} from '@phosphor/coreutils';

import {
  Widget
} from '@phosphor/widgets';

import {
  defaultSanitizer
} from '../../../lib/apputils';

import {
  LatexRenderer, PDFRenderer, JavaScriptRenderer,
  SVGRenderer, MarkdownRenderer, TextRenderer, HTMLRenderer, ImageRenderer
} from '../../../lib/renderers';

import {
  MimeModel, RenderMime
} from '../../../lib/rendermime';


const EXPECTED_MD = `<h1 id="Title-first-level">Title first level<a target="_self" class="jp-InternalAnchorLink" href="#Title-first-level">¶</a></h1>\n<h2 id="Title-second-Level">Title second Level<a target="_self" class="jp-InternalAnchorLink" href="#Title-second-Level">¶</a></h2>\n<h3 id="Title-third-level">Title third level<a target="_self" class="jp-InternalAnchorLink" href="#Title-third-level">¶</a></h3>\n<h4 id="Title-fourth-level">Title fourth level<a target="_self" class="jp-InternalAnchorLink" href="#Title-fourth-level">¶</a></h4>\n<h5 id="Title-fifth-level">Title fith level<a target="_self" class="jp-InternalAnchorLink" href="#Title-fifth-level">¶</a></h5>\n<h6 id="Title-sixth-level">Title sixth level<a target="_self" class="jp-InternalAnchorLink" href="#Title-sixth-level">¶</a></h6>\n<h1 id="h1">h1<a target="_self" class="jp-InternalAnchorLink" href="#h1">¶</a></h1>\n<h2 id="h2">h2<a target="_self" class="jp-InternalAnchorLink" href="#h2">¶</a></h2>\n<h3 id="h3">h3<a target="_self" class="jp-InternalAnchorLink" href="#h3">¶</a></h3>\n<h4 id="h4">h4<a target="_self" class="jp-InternalAnchorLink" href="#h4">¶</a></h4>\n<h5 id="h6">h6<a target="_self" class="jp-InternalAnchorLink" href="#h6">¶</a></h5>\n<p>This is just a sample paragraph\nYou can look at different level of nested unorderd list ljbakjn arsvlasc asc asc awsc asc ascd ascd ascd asdc asc</p>\n<ul>\n<li>level 1<ul>\n<li>level 2</li>\n<li>level 2</li>\n<li>level 2<ul>\n<li>level 3</li>\n<li>level 3<ul>\n<li>level 4<ul>\n<li>level 5<ul>\n<li>level 6</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n</li>\n<li>level 2</li>\n</ul>\n</li>\n<li>level 1</li>\n<li>level 1</li>\n<li>level 1\nOrdered list</li>\n<li>level 1<ol>\n<li>level 1</li>\n<li>level 1<ol>\n<li>level 1</li>\n<li>level 1</li>\n<li>level 1<ol>\n<li>level 1</li>\n<li>level 1<ol>\n<li>level 1</li>\n<li>level 1</li>\n<li>level 1</li>\n</ol>\n</li>\n</ol>\n</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>level 1</li>\n<li>level 1\nsome Horizontal line</li>\n</ul>\n<hr>\n<h2>and another one</h2>\n<p>Colons can be used to align columns.</p>\n<table>\n<thead>\n<tr>\n<th>Tables</th>\n<th>Are</th>\n<th>Cool</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>col 3 is</td>\n<td>right-aligned</td>\n<td>1600</td>\n</tr>\n<tr>\n<td>col 2 is</td>\n<td>centered</td>\n<td>12</td>\n</tr>\n<tr>\n<td>zebra stripes</td>\n<td>are neat</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>\n<p>There must be at least 3 dashes separating each header cell.\nThe outer pipes (|) are optional, and you don\'t need to make the\nraw Markdown line up prettily. You can also use inline Markdown.</p>\n`;


function runCanRunder(renderer: RenderMime.IRenderer, trusted: boolean): boolean {
  let canRender = true;
  let data: JSONObject = Object.create(null);
  for (let mimeType in renderer.mimeTypes) {
    data[mimeType] = 'test';
  }
  data['fizz/buzz'] = 'test';
  let model = new MimeModel({ data, trusted });

  for (let mimeType of renderer.mimeTypes) {
    let options = { model, mimeType, sanitizer };
    if (!renderer.canRender(options)) {
      canRender = false;
    }
  }
  let options = { model, mimeType: 'fizz/buzz', sanitizer };
  expect(renderer.canRender(options)).to.be(false);
  return canRender;
}


function createModel(mimeType: string, source: JSONValue, trusted=false): RenderMime.IMimeModel {
  let data: JSONObject = {};
{'fraction_non_alphanumeric': 0.22545546558704455, 'fraction_numerical': 0.018977732793522266, 'mean_word_length': 5.166146645865835, 'pattern_counts': {'":': 0, '<': 329, '<?xml version=': 0, '>': 329, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2254712', 'n_tokens_mistral': 3149, 'n_tokens_neox': 3017, 'n_words': 535}