mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Use ES6 in lib files.
This commit is contained in:
@@ -1,41 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash'),
|
||||
fs = require('fs'),
|
||||
marky = require('marky-markdown'),
|
||||
path = require('path'),
|
||||
util = require('../common/util');
|
||||
const _ = require('lodash');
|
||||
const fs = require('fs');
|
||||
const marky = require('marky-markdown');
|
||||
const path = require('path');
|
||||
const util = require('../common/util');
|
||||
|
||||
var basePath = path.join(__dirname, '..', '..'),
|
||||
docPath = path.join(basePath, 'doc'),
|
||||
readmePath = path.join(docPath, 'README.md');
|
||||
const basePath = path.join(__dirname, '..', '..');
|
||||
const docPath = path.join(basePath, 'doc');
|
||||
const readmePath = path.join(docPath, 'README.md');
|
||||
|
||||
const highlights = [
|
||||
'comment',
|
||||
'constant',
|
||||
'delimiter',
|
||||
'html',
|
||||
'js',
|
||||
'method',
|
||||
'modifier',
|
||||
'numeric',
|
||||
'shell',
|
||||
'source',
|
||||
'string',
|
||||
'text',
|
||||
'type'
|
||||
];
|
||||
|
||||
function build(type) {
|
||||
var markdown = fs
|
||||
const markdown = fs
|
||||
// Load markdown.
|
||||
.readFileSync(readmePath, 'utf8')
|
||||
// Uncomment docdown HTML hints.
|
||||
.replace(/(<)!--\s*|\s*--(>)/g, '$1$2');
|
||||
|
||||
var $ = marky(markdown, { 'sanitize': false }),
|
||||
$header = $('h1').first().remove(),
|
||||
version = _.trim($header.find('span').first().text()).slice(1);
|
||||
|
||||
var highlights = [
|
||||
'comment',
|
||||
'constant',
|
||||
'delimiter',
|
||||
'html',
|
||||
'js',
|
||||
'method',
|
||||
'modifier',
|
||||
'numeric',
|
||||
'shell',
|
||||
'source',
|
||||
'string',
|
||||
'text',
|
||||
'type'
|
||||
];
|
||||
const $ = marky(markdown, { 'sanitize': false });
|
||||
const $header = $('h1').first().remove();
|
||||
const version = _.trim($header.find('span').first().text()).slice(1);
|
||||
|
||||
// Remove docdown horizontal rules.
|
||||
$('hr').remove();
|
||||
@@ -46,7 +46,7 @@ function build(type) {
|
||||
.attr('id', null);
|
||||
|
||||
$(':header:not(h3) > a').each(function() {
|
||||
var $a = $(this);
|
||||
const $a = $(this);
|
||||
$a.replaceWith($a.html());
|
||||
});
|
||||
|
||||
@@ -54,8 +54,8 @@ function build(type) {
|
||||
$('p:empty + h3').prev().remove();
|
||||
|
||||
$('h3 ~ p:empty').each(function() {
|
||||
var $p = $(this),
|
||||
node = this.previousSibling;
|
||||
const $p = $(this);
|
||||
let node = this.previousSibling;
|
||||
|
||||
while ((node = node.previousSibling) && node.name != 'h3' && node.name != 'p') {
|
||||
$p.prepend(node.nextSibling);
|
||||
@@ -63,19 +63,19 @@ function build(type) {
|
||||
});
|
||||
|
||||
$('h3 code em').parent().each(function() {
|
||||
var $code = $(this);
|
||||
const $code = $(this);
|
||||
$code.html($code.html().replace(/<\/?em>/g, '_'));
|
||||
});
|
||||
|
||||
// Cleanup highlights class names.
|
||||
$('.highlight [class]').each(function() {
|
||||
var $el = $(this),
|
||||
className = _.intersection($el.attr('class').split(/\s+/), highlights).join(' ');
|
||||
const $el = $(this);
|
||||
const className = _.intersection($el.attr('class').split(/\s+/), highlights).join(' ');
|
||||
|
||||
$el.attr('class', className || null);
|
||||
});
|
||||
|
||||
var html = [
|
||||
const html = [
|
||||
// Append YAML front matter.
|
||||
'---',
|
||||
'id: docs',
|
||||
|
||||
Reference in New Issue
Block a user