52 lines
1.2 KiB
Bash
Executable File
52 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# HTML structure
|
|
html_start='
|
|
<html>
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" href="github-markdown.css">
|
|
</head>
|
|
<body class="markdown-body">
|
|
<style>
|
|
.markdown-body {
|
|
box-sizing: border-box;
|
|
min-width: 200px;
|
|
max-width: 980px;
|
|
margin: 0 auto;
|
|
padding: 45px;
|
|
}
|
|
|
|
@media (max-width: 767px) {
|
|
.markdown-body {
|
|
padding: 15px;
|
|
}
|
|
}
|
|
</style>
|
|
'
|
|
|
|
html_end='
|
|
</body>
|
|
</html>
|
|
'
|
|
|
|
# Iterate over each markdown file in the current directory
|
|
for file in *.md; do
|
|
# Read markdown content from file
|
|
markdown_content=$(cat "$file")
|
|
|
|
# Convert markdown to HTML
|
|
html_content=$(gh api \
|
|
--method POST \
|
|
-H "Accept: application/vnd.github+json" \
|
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
/markdown \
|
|
-f text="$markdown_content"
|
|
)
|
|
|
|
# Write HTML content to a new file
|
|
html_file="./html/${file%.md}.html"
|
|
echo "$html_start$html_content$html_end" > "$html_file"
|
|
|
|
echo "Conversion completed. HTML content written to $html_file"
|
|
done |