Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function get_tutorial(slug) {
const found = find_tutorial(slug);
if (!found) return found;
const dir = `content/tutorial/${found.section}/${found.chapter}`;
const markdown = fs.readFileSync(`${dir}/text.md`, 'utf-8');
const app_a = fs.readdirSync(`${dir}/app-a`);
const app_b = fs.existsSync(`${dir}/app-b`) && fs.readdirSync(`${dir}/app-b`);
const { content } = extract_frontmatter(markdown);
const renderer = new marked.Renderer();
renderer.link = link_renderer;
renderer.code = (source, lang) => {
source = source.replace(/^ +/gm, match =>
match.split(' ').join('\t')
);
const lines = source.split('\n');
const meta = extract_metadata(lines[0], lang);
let prefix = '';
let className = 'code-block';