Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
refactor(Headings extension): use tag func
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Feb 27, 2020
1 parent 71820f7 commit 249b24d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/extensions/headings/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { create, replace, select, ready, attr } from '../../util'
import { select, ready, tag } from '../../util'

/**
* Find all heading nodes and change their depth to depth +1
Expand All @@ -11,10 +11,6 @@ ready(() => {
select(':--Heading').forEach(heading => {
const level = parseFloat(/^H([1-6])$/.exec(heading.tagName)?.[1] ?? '0')
const newLevel = Math.min(level + 1, 6)
replace(
heading,
// Using innerHTML seems less than ideal, but given this is only meant to be temporary...
create(`h${newLevel} :--Heading`, heading.innerHTML)
)
tag(heading,`h${newLevel}`)
})
})

0 comments on commit 249b24d

Please sign in to comment.