In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to convert multiple Markdown files into HTML or other formats in Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn how to convert multiple Markdown files into HTML or other formats in Linux.
Most of the time the way I deal with Markdown is to finish writing a file and then convert it to HTML or other formats. There are also times when you need to create new files. When I have to write multiple Markdown files, I usually have to write them all before converting them.
I use pandoc to convert files, which converts all Markdown files at once.
Files in Markdown format can be converted to .html files, and sometimes I need to convert it to another format, such as epub, when pandoc comes in handy. I prefer to use the command line, so I'll introduce it first in this article, but you can also use VSCodium to do the conversion on the non-command line. I'll introduce it later.
Use pandoc to convert multiple Markdown files to other formats (command line)
You can get started quickly by typing the following command at Ubuntu and other Debian distribution terminals:
Sudo apt-get install pandoc
In this example, I have four Markdown files that need to be converted in a directory called md_test.
[email protected]: ~ / Documents/md_test$ ls-l * .md-rw-r--r-- 1 bdyer bdyer 3374 Apr 7 2020 file01.md-rw-r--r-- 1 bdyer bdyer 782 Apr 2 05:23 file02.md-rw-r--r-- 1 bdyer bdyer 9257 Apr 2 05:21 file03.md-rw-r--r-- 1 bdyer bdyer 9442 Apr 2 05:21 file04.md [email protected]: ~ / Documents/md_test$
There is no HTML file yet. Now I'm going to use pandoc for these files. I will run a command to do this:
Call pandoc
Read the .md file and export it to .html
Here is the command I want to run:
For i in * .md; do echo "$I" & & pandoc-s $I-o $i.html; done
If you don't quite understand the commands above, you can refer to executing more than one command at a time in Linux.
After I execute the command, the result is as follows:
[email protected]: ~ / Documents/md_test$ for i in * .md; do echo "$I" & & pandoc-s $I-o $i.html; donefile01.mdfile02.mdfile03.mdfile04.md [email protected]: ~ / Documents/md_test$
Let me use the ls command again to see if the HTML file has been generated:
[email protected]: ~ / Documents/md_test$ ls-l * .html-rw-r--r-- 1 bdyer bdyer 4291 Apr 2 06:08 file01.md.html-rw-r--r-- 1 bdyer bdyer 1781 Apr 2 06:08 file02.md.html-rw-r--r-- 1 bdyer bdyer 10272 Apr 2 06:08 file03.md.html-rw-r--r-- 1 bdyer bdyer 10502 Apr 2 06:08 file04.md.html [email protected]: ~ / Documents/md_test$
The conversion was successful, and now you have four HTML files that can be used on the Web server.
Pandoc has quite a number of features, and you can convert Markdown files to other supported formats by specifying the extension of the output file. It is not difficult to understand why it is considered to be the best open source writing tool.
Use VSCodium to convert Markdown files to HTML (GUI mode)
As we said earlier, I usually use the command line, but for batch conversions, I don't use the command line, and neither do you. VSCode or VSCodium can complete batch operations. You only need to install a Markdown-All-in-One extension to convert multiple Markdown files in one run.
There are two ways to install this extension:
Terminal of VSCodium
Plug-in Manager for VSCodium
Install the extension through VSCodium's terminal:
Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community
Click the terminal of the menu bar. Will open the terminal panel
Enter, or copy the following command and paste it to the terminal:
Codium-install-extension yzhang.markdown-all-in-one
Note: if you are using VSCode instead of VSCodium, replace the codium in the above command with code
The second way to install is through the plug-in / extension manager of VSCodium:
Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community
Click the block area on the left side of the VSCodium window. An extended list appears with a search box at the top of the list.
Enter "Markdown All in One" in the search box. The extension appears at the top of the list. Click the install button to install it. If you have already installed it, a gear icon will appear at the location of the installation button.
After the installation is complete, you can open the folder containing the Markdown files that need to be converted.
Click the paper icon on the left side of the VSCodium window. You can choose a folder. After opening the folder, you need to open at least one file. You can also open multiple files, but at least one.
When the file is open, press CTRL+SHIFT+P to evoke the command panel. Then, enter Markdown in the search box that appears. When you type, a list of Markdown-related commands appears. One of them is the Markdown All in One: Print documents to HTML command. Click it:
You need to select a folder to store these files. It will automatically create an out directory, and the converted HTML files will be stored in the out directory. As you can see from the figure below, the Markdown document has been converted to an HTML file. Here, you can open, view, and edit these HTML files.
You can concentrate more on writing while waiting for Markdown files to be converted. When you are ready, you can convert them to HTML-you can convert them in two ways.
At this point, I believe you have a deeper understanding of "how to convert multiple Markdown files into HTML or other formats in Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.