Skip to content

Expose options for markdown-it #151

@vralle

Description

@vralle

Current behavior

I use eta.js as a template engine.

Now I tried to import markdown files into html, but it gives me errors.

Here's what I do:

src/view/index.html
I'm trying to import md file with eta include()

 {{~ include("parts/head") }}
<body>
   {{~ include("content/home.md") }}
</body>

The plugin cfg - here I'm use postprocess to parse md into html

import markdownit from 'markdown-it';
const md = markdownit({
  // Enable HTML tags in source
  html: true,
  typographer: true,
});
...
new HtmlBundlerPlugin({
  entry: {
    index: {
      import: join(projectPaths.src, "views", "index.html"),
      data: renderData
    },
  },
  postprocess: (content) => {
    return md.render(content);
  }
}),

Result:

ERROR in ./src/views/index.html
Module build failed (from ../../node_modules/html-bundler-webpack-plugin/src/Loader/index.js):
LoaderException: 
 HTML Bundler Plugin  Preprocessor failed.
File: src/views/index.html

Error: line 22
    21|         <body>
 >> 22|                 {{~ include("content/home.md") }}
    23|         </body>

Cannot find module 'prismjs'. Please install the missing module: npm i -D prismjs

Here the plugin requires prismjs. But why? I don't have code highlighting)

I guess the error could be caused by eta.js, but the plugin informs about unnecessary actions, and now I don't understand what I need to fix.

In general, I have no other ideas on how to use markdown with eta.js

Appreciation for the useful project

  • Do not forget to give a star ⭐

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions