@@ -117,7 +117,7 @@ export const formatMarkdownBody = (container, selectors, options, exec) => {
117
117
return markdownBody
118
118
}
119
119
120
- const extract = async ( markdownBody , selectors , options , exec ) => {
120
+ const extract = async ( { markdownBody, selectors, options, exec, hook } ) => {
121
121
const { origin, context, localOptions = { } } = options
122
122
const fileName = getText ( selectors . title ) || document . title
123
123
const realName = fileName . replace ( / [ \\ \/ \? < > : ' \* \| ] / g, '_' )
@@ -151,7 +151,7 @@ const extract = async (markdownBody, selectors, options, exec) => {
151
151
} , localOptions . tpl )
152
152
const markdownDoc = html2markdown ( info + getMarkdown ( markdownBody ) , { } )
153
153
const copyright = formatCopyRight ( { title : fileName , url : location . href } , localOptions )
154
- const content = await exec ( 'formatContent' , { markdownBody, markdownDoc } )
154
+ const content = await exec ( hook [ 'formatContent' ] , context , { markdownBody, markdownDoc } )
155
155
files . push ( {
156
156
name : realName + '.md' ,
157
157
content : `${ content && typeof content === 'string' ? content : markdownDoc } ${ copyright } `
@@ -178,7 +178,7 @@ export const downloadMarkdown = async (...rest) => {
178
178
const markdownBody = formatMarkdownBody ( container , selectors , options , exec )
179
179
if ( await verify ( 'extract' , { markdownBody } ) ) return exec ( )
180
180
181
- const { fileName, files } = await extract ( markdownBody , selectors , options , exec )
181
+ const { fileName, files } = await extract ( { markdownBody, selectors, options, exec, hook } )
182
182
if ( await verify ( 'afterExtract' , { fileName, files } ) ) return exec ( )
183
183
184
184
return {
0 commit comments