Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fs = require('fs-plus')
let marked = null // Defer until used
let renderer = null
let cheerio = null
const yamlFrontMatter = require('yaml-front-matter')
let yamlFrontMatter = null

const { scopeForFenceName } = require('./extension-helper')
const { resourcePath } = atom.getLoadSettings()
Expand Down Expand Up @@ -49,9 +49,11 @@ exports.toHTML = async function (text, filePath, grammar) {
}

var render = function (text, filePath) {
if (marked == null) {
cheerio = require('cheerio')
if (marked == null || yamlFrontMatter == null || cheerio == null) {
marked = require('marked')
yamlFrontMatter = require('yaml-front-matter')
cheerio = require('cheerio')

renderer = new marked.Renderer()
renderer.listitem = function (text, isTask) {
const listAttributes = isTask ? ' class="task-list-item"' : ''
Expand Down