Skip to content

Commit

Permalink
Adopt Prettier v3 new default style
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Sep 9, 2023
1 parent a8d6bac commit b997338
Show file tree
Hide file tree
Showing 68 changed files with 296 additions and 292 deletions.
2 changes: 1 addition & 1 deletion docs/assets/how-to-use/example.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<body>
<style>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
12 changes: 7 additions & 5 deletions docsify/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ const server = http.createServer((req, res) => {
if (endBodyIdx >= 0) {
html = `${html.slice(
0,
endBodyIdx
endBodyIdx,
)}<script>${wsScript}</script></body>${html.slice(
endBodyIdx + 7
endBodyIdx + 7,
)}`
}

Expand All @@ -87,7 +87,7 @@ const server = http.createServer((req, res) => {
overriddenHeaders['Content-Length'] = html.length.toString()
resolve(this)
},
})
}),
)
}
})
Expand All @@ -99,10 +99,12 @@ const server = http.createServer((req, res) => {
public: path.resolve(__dirname, '../docs'),
rewrites: [{ source: '**', destination: '/index.html' }],
},
{ createReadStream }
{ createReadStream },
)
})

server.listen(port, () =>
console.log(`Listening Marpit documentation on http://127.0.0.1:${port}/ ...`)
console.log(
`Listening Marpit documentation on http://127.0.0.1:${port}/ ...`,
),
)
6 changes: 3 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ declare namespace Marpit {
type DirectiveDefinitions = {
[directive: string]: (
value: string | object | (string | object)[],
marpit?: Marpit
marpit?: Marpit,
) => { [meta: string]: any }
}

Expand Down Expand Up @@ -66,7 +66,7 @@ declare namespace Marpit {
}

type PluginFactory = <P extends any[]>(
plugin: Plugin<P, { marpit: Marpit }>
plugin: Plugin<P, { marpit: Marpit }>,
) => Plugin<P, { marpit: Marpit }>

export class Marpit {
Expand Down Expand Up @@ -139,7 +139,7 @@ declare namespace Marpit {
get(name: string, fallback?: boolean): Theme | undefined
getThemeMeta(
theme: string | Theme,
meta: string
meta: string,
): string | string[] | undefined
getThemeProp(theme: string | Theme, prop: string): any
has(name: string): boolean
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/postcss_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export function plugin(name, func) {
return Object.defineProperty(
typeof retFunc === 'function' ? { Once: retFunc } : retFunc,
'postcssPlugin',
{ value: name }
{ value: name },
)
},
'postcss',
{ value: true }
{ value: true },
)
}

Expand Down
20 changes: 10 additions & 10 deletions src/markdown/background_image/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function _advancedBackground(md) {

t.attrSet(
'width',
`${100 - Number.parseFloat(splitBgSize.slice(0, -1))}%`
`${100 - Number.parseFloat(splitBgSize.slice(0, -1))}%`,
)

if (splitSide === 'left') t.attrSet('x', splitBgSize)
Expand Down Expand Up @@ -99,17 +99,17 @@ function _advancedBackground(md) {
{
tag: 'figure',
style: style.toString(),
}
)
},
),
)
}

return imageTokens
})()
)
)
})(),
),
),
),
t
t,
)
} else if (current && t.type === 'marpit_inline_svg_content_close') {
const { open, height, width } = current.meta.marpitBackground
Expand Down Expand Up @@ -142,8 +142,8 @@ function _advancedBackground(md) {
id: undefined,
style: style.toString(),
'data-marpit-advanced-background': 'pseudo',
})
)
}),
),
)

current = undefined
Expand All @@ -153,7 +153,7 @@ function _advancedBackground(md) {
}

state.tokens = newTokens
}
},
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/markdown/background_image/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function _backgroundImageApply(md) {
}
}
}
}
},
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/markdown/background_image/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function _backgroundImageParse(md) {
}
}
}
}
},
)
}

Expand Down
4 changes: 2 additions & 2 deletions src/markdown/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function _comment(md) {
parse(token, token.content)

return true
}
},
)

md.inline.ruler.before(
Expand Down Expand Up @@ -122,7 +122,7 @@ function _comment(md) {

state.pos += match[0].length
return true
}
},
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/markdown/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function _container(md) {
state.Token,
'marpit_containers',
cont,
state.tokens
state.tokens,
)
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/markdown/directives/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function _apply(md, opts = {}) {
if (marpitDirectives.backgroundPosition)
style.set(
'background-position',
marpitDirectives.backgroundPosition
marpitDirectives.backgroundPosition,
)

if (marpitDirectives.backgroundRepeat)
Expand All @@ -114,11 +114,11 @@ function _apply(md, opts = {}) {
if (marpitDirectives.paginate !== 'skip') {
token.attrSet(
'data-marpit-pagination',
marpitSlide - currentSkippedSlides + 1
marpitSlide - currentSkippedSlides + 1,
)
token.attrSet(
'data-marpit-pagination-total',
marpitSlideTotal - totalSkippedSlides
marpitSlideTotal - totalSkippedSlides,
)
}
}
Expand All @@ -133,7 +133,7 @@ function _apply(md, opts = {}) {
if (styleStr !== '') token.attrSet('style', styleStr)
}
}
}
},
)
}

Expand Down
8 changes: 4 additions & 4 deletions src/markdown/directives/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function _parse(md, opts = {}) {
...Object.keys(marpit.customDirectives.global),
...Object.keys(marpit.customDirectives.local),
]
: false
: false,
)
if (parsed !== false) frontMatterObject.yaml = parsed
})
Expand All @@ -84,7 +84,7 @@ function _parse(md, opts = {}) {
...globalDirectives,
...applyBuiltinDirectives(
marpit.customDirectives.global[key](obj[key], marpit),
directives.globals
directives.globals,
),
}
}
Expand Down Expand Up @@ -138,7 +138,7 @@ function _parse(md, opts = {}) {
...cursor.local,
...applyBuiltinDirectives(
marpit.customDirectives.local[key](obj[key], marpit),
directives.locals
directives.locals,
),
}
}
Expand All @@ -160,7 +160,7 @@ function _parse(md, opts = {}) {
...cursor.spot,
...applyBuiltinDirectives(
marpit.customDirectives.local[spotKey](obj[key], marpit),
directives.locals
directives.locals,
),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/markdown/directives/yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const yaml = (text, looseDirectives = false) =>
...directives,
...(Array.isArray(looseDirectives) ? looseDirectives : []),
])
: text
: text,
)

export default yaml
8 changes: 4 additions & 4 deletions src/markdown/header_and_footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function _headerAndFooter(md) {
state.Token,
`marpit_${tag}`,
{ tag, close: { block: true } },
getParsed(markdown)
getParsed(markdown),
)

let current
Expand All @@ -49,12 +49,12 @@ function _headerAndFooter(md) {

if (current.meta && current.meta.marpitHeader)
newTokens.push(
...createMarginalTokens('header', current.meta.marpitHeader)
...createMarginalTokens('header', current.meta.marpitHeader),
)
} else if (token.type === 'marpit_slide_close') {
if (current.meta && current.meta.marpitFooter)
newTokens.push(
...createMarginalTokens('footer', current.meta.marpitFooter)
...createMarginalTokens('footer', current.meta.marpitFooter),
)

newTokens.push(token)
Expand All @@ -64,7 +64,7 @@ function _headerAndFooter(md) {
}

state.tokens = newTokens
}
},
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/markdown/heading_divider.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function _headingDivider(md) {
marpit.lastGlobalDirectives &&
Object.prototype.hasOwnProperty.call(
marpit.lastGlobalDirectives,
'headingDivider'
'headingDivider',
)
)
target = marpit.lastGlobalDirectives.headingDivider
Expand Down
2 changes: 1 addition & 1 deletion src/markdown/image/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function _applyImage(md) {
}
}
}
}
},
)
}

Expand Down
14 changes: 7 additions & 7 deletions src/markdown/image/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import marpitPlugin from '../../plugin'
const escape = (target) =>
target.replace(
/[\\;:()]/g,
(matched) => `\\${matched[0].codePointAt(0).toString(16)} `
(matched) => `\\${matched[0].codePointAt(0).toString(16)} `,
)

const optionMatchers = new Map()
Expand All @@ -18,12 +18,12 @@ const normalizeLength = (v) => `${v}${/^(\d*\.)?\d+$/.test(v) ? 'px' : ''}`

optionMatchers.set(
/^w(?:idth)?:((?:\d*\.)?\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px)?|auto)$/,
(matches) => ({ width: normalizeLength(matches[1]) })
(matches) => ({ width: normalizeLength(matches[1]) }),
)

optionMatchers.set(
/^h(?:eight)?:((?:\d*\.)?\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px)?|auto)$/,
(matches) => ({ height: normalizeLength(matches[1]) })
(matches) => ({ height: normalizeLength(matches[1]) }),
)

// CSS filters
Expand All @@ -44,11 +44,11 @@ optionMatchers.set(
for (const arg of matches.slice(1)) {
if (arg) {
const colorFunc = arg.match(
/^(rgba?|hsla?|hwb|(?:ok)?(?:lab|lch)|color)\((.*)\)$/
/^(rgba?|hsla?|hwb|(?:ok)?(?:lab|lch)|color)\((.*)\)$/,
)

args.push(
colorFunc ? `${colorFunc[1]}(${escape(colorFunc[2])})` : escape(arg)
colorFunc ? `${colorFunc[1]}(${escape(colorFunc[2])})` : escape(arg),
)
}
}
Expand All @@ -59,7 +59,7 @@ optionMatchers.set(
['drop-shadow', args.join(' ') || '0 5px 10px rgba(0,0,0,.4)'],
],
}
}
},
)
optionMatchers.set(/^grayscale(?::(.+))?$/, (matches, meta) => ({
filters: [...meta.filters, ['grayscale', escape(matches[1] || '1')]],
Expand Down Expand Up @@ -208,7 +208,7 @@ function _parseImage(md) {
: 'color'

console.warn(
`Deprecation warning: Shorthand for setting colors via Markdown image syntax is deprecated now, and will remove in next major release. Please replace to a scoped local direcitve <!-- _${replacedDirective}: "${originalUrl}" -->, or use the scoped style <style scoped>.`
`Deprecation warning: Shorthand for setting colors via Markdown image syntax is deprecated now, and will remove in next major release. Please replace to a scoped local direcitve <!-- _${replacedDirective}: "${originalUrl}" -->, or use the scoped style <style scoped>.`,
)

token.meta.marpitImage.color = originalUrl
Expand Down
10 changes: 5 additions & 5 deletions src/markdown/inline_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function _inlineSVG(md) {
for (const tokens of split(
state.tokens,
(t) => t.meta && t.meta.marpitSlideElement === 1,
true
true,
)) {
if (tokens.length > 0) {
for (const t of tokens)
Expand All @@ -52,15 +52,15 @@ function _inlineSVG(md) {
state.Token,
'marpit_inline_svg_content',
{ tag: 'foreignObject', width: w, height: h },
tokens
)
)
tokens,
),
),
)
}
}

state.tokens = newTokens
}
},
)
}

Expand Down
Loading

0 comments on commit b997338

Please sign in to comment.