rewrite in vanilla js
This commit is contained in:
parent
590aec5260
commit
e1ea47052d
4 changed files with 10 additions and 29 deletions
|
|
@ -18,7 +18,7 @@ fn parse_markdown(document: &str) -> String {
|
||||||
|
|
||||||
// Parse the document into a root `AstNode`
|
// Parse the document into a root `AstNode`
|
||||||
let mut options = Options::default();
|
let mut options = Options::default();
|
||||||
options.render.hardbreaks = true;
|
// options.render.hardbreaks = true;
|
||||||
let root = parse_document(&arena, document, &options);
|
let root = parse_document(&arena, document, &options);
|
||||||
|
|
||||||
// Iterate over all the descendants of root.
|
// Iterate over all the descendants of root.
|
||||||
|
|
@ -28,7 +28,6 @@ fn parse_markdown(document: &str) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut html = vec![];
|
let mut html = vec![];
|
||||||
options.render.hardbreaks = true;
|
|
||||||
format_html(root, &options, &mut html).unwrap();
|
format_html(root, &options, &mut html).unwrap();
|
||||||
println!("{:?}", String::from_utf8(html.clone()));
|
println!("{:?}", String::from_utf8(html.clone()));
|
||||||
String::from_utf8(html).unwrap()
|
String::from_utf8(html).unwrap()
|
||||||
|
|
|
||||||
|
|
@ -10,31 +10,9 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<main class="container">
|
<main class="container">
|
||||||
<h1>Welcome to Tauri</h1>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<a href="https://tauri.app" target="_blank">
|
|
||||||
<img src="/assets/tauri.svg" class="logo tauri" alt="Tauri logo" />
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
href="https://developer.mozilla.org/en-US/docs/Web/JavaScript"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src="/assets/javascript.svg"
|
|
||||||
class="logo vanilla"
|
|
||||||
alt="JavaScript logo"
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<p>Click on the Tauri logo to learn more about the framework</p>
|
|
||||||
|
|
||||||
<textarea id="markdown_input"></textarea>
|
<textarea id="markdown_input"></textarea>
|
||||||
|
<div class="rendered_markdown" id="rendered_markdown">
|
||||||
<div class="row" id="rendered_markdown">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
invoke("parse_markdown", { document: text }).then(
|
invoke("parse_markdown", { document: text }).then(
|
||||||
(ret)=>{
|
(ret)=>{
|
||||||
var tag_id = document.getElementById('rendered_markdown');
|
var tag_id = document.getElementById('rendered_markdown');
|
||||||
tag_id.innerHTML = ret;
|
tag_id.innerHTML = "<pre>".concat("", ret).concat("", "</pre>");
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
padding-top: 10vh;
|
padding-top: 10vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: left;
|
||||||
text-align: center;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
|
|
@ -39,9 +39,13 @@
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rendered_markdown {
|
||||||
|
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
a {
|
a {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #646cff;
|
color: #646cff;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue