-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GLOBAL UPDATE. MADE MODULAR. ADDED EXTRERNAL STYLE EDITING
- Loading branch information
Showing
7 changed files
with
491 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"rust-analyzer.showUnlinkedFileNotification": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
<html lang="en"> | ||
<head> | ||
<title>.\README.html</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style> | ||
body { | ||
font: 400 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
color: #111; | ||
background-color: #fdfdfd; | ||
-webkit-text-size-adjust: 100%; | ||
-webkit-font-feature-settings: "kern" 1; | ||
-moz-font-feature-settings: "kern" 1; | ||
-o-font-feature-settings: "kern" 1; | ||
font-feature-settings: "kern" 1; | ||
font-kerning: normal; | ||
padding: 30px; | ||
} | ||
|
||
@media only screen and (max-width: 600px) { | ||
body { | ||
padding: 5px; | ||
} | ||
|
||
body > #content { | ||
padding: 0px 20px 20px 20px !important; | ||
} | ||
} | ||
|
||
body > #content { | ||
margin: 0px; | ||
max-width: 900px; | ||
border: 1px solid #e1e4e8; | ||
padding: 10px 40px; | ||
padding-bottom: 20px; | ||
border-radius: 15px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
|
||
hr { | ||
color: #bbb; | ||
background-color: #bbb; | ||
height: 1px; | ||
flex: 0 1 auto; | ||
margin: 1em 0; | ||
padding: 0; | ||
border: none; | ||
} | ||
|
||
a { | ||
color: #0366d6; | ||
text-decoration: none; | ||
} | ||
|
||
a:visited { | ||
color: #0366d6; | ||
} | ||
|
||
a:hover { | ||
color: #0366d6; | ||
text-decoration: underline; | ||
} | ||
|
||
pre { | ||
background-color: #f6f8fa; | ||
border-radius: 3px; | ||
font-size: 85%; | ||
line-height: 1.45; | ||
overflow: auto; | ||
padding: 16px; | ||
} | ||
|
||
code { | ||
background-color: rgba(27,31,35,.05); | ||
border-radius: 3px; | ||
font-size: 85%; | ||
margin: 0; | ||
word-wrap: break-word; | ||
padding: .2em .4em; | ||
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace; | ||
} | ||
|
||
pre > code { | ||
background-color: transparent; | ||
border: 0; | ||
display: inline; | ||
line-height: inherit; | ||
margin: 0; | ||
overflow: visible; | ||
padding: 0; | ||
word-wrap: normal; | ||
font-size: 100%; | ||
} | ||
|
||
blockquote { | ||
margin-left: 30px; | ||
margin-top: 0px; | ||
margin-bottom: 16px; | ||
border-left-width: 3px; | ||
padding: 0 1em; | ||
color: #828282; | ||
border-left: 4px solid #e8e8e8; | ||
padding-left: 15px; | ||
font-size: 18px; | ||
letter-spacing: -1px; | ||
font-style: italic; | ||
} | ||
|
||
blockquote * { | ||
font-style: normal !important; | ||
letter-spacing: 0; | ||
color: #6a737d !important; | ||
} | ||
|
||
table { | ||
border-spacing: 2px; | ||
display: block; | ||
font-size: 14px; | ||
overflow: auto; | ||
width: 100%; | ||
margin-bottom: 16px; | ||
border-spacing: 0; | ||
border-collapse: collapse; | ||
} | ||
|
||
td { | ||
padding: 6px 13px; | ||
border: 1px solid #dfe2e5; | ||
} | ||
|
||
th { | ||
font-weight: 600; | ||
padding: 6px 13px; | ||
border: 1px solid #dfe2e5; | ||
} | ||
|
||
tr { | ||
background-color: #fff; | ||
border-top: 1px solid #c6cbd1; | ||
} | ||
|
||
table tr:nth-child(2n) { | ||
background-color: #f6f8fa; | ||
} | ||
|
||
img { | ||
max-width: 100%; | ||
} | ||
|
||
p { | ||
line-height: 24px; | ||
font-weight: 400; | ||
font-size: 16px; | ||
color: #24292e; | ||
} | ||
|
||
ul { | ||
margin-top: 0; | ||
} | ||
|
||
li { | ||
color: #24292e; | ||
font-size: 16px; | ||
font-weight: 400; | ||
line-height: 1.5; | ||
} | ||
|
||
li + li { | ||
margin-top: 0.25em; | ||
} | ||
|
||
* { | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; | ||
color: #24292e; | ||
} | ||
|
||
a:visited { | ||
color: #0366d6; | ||
} | ||
|
||
h1, h2, h3 { | ||
border-bottom: 1px solid #eaecef; | ||
color: #111; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id='content'><h1 align="center">Makurust</h1> | ||
<p align="center"> | ||
<img src="https://user-images.githubusercontent.com/97128346/221287390-bb500651-5daa-4fbc-a1f4-10f34fc27ff8.png" width="300px" height="300px"> | ||
</p> | ||
<h3 align="center">Makurust is a powerful tool written in Rust that allows you to effortlessly convert your Markdown files into static HTML pages. Inspired by Typescript based Makudaun tool that was originially written by Yuri Katsuki. Makurust is designed to make the conversion process as fast and efficient as possible.</h3> | ||
<p> | ||
<h2>Usage</h2> | ||
<p>To use Makurust, simply run the following command:</p> | ||
<pre><code class="language-bash">makurust filename.md | ||
</code></pre> | ||
<p>As a result, an HTML page will be created from the given Markdown file. If the output file already exists, it will be overwritten.<br></p> | ||
<p>Makurust was build using third party library - <code>pulldown-cmark = "0.9.2"</code></p> | ||
<h2>Installation from git</h2> | ||
<pre><code class="language-bash">cargo install --locked --git https://github.com/fromgodd/makurust makurust | ||
</code></pre> | ||
<h3>What is working</h3> | ||
<ul> | ||
<li>[X] Basic Markdown Support</li> | ||
<li>[x] GitHub-like Markdown Style</li> | ||
<li>[x] Aligning</li> | ||
<li>[x] Images</li> | ||
<li>[x] Code snippets</li> | ||
</ul> | ||
<h3>Under development</h3> | ||
<ul> | ||
<li>[ ] Table</li> | ||
<li>[ ] Syntax highlighting for snippets</li> | ||
<li>[ ] Checkboxes</li> | ||
</ul> | ||
<h3>TODO: Implement Table support, Darkmode (-dark argument), ~~Implement panics~~, OS System Err and etc.</h3> | ||
|
||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::env; | ||
|
||
pub struct Args { | ||
pub input_filename: String, | ||
} | ||
|
||
pub fn parse_args() -> Result<Args, &'static str> { | ||
let args: Vec<String> = env::args().collect(); | ||
let mut input_filename: Option<&String> = None; | ||
for arg in args.iter().skip(1) { | ||
match arg.as_str() { | ||
"-h" => { | ||
println!("USAGE: makurust filename.md"); | ||
return Err("help"); | ||
} | ||
"-v" => { | ||
println!("Makurust V 0.2beta"); | ||
return Err("version"); | ||
} | ||
_ => input_filename = Some(arg), | ||
} | ||
} | ||
let input_filename = match input_filename { | ||
Some(filename) => filename.to_string(), | ||
None => { | ||
println!("No input file provided!"); | ||
return Err("input file not provided"); | ||
} | ||
}; | ||
Ok(Args { input_filename }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use pulldown_cmark::{html, Options, Parser}; | ||
use std::fs; | ||
use std::fs::File; | ||
use std::io::{self, prelude::*}; | ||
use std::error::Error; | ||
|
||
pub fn markdown_to_html(input_contents: &str) -> String { | ||
let options = Options::empty(); | ||
let parser = Parser::new_ext(input_contents, options); | ||
let mut html_output = String::new(); | ||
html::push_html(&mut html_output, parser); | ||
html_output | ||
} | ||
|
||
pub fn write_to_file(html_output: String, output_filename: &str) -> Result<(), Box<dyn Error>> { | ||
let precontent = format!( | ||
r#"<html lang="en"> | ||
<head> | ||
<title>{}</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style> | ||
{} | ||
</style> | ||
</head> | ||
<body> | ||
<div id='content'>"#, | ||
output_filename.replace(".md", ""), | ||
fs::read_to_string("styles/style.css")?, | ||
); | ||
let postcontent = r#" | ||
</div> | ||
</body> | ||
</html>"#; | ||
let mut output_file = File::create(output_filename)?; | ||
write!(output_file, "{}{}{}", precontent, html_output, postcontent)?; | ||
Ok(()) | ||
} |
Oops, something went wrong.