Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
md.parse = (markdown: string, env: any) => {
// Generate tokens by Marp if enabled
if (detectMarpFromMarkdown(markdown)) {
const mdFolder = Uri.parse(md.normalizeLink('.')).with({ scheme: 'file' })
const workspaceFolder = workspace.getWorkspaceFolder(mdFolder)
const baseFolder = workspaceFolder ? workspaceFolder.uri : mdFolder
const marp = new Marp(marpCoreOptionForPreview(md.options))
.use(customTheme)
.use(outline)
.use(lineNumber)
// Load custom themes
let shouldRefresh = false
Promise.all(
themes.loadStyles(baseFolder).map(promise =>
promise
.then(theme => {
if (theme.registered) shouldRefresh = true
})
.catch(e => console.error(e))
)
).then(() => {
module.exports = opts => {
return new Marp(opts)
.use(markdownItMark)
// .use(markdownItFootnote)
.use(markdownItAbbr)
.use(markdownItSup)
.use(markdownItSub)
.use(markdownItEmoji)
.use(html5Media)
.use(markdownItContainer, 'note');
}
private loop() {
// At first, clear the event queue for adding funcs to execute in next frame
const events = this.animationEvents
this.animationEvents = []
// Execute registered events
for (const func of events) func()
// Finally trigger marp-core's fitting
MarpBrowser(false)
if (this.dispatched) this.requestAnimationFrame()
}
if (marpVscode) {
document.body.classList.add('marp-vscode')
// Remove default styles
const styles = document.querySelectorAll(
'style:not(#marp-vscode-style):not(#_defaultStyles)'
)
const links = document.querySelectorAll(
'link[rel="stylesheet"]:not([href*="marp-vscode"])'
)
styles.forEach(elm => elm.remove())
links.forEach(elm => elm.remove())
// Run Marp observer
browserCjs()
}
}
describe("Bespoke template's browser context", () => {
const marp = new Marp({
container: new MarpitElement('div', { id: 'p' }),
})
const defaultMarkdown = '# 1\n\n---\n\n## 2\n\n---\n\n### 3'
const render = (
md = defaultMarkdown,
targetDocument = document
): HTMLElement => {
targetDocument.body.innerHTML = marp.render(md).html
return targetDocument.getElementById('p')!
}
const replaceLocation = >(
path: string,
action: () => T
export const Marp = props => {
const marp = new MarpCore({
container: null,
script: false,
printable: false,
})
marp.markdown.normalizeLink = url => resolvePath(url)
const rendered = marp.render(props.markdown, { htmlAsArray: true })
return (
<div>
</div>