Skip to content

Commit

Permalink
lint: reduce empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
puzrin committed Dec 2, 2023
1 parent 3c66f25 commit 8b815a6
Show file tree
Hide file tree
Showing 44 changed files with 0 additions and 195 deletions.
2 changes: 0 additions & 2 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ rules:
camelcase: 0
key-spacing: 0
no-multi-spaces: 0
no-multiple-empty-lines: 0
padded-blocks: 0
2 changes: 0 additions & 2 deletions benchmark/benchmark.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ fs.readdirSync(new URL('./samples', import.meta.url)).sort().forEach(sample => {
SAMPLES.push({ name: sample.split('.')[0], title, content, suite })
})


function select (patterns) {
const result = []

Expand All @@ -78,7 +77,6 @@ function select (patterns) {
return result
}


function run (files) {
const selected = select(files)

Expand Down
4 changes: 0 additions & 4 deletions bin/markdown-it.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import fs from 'node:fs'
import argparse from 'argparse'
import markdownit from '../index.mjs'


const cli = new argparse.ArgumentParser({
prog: 'markdown-it',
add_help: true
Expand Down Expand Up @@ -49,7 +48,6 @@ cli.add_argument('-o', '--output', {

const options = cli.parse_args()


function readFile (filename, encoding, callback) {
if (options.file === '-') {
// read from stdin
Expand All @@ -65,7 +63,6 @@ function readFile (filename, encoding, callback) {
}
}


readFile(options.file, 'utf8', function (err, input) {
let output

Expand All @@ -92,7 +89,6 @@ readFile(options.file, 'utf8', function (err, input) {

try {
output = md.render(input)

} catch (e) {
console.error(
(options.trace && e.stack) ||
Expand Down
9 changes: 0 additions & 9 deletions lib/common/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function arrayReplaceAt (src, pos, newElements) {
return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1))
}


function isValidEntityCode (c) {
/* eslint no-bitwise:0 */
// broken sequence
Expand Down Expand Up @@ -71,14 +70,12 @@ function fromCodePoint (c) {
return String.fromCharCode(c)
}


const UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g
const ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi
const UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi')

const DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i


function replaceEntityPattern (match, name) {
if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
const code = name[1].toLowerCase() === 'x'
Expand Down Expand Up @@ -120,7 +117,6 @@ function unescapeAll (str) {
})
}


const HTML_ESCAPE_TEST_RE = /[&<>"]/
const HTML_ESCAPE_REPLACE_RE = /[&<>"]/g
const HTML_REPLACEMENTS = {
Expand All @@ -141,14 +137,12 @@ function escapeHtml (str) {
return str
}


const REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g

function escapeRE (str) {
return str.replace(REGEXP_ESCAPE_RE, '\\$&')
}


function isSpace (code) {
switch (code) {
case 0x09:
Expand Down Expand Up @@ -178,15 +172,13 @@ function isWhiteSpace (code) {
return false
}


/* eslint-disable max-len */

// Currently without astral characters support.
function isPunctChar (ch) {
return ucmicro.P.test(ch)
}


// Markdown ASCII punctuation characters.
//
// !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
Expand Down Expand Up @@ -286,7 +278,6 @@ function normalizeReference (str) {
return str.toLowerCase().toUpperCase()
}


// Re-export libraries commonly used in both markdown-it and its plugins,
// so plugins won't have to depend on them explicitly, which reduces their
// bundled size (e.g. a browser build).
Expand Down
1 change: 0 additions & 1 deletion lib/helpers/parse_link_title.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { unescapeAll } from '../common/utils.mjs'


export default function parseLinkTitle (str, start, max) {
let code, marker
let lines = 0
Expand Down
15 changes: 0 additions & 15 deletions lib/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const config = {
commonmark: cfg_commonmark
}


//
// This validator can prohibit more than really needed to prevent XSS. It's a
// tradeoff to keep code simple and to be secure by default.
Expand All @@ -39,7 +38,6 @@ function validateLink (url) {
return BAD_PROTO_RE.test(str) ? GOOD_DATA_RE.test(str) : true
}


const RECODE_HOSTNAME_FOR = ['http:', 'https:', 'mailto:']

function normalizeLink (url) {
Expand Down Expand Up @@ -83,7 +81,6 @@ function normalizeLinkText (url) {
return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + '%')
}


/**
* class MarkdownIt
*
Expand Down Expand Up @@ -320,7 +317,6 @@ function MarkdownIt (presetName, options) {
**/
this.normalizeLinkText = normalizeLinkText


// Expose utils & helpers for easy acces from plugins

/**
Expand All @@ -339,14 +335,12 @@ function MarkdownIt (presetName, options) {
**/
this.helpers = utils.assign({}, helpers)


this.options = {}
this.configure(presetName)

if (options) { this.set(options) }
}


/** chainable
* MarkdownIt.set(options)
*
Expand All @@ -371,7 +365,6 @@ MarkdownIt.prototype.set = function (options) {
return this
}


/** chainable, internal
* MarkdownIt.configure(presets)
*
Expand Down Expand Up @@ -408,7 +401,6 @@ MarkdownIt.prototype.configure = function (presets) {
return this
}


/** chainable
* MarkdownIt.enable(list, ignoreInvalid)
* - list (String|Array): rule name or list of rule names to enable
Expand Down Expand Up @@ -446,7 +438,6 @@ MarkdownIt.prototype.enable = function (list, ignoreInvalid) {
return this
}


/** chainable
* MarkdownIt.disable(list, ignoreInvalid)
* - list (String|Array): rule name or list of rule names to disable.
Expand All @@ -473,7 +464,6 @@ MarkdownIt.prototype.disable = function (list, ignoreInvalid) {
return this
}


/** chainable
* MarkdownIt.use(plugin, params)
*
Expand All @@ -496,7 +486,6 @@ MarkdownIt.prototype.use = function (plugin /*, params, ... */) {
return this
}


/** internal
* MarkdownIt.parse(src, env) -> Array
* - src (String): source string
Expand Down Expand Up @@ -524,7 +513,6 @@ MarkdownIt.prototype.parse = function (src, env) {
return state.tokens
}


/**
* MarkdownIt.render(src [, env]) -> String
* - src (String): source string
Expand All @@ -542,7 +530,6 @@ MarkdownIt.prototype.render = function (src, env) {
return this.renderer.render(this.parse(src, env), this.options, env)
}


/** internal
* MarkdownIt.parseInline(src, env) -> Array
* - src (String): source string
Expand All @@ -561,7 +548,6 @@ MarkdownIt.prototype.parseInline = function (src, env) {
return state.tokens
}


/**
* MarkdownIt.renderInline(src [, env]) -> String
* - src (String): source string
Expand All @@ -576,5 +562,4 @@ MarkdownIt.prototype.renderInline = function (src, env) {
return this.renderer.render(this.parseInline(src, env), this.options, env)
}


export default MarkdownIt
5 changes: 0 additions & 5 deletions lib/parser_block.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const _rules = [
['paragraph', r_paragraph]
]


/**
* new ParserBlock()
**/
Expand All @@ -52,7 +51,6 @@ function ParserBlock () {
}
}


// Generate tokens for input range
//
ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
Expand Down Expand Up @@ -118,7 +116,6 @@ ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
}
}


/**
* ParserBlock.parse(str, md, env, outTokens)
*
Expand All @@ -132,8 +129,6 @@ ParserBlock.prototype.parse = function (src, md, env, outTokens) {
this.tokenize(state, state.line, state.lineMax)
}


ParserBlock.prototype.State = StateBlock


export default ParserBlock
4 changes: 0 additions & 4 deletions lib/parser_core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import r_replacements from './rules_core/replacements.mjs'
import r_smartquotes from './rules_core/smartquotes.mjs'
import r_text_join from './rules_core/text_join.mjs'


const _rules = [
['normalize', r_normalize],
['block', r_block],
Expand All @@ -29,7 +28,6 @@ const _rules = [
['text_join', r_text_join]
]


/**
* new Core()
**/
Expand All @@ -46,7 +44,6 @@ function Core () {
}
}


/**
* Core.process(state)
*
Expand All @@ -62,5 +59,4 @@ Core.prototype.process = function (state) {

Core.prototype.State = StateCore


export default Core
8 changes: 0 additions & 8 deletions lib/parser_inline.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import r_entity from './rules_inline/entity.mjs'
import r_balance_pairs from './rules_inline/balance_pairs.mjs'
import r_fragments_join from './rules_inline/fragments_join.mjs'


// Parser rules

const _rules = [
Expand Down Expand Up @@ -55,7 +54,6 @@ const _rules2 = [
['fragments_join', r_fragments_join]
]


/**
* new ParserInline()
**/
Expand Down Expand Up @@ -84,7 +82,6 @@ function ParserInline () {
}
}


// Skip single token by running all rules in validation mode;
// returns `true` if any rule reported success
//
Expand All @@ -95,7 +92,6 @@ ParserInline.prototype.skipToken = function (state) {
const maxNesting = state.md.options.maxNesting
const cache = state.cache


if (typeof cache[pos] !== 'undefined') {
state.pos = cache[pos]
return
Expand Down Expand Up @@ -137,7 +133,6 @@ ParserInline.prototype.skipToken = function (state) {
cache[pos] = state.pos
}


// Generate tokens for input range
//
ParserInline.prototype.tokenize = function (state) {
Expand Down Expand Up @@ -179,7 +174,6 @@ ParserInline.prototype.tokenize = function (state) {
}
}


/**
* ParserInline.parse(str, md, env, outTokens)
*
Expand All @@ -198,8 +192,6 @@ ParserInline.prototype.parse = function (str, md, env, outTokens) {
}
}


ParserInline.prototype.State = StateInline


export default ParserInline
Loading

0 comments on commit 8b815a6

Please sign in to comment.