question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to parse additional markdown files?

See original GitHub issue

Search terms

  • additional markdown
  • parsing
  • lexing
  • tokenization
  • reflection
  • plugin

Question

I have written a plugin that reads all the non-root/non-readme markdown files and creates HTML files out of those. Additionally it also supports some custom inline-tags. This process looks roughly as follows:

// The plugin code is abbreviated for the purpose of discussing the root issue.
function load(app) {
  app.renderer.on({
    [Renderer.EVENT_END_PAGE]: renderMarkdownPage.bind(app),
  });
}

function renderMarkdownPage(pageEvent) {
  if (!(model instanceof MarkdownReflection)) return; // <- MarkdownReflection: my custom reflection class

  pageEvent.contents = /** @type {DefaultTheme} */ (this.renderer.theme)
    .getRenderContext(pageEvent)
    .markdown(model.content) // <-- Markdown content
}

This works as expected except one problem. If the additional markdown files contain inline tags like {@link} those remain untouched and are not converted. So I thought to perform the same stuffs that is done for the project readme. However, I see that the relevant components are not exported from the package and additional exports are blocked via the exports in the package.json.

Is there any work around for this? Or am I looking at the wrong places, and there is a easier way to achieve this?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Sayan751commented, Aug 2, 2022

@Gerrit0 Thanks for the changes. It seems to work pretty well.

0reactions
Sayan751commented, Jul 26, 2022

Short term, should probably just change the markdown helper on DefaultThemeRenderContext to also accept a CommentDisplayPart[]

That sounds good as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Markdown and including multiple files - Stack Overflow
Specifically, I want to create a separate markdown file with links that I call often but not always (call this B.md), then when...
Read more >
Parsing Markdown into an Automated Table of Contents
This tutorial will show you how to parse long Markdown text to HTML and then generate a list of links from the headings....
Read more >
rpearce/parse-md: Parse Markdown file's metadata ... - GitHub
This library exists as a way to pass a markdown file's content and have its metadata and markdown returned as an object containing...
Read more >
How-To Guides - MyST Markdown
This page describes several common uses of MyST parser and how to accomplish them. Include rST files into a Markdown file¶. As explained...
Read more >
Writing a Simple Markdown Parser Using JavaScript
Many developers opt to use Markdown, a markup language which is popular for writing blogs, readme files, and many other forms of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found