<commit_before>var fs = require('fs');
var path = require('path');
var assert = require('assert');

var page = require('../').parse.page;


var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/PAGE.md'), 'utf8');
var LEXED = page(CONTENT);

var HR_CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/HR_PAGE.md'), 'utf8');
var HR_LEXED = page(HR_CONTENT);

describe('Page parsing', function() {
    it('should detection sections', function() {
        assert.equal(LEXED.length, 3);
    });

    it('should detection section types', function() {
        assert.equal(LEXED[0].type, 'normal');
        assert.equal(LEXED[1].type, 'exercise');
        assert.equal(LEXED[2].type, 'normal');
    });

    it('should gen content for normal sections', function() {
        assert(LEXED[0].content);
        assert(LEXED[2].content);
    });

    it('should gen code and content for exercise sections', function() {
        assert(LEXED[1].content);
        assert(LEXED[1].code);
        assert(LEXED[1].code.base);
        assert(LEXED[1].code.solution);
        assert(LEXED[1].code.validation);
    });

    it('should merge sections correctly', function() {
        // One big section
        assert.equal(HR_LEXED.length, 1);

        // HRs inserted correctly
        assert.equal(HR_LEXED[0].content.match(/<hr>/g).length, 2);
    });
});<commit_msg>Add github link resolution test<commit_after>var fs = require('fs');
var path = require('path');
var assert = require('assert');

var page = require('../').parse.page;


var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/PAGE.md'), 'utf8');
var LEXED = page(CONTENT);

var HR_CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/HR_PAGE.md'), 'utf8');
var HR_LEXED = page(HR_CONTENT);

var LINKS_CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/GITHUB_LINKS.md'), 'utf8');


describe('Page parsing', function() {
    it('should detection sections', function() {
        assert.equal(LEXED.length, 3);
    });

    it('should detection section types', function() {
        assert.equal(LEXED[0].type, 'normal');
        assert.equal(LEXED[1].type, 'exercise');
        assert.equal(LEXED[2].type, 'normal');
    });

    it('should gen content for normal sections', function() {
        assert(LEXED[0].content);
        assert(LEXED[2].content);
    });

    it('should gen code and content for exercise sections', function() {
        assert(LEXED[1].content);
        assert(LEXED[1].code);
        assert(LEXED[1].code.base);
        assert(LEXED[1].code.solution);
        assert(LEXED[1].code.validation);
    });

    it('should merge sections correctly', function() {
        // One big section
        assert.equal(HR_LEXED.length, 1);

        // HRs inserted correctly
        assert.equal(HR_LEXED[0].content.match(/<hr>/g).length, 2);
    });
});


describe('Relative links', function() {
    it('should be resolved to their GitHub counterparts', function() {
        var LEXED = page(LINKS_CONTENT, {
            // GitHub repo ID
            repo: 'GitBookIO/javascript',

            // Imaginary folder of markdown file
            dir: 'course',
        });

        assert(LEXED[0].content.indexOf('https://github.com/GitBookIO/javascript/blob/src/something.cpp') !== -1);
    });
});
{'fraction_non_alphanumeric': 0.1724765080327372, 'fraction_numerical': 0.010609275538041831, 'mean_word_length': 3.094292803970223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '4064812', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1009, 'n_words': 209}