Skip to content

Commit

Permalink
fix: typing mistakes or misspelled words (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManUtopiK authored Nov 28, 2023
1 parent fd1c9f6 commit bd3f4c4
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 39 deletions.
22 changes: 11 additions & 11 deletions src/from-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import { parseEntities } from 'parse-entities'
import { kebabCase } from 'scule'
import type { Token, CompileContext, Container, Fragment, Nodes } from './micromark-extension/types'
import type { RemarkMDCOptions } from './types'
import { NON_UNWRAPABLE_TYPES } from './utils'
import { NON_UNWRAPPABLE_TYPES } from './utils'

export default (opts: RemarkMDCOptions = {}) => {
const canContainEols = ['textComponent']

const experimentalAutoUnwrap = (node: Container) => {
if (opts.experimental?.autoUnwrap && NON_UNWRAPABLE_TYPES.includes(node.type)) {
if (opts.experimental?.autoUnwrap && NON_UNWRAPPABLE_TYPES.includes(node.type)) {
const nonSlotChildren = (node.children).filter((child: any) => child.type !== 'componentContainerSection')
if (nonSlotChildren.length === 1 && !NON_UNWRAPABLE_TYPES.includes(nonSlotChildren[0].type)) {
if (nonSlotChildren.length === 1 && !NON_UNWRAPPABLE_TYPES.includes(nonSlotChildren[0].type)) {
const nonSlotChildIndex = node.children.indexOf(nonSlotChildren[0])

node.children.splice(nonSlotChildIndex, 1, ...(nonSlotChildren[0] as Container).children)
Expand Down Expand Up @@ -149,9 +149,9 @@ export default (opts: RemarkMDCOptions = {}) => {

/**
* Ensure lists and list-items are closed before closing section
* This issue occurs because `---` separtors ar conflict with markdown lists
* This issue occurs because `---` separators ar conflict with markdown lists
*/
attempClosingOpenListSection.call(this, section)
attemptClosingOpenListSection.call(this, section)

experimentalAutoUnwrap(section)

Expand All @@ -163,9 +163,9 @@ export default (opts: RemarkMDCOptions = {}) => {

/**
* Ensure lists and list-items are closed before closing section
* This issue occurs because `---` separtors ar conflict with markdown lists
* This issue occurs because `---` separators ar conflict with markdown lists
*/
section = attempClosingOpenListSection.call(this, section)
section = attemptClosingOpenListSection.call(this, section)

if (section.type === 'componentContainerDataSection') {
section.rawData = this.sliceSerialize(token)
Expand Down Expand Up @@ -272,21 +272,21 @@ export default (opts: RemarkMDCOptions = {}) => {
}

function conditionalExit (this: CompileContext, token: Token) {
// As of [email protected] tokenStach items is an array containing the token and a handler
// As of [email protected] tokenStack items is an array containing the token and a handler
// https://github.com/syntax-tree/mdast-util-from-markdown/blob/752dc22acfc517d280612e8d499d5ce0cd5a4495/dev/lib/index.js#L548
const [section] = this.tokenStack[this.tokenStack.length - 1]
if ((section as Token).type === token.type) {
this.exit(token)
}
}

function attempClosingOpenListSection (this: CompileContext, section: (Fragment | Nodes)) {
function attemptClosingOpenListSection (this: CompileContext, section: (Fragment | Nodes)) {
/**
* Ensure lists and list-items are closed before closing section
* This issue occurs because `---` separtors ar conflict with markdown lists
* This issue occurs because `---` separators ar conflict with markdown lists
*/
while (section.type === 'listItem' || section.type === 'list') {
// As of [email protected] tokenStach items is an array containing the token and a handler
// As of [email protected] tokenStack items is an array containing the token and a handler
// https://github.com/syntax-tree/mdast-util-from-markdown/blob/752dc22acfc517d280612e8d499d5ce0cd5a4495/dev/lib/index.js#L548
const [stackToken] = this.tokenStack[this.tokenStack.length - 1]
this.exit(stackToken)
Expand Down
2 changes: 1 addition & 1 deletion src/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function stringifyFrontMatter (data: any, content = '') {
// flatten frontmatter data
// convert `parent: { child: ... }` into flat keys `parent.child`
data = flat.flatten(data, {
// preserve arrays and their contents as is and do not waltk through arrays
// preserve arrays and their contents as is and do not walk through arrays
// flatten array will be like `parent.0.child` and `parent.1.child` with is not readable
safe: true
})
Expand Down
2 changes: 1 addition & 1 deletion src/mdast-util-to-markdown.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
/**
* Functions to track output positions.
* This info isn’t used yet but suchs functionality allows line wrapping,
* This info isn’t used yet but such functionality allows line wrapping,
* and theoretically source maps (though, is there practical use in that?).
*
* @param {TrackFields} options_
Expand Down
2 changes: 1 addition & 1 deletion src/micromark-extension/tokenize-attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function tokenize (this: TokenizeContext, effects: Effects, ok: State, nok: Stat
if (code !== Codes.openingCurlyBracket) { throw new Error('expected `{`') }

/**
* Make sure sytax is used after valid tags
* Make sure syntax is used after valid tags
*/
const event = self.events[self.events.length - 1]
if (markdownLineEnding(self.previous) || !event || !validEvents.includes(event[1].type)) {
Expand Down
14 changes: 7 additions & 7 deletions src/micromark-extension/tokenize-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function tokenize (this: TokenizeContext, effects: Effects, ok: State, nok: Stat
* Show whether the current line is in the code fence or not.
* Lines inside the code fence will not check for the slot separator and component end.
*/
let vistingCodeFenced = false
let visitingCodeFenced = false

const section = useTokenState('componentContainerSection')

Expand Down Expand Up @@ -66,19 +66,19 @@ function tokenize (this: TokenizeContext, effects: Effects, ok: State, nok: Stat
}

if (size !== slotSeparatorLength) {
// Revert section state to inital value before failing
// Revert section state to initial value before failing
revertSectionState()
return nok(code)
}
if (sectionIndentSize !== initialPrefix) {
// Revert sect to inital value before failing
// Revert sect to initial value before failing
revertSectionState()
return nok(code)
}

// non ascii chars are invalid
if (!asciiAlpha(code)) {
// Revert sect to inital value before failing
// Revert sect to initial value before failing
revertSectionState()
return nok(code)
}
Expand Down Expand Up @@ -183,14 +183,14 @@ function tokenize (this: TokenizeContext, effects: Effects, ok: State, nok: Stat
return effects.check(
tokenizeCodeFence,
(code) => {
vistingCodeFenced = !vistingCodeFenced
visitingCodeFenced = !visitingCodeFenced
return chunkStart(code)
},
chunkStart
)(code)
}

if (vistingCodeFenced) {
if (visitingCodeFenced) {
return chunkStart(code)
}

Expand All @@ -204,7 +204,7 @@ function tokenize (this: TokenizeContext, effects: Effects, ok: State, nok: Stat
}

/**
* disbale spliting inner sections
* disable splitting inner sections
*/
if (code === Codes.colon) {
return effects.attempt(
Expand Down
4 changes: 2 additions & 2 deletions src/micromark-extension/tokenize-span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function tokenize (this: TokenizeContext, effects: Effects, ok: State, nok: Stat
throw new Error('expected `[`')
}

// When we are in the beggining of task list line,
// When we are in the beginning of task list line,
// there is a good chance that we are dealing with a GFM task list
if (
self.previous === Codes.EOF &&
Expand All @@ -46,7 +46,7 @@ function tokenize (this: TokenizeContext, effects: Effects, ok: State, nok: Stat
if (code === Codes.openingParentheses || code === Codes.openingSquareBracket) {
return nok(code)
}
// Attemp parsing attributes
// Attempt parsing attributes
if (code === Codes.openingCurlyBracket) {
return effects.attempt(attributes, exitOK, exitOK)(code)
}
Expand Down
10 changes: 5 additions & 5 deletions src/to-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { type State, type Info, type Unsafe, defaultHandlers } from 'mdast-util-
import { containerFlow, containerPhrasing, checkQuote } from './mdast-util-to-markdown'
import { stringifyFrontMatter } from './frontmatter'
import type { RemarkMDCOptions } from './types'
import { NON_UNWRAPABLE_TYPES } from './utils'
import { NON_UNWRAPPABLE_TYPES } from './utils'
import { Container } from './micromark-extension/types'

const own = {}.hasOwnProperty

const shortcut = /^[^\t\n\r "#'.<=>`}]+$/
const baseFense = 2
const baseFence = 2

// import { defaultHandlers } from 'mdast-util-to-markdown/lib/util/compile-pattern'
function compilePattern (pattern: Unsafe) {
Expand Down Expand Up @@ -45,9 +45,9 @@ export default (opts: RemarkMDCOptions = {}) => {
node.children = [
{
type: node.mdc.unwrapped as any,
children: node.children.filter(child => !NON_UNWRAPABLE_TYPES.includes(child.type))
children: node.children.filter(child => !NON_UNWRAPPABLE_TYPES.includes(child.type))
},
...node.children.filter(child => NON_UNWRAPABLE_TYPES.includes(child.type))
...node.children.filter(child => NON_UNWRAPPABLE_TYPES.includes(child.type))
]
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@ export default (opts: RemarkMDCOptions = {}) => {
let nest = 0
function containerComponent (node: NodeContainerComponent, _: any, context: any) {
context.indexStack = context.stack
const prefix = ':'.repeat(baseFense + nest)
const prefix = ':'.repeat(baseFence + nest)
nest += 1
const exit = context.enter(node.type)
let value = prefix + (node.name || '') + label(node, context)
Expand Down
4 changes: 2 additions & 2 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
interface ComponentHanlder {
interface ComponentHandler {
name: string
instance: any
options?: any
}

export interface RemarkMDCOptions {
components?: ComponentHanlder[]
components?: ComponentHandler[]
experimental?: {
autoUnwrap?: boolean
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const NON_UNWRAPABLE_TYPES = [
export const NON_UNWRAPPABLE_TYPES = [
'componentContainerSection',
'componentContainerDataSection',
'containerComponent',
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/attributes.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ exports[`Attributes > image 1`] = `
}
`;

exports[`Attributes > invlid-binding 1`] = `
exports[`Attributes > invalid-binding 1`] = `
{
"children": [
{
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/block-component.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`block-component > danglig-list 1`] = `
exports[`block-component > dangling-list 1`] = `
{
"children": [
{
Expand Down
2 changes: 1 addition & 1 deletion test/attributes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Attributes', () => {
markdown: ':test{attr= value} text',
expected: ':test{attr="value"} text'
},
'invlid-binding': {
'invalid-binding': {
markdown: ':test{:} text',
expected: ':test{:} text'
},
Expand Down
2 changes: 1 addition & 1 deletion test/block-component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('block-component', () => {
'Third line'
].join('\n')
},
'danglig-list': {
'dangling-list': {
markdown: [
'::component',
'- list item',
Expand Down
8 changes: 4 additions & 4 deletions test/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { unified, type Preset } from 'unified'
import parse from 'remark-parse'
import gfm from 'remark-gfm'
import strigify from 'remark-stringify'
import stringify from 'remark-stringify'
import { expect, test } from 'vitest'
import mdc from '../../src'

Expand All @@ -21,8 +21,8 @@ export function runMarkdownTests (tests: Record<string, MarkdownTest>) {

expect(ast).toMatchSnapshot()

const regenertedMarkdown = await astToMarkdown(ast, plugins, mdcOptions)
expect(regenertedMarkdown.trim()).toEqual(expected || markdown)
const regeneratedMarkdown = await astToMarkdown(ast, plugins, mdcOptions)
expect(regeneratedMarkdown.trim()).toEqual(expected || markdown)
if (extra) {
extra(markdown, ast, expected || markdown)
}
Expand Down Expand Up @@ -64,7 +64,7 @@ async function astToMarkdown (ast: any, plugins = [] as any[], mdcOptions = {})
for (const plugin of plugins) {
stream.use(plugin)
}
stream.use(strigify, {
stream.use(stringify, {
bullet: '-'
})
const result = await stream.process(JSON.stringify(ast))
Expand Down

0 comments on commit bd3f4c4

Please sign in to comment.