Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown export options (Feature request) #2963

Closed
samchugit opened this issue Jul 6, 2022 · 1 comment
Closed

Markdown export options (Feature request) #2963

samchugit opened this issue Jul 6, 2022 · 1 comment

Comments

@samchugit
Copy link

Describe feature

When I export a note with code blocks into markdown, the code blocks are indented rather than fenced with ```, along with the header style using setext than the atx style, which will be rendered normally in most markdown renderers. However, I still want the atx headers and fenced code blocks as my writing favor.

After inspecting the source code, I figure out that the markdown exporter utilizes turndown, and the export behavior can be tweaked by some options. So I made some changes to the src/services/export/md.js as followed.

--- a/src/services/export/md.js
+++ b/src/services/export/md.js
@@ -7,7 +7,7 @@ let instance = null;

 function toMarkdown(content) {
     if (instance === null) {
-        instance = new TurndownService();
+        instance = new TurndownService({ codeBlockStyle: 'fenced', headingStyle: 'atx' });
         instance.use(turndownPluginGfm.gfm);
     }

After recompiling the docker image, I can totally export notes into markdown files with fenced code blocks and atx style headers. Therefore, I wonder if it's possible to add some option entries to adjust exporting style.

P.S. thanks for your great job!

Additional Information

No response

@zadam
Copy link
Owner

zadam commented Jul 6, 2022

Hi, I changed codeblock style to fenced, it seems to be more popular.

@zadam zadam closed this as completed in 02affec Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants