From d175ab4f4786097c20addb5d8636f2d145178f5b Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Sun, 26 Mar 2023 16:20:00 +0200 Subject: [PATCH 1/9] jotdown_wasm: rm debug print --- examples/jotdown_wasm/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/jotdown_wasm/index.html b/examples/jotdown_wasm/index.html index 9155096..be3d983 100644 --- a/examples/jotdown_wasm/index.html +++ b/examples/jotdown_wasm/index.html @@ -10,7 +10,6 @@ function render() { let html = jotdown_render(input.innerText); - console.log(fmt.value); if (fmt.value == "html") { output.classList.add("verbatim") output.innerText = html; From 4cacb61a6885dc9cde4b9860d36c6b78b81d9d34 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Sun, 26 Mar 2023 22:59:26 +0200 Subject: [PATCH 2/9] jotdown_wasm: rm unmatched closing div --- examples/jotdown_wasm/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/jotdown_wasm/index.html b/examples/jotdown_wasm/index.html index be3d983..df27dd4 100644 --- a/examples/jotdown_wasm/index.html +++ b/examples/jotdown_wasm/index.html @@ -28,5 +28,5 @@ setTimeout(() => { input.focus(); }, 0);
*Hello world!*
-

+  

 

From d5803c4a12668eaa6f8f84e4586c79fba8b51678 Mon Sep 17 00:00:00 2001
From: Noah Hellman 
Date: Sun, 26 Mar 2023 16:33:38 +0200
Subject: [PATCH 3/9] jotdown_wasm: create html wrapper

demo.html can be included in another html file, create a html file that
includes demo.html for the demo, rather than using demo.html directly
and letting the browser add ,  etc
---
 examples/jotdown_wasm/Makefile                  | 14 ++++++++++++--
 examples/jotdown_wasm/{index.html => demo.html} |  0
 2 files changed, 12 insertions(+), 2 deletions(-)
 rename examples/jotdown_wasm/{index.html => demo.html} (100%)

diff --git a/examples/jotdown_wasm/Makefile b/examples/jotdown_wasm/Makefile
index 5c0c34c..96ab265 100644
--- a/examples/jotdown_wasm/Makefile
+++ b/examples/jotdown_wasm/Makefile
@@ -7,9 +7,19 @@ ${WASM}: ${SRC}
 
 wasm: ${WASM}
 
-run: ${WASM}
+index.html: Makefile demo.html
+	echo '' > $@
+	echo '' >> $@
+	echo 'Jotdown Demo' >> $@
+	echo '' >> $@
+	echo '' >> $@
+	cat demo.html >> $@
+	echo '' >> $@
+	echo '' >> $@
+
+run: ${WASM} index.html
 	python -m http.server
 
 clean:
-	rm -rf pkg
+	rm -rf pkg index.html
 	cargo clean
diff --git a/examples/jotdown_wasm/index.html b/examples/jotdown_wasm/demo.html
similarity index 100%
rename from examples/jotdown_wasm/index.html
rename to examples/jotdown_wasm/demo.html

From 122cb84d2d37e2771cf80cd0a87b304f776660b0 Mon Sep 17 00:00:00 2001
From: Noah Hellman 
Date: Sun, 26 Mar 2023 16:15:54 +0200
Subject: [PATCH 4/9] jotdown_wasm: use full viewport

---
 examples/jotdown_wasm/Makefile  |  2 +-
 examples/jotdown_wasm/demo.html | 15 +++++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/examples/jotdown_wasm/Makefile b/examples/jotdown_wasm/Makefile
index 96ab265..d2a2b92 100644
--- a/examples/jotdown_wasm/Makefile
+++ b/examples/jotdown_wasm/Makefile
@@ -12,7 +12,7 @@ index.html: Makefile demo.html
 	echo '' >> $@
 	echo 'Jotdown Demo' >> $@
 	echo '' >> $@
-	echo '' >> $@
+	echo '' >> $@
 	cat demo.html >> $@
 	echo '' >> $@
 	echo '' >> $@
diff --git a/examples/jotdown_wasm/demo.html b/examples/jotdown_wasm/demo.html
index df27dd4..5876b28 100644
--- a/examples/jotdown_wasm/demo.html
+++ b/examples/jotdown_wasm/demo.html
@@ -1,5 +1,4 @@
-
-
+
-
*Hello world!*
-

+  
+ +
+
+
*Hello world!*
+

+  
From f31398a796136da1a6682175692442acf1481e16 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Sun, 26 Mar 2023 17:05:50 +0200 Subject: [PATCH 5/9] attr: impl Debug for Attributes manually show key value pairs instead of internal structure --- src/attr.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/attr.rs b/src/attr.rs index cd6eaaa..16fc984 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -98,7 +98,7 @@ impl<'s> Iterator for AttributeValueParts<'s> { // Attributes are relatively rare, we choose to pay 8 bytes always and sometimes an extra // indirection instead of always 24 bytes. #[allow(clippy::box_vec)] -#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[derive(Clone, PartialEq, Eq, Default)] pub struct Attributes<'s>(Option)>>>); impl<'s> Attributes<'s> { @@ -202,6 +202,21 @@ impl<'s> FromIterator<(&'s str, &'s str)> for Attributes<'s> { } } +impl<'s> std::fmt::Debug for Attributes<'s> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{{")?; + let mut first = true; + for (k, v) in self.iter() { + if !first { + write!(f, ", ")?; + } + first = false; + write!(f, "{}=\"{}\"", k, v.raw)?; + } + write!(f, "}}") + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum State { Start, From f3732693c6807acb07772bdffa76f46ddc93d2c3 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Sun, 26 Mar 2023 14:54:25 +0200 Subject: [PATCH 6/9] jotdown_wasm: add option to show events provide 1:1 representation of events to help explore how events are emitted --- examples/jotdown_wasm/demo.html | 14 ++++++++++---- examples/jotdown_wasm/src/lib.rs | 8 ++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/examples/jotdown_wasm/demo.html b/examples/jotdown_wasm/demo.html index 5876b28..60f0308 100644 --- a/examples/jotdown_wasm/demo.html +++ b/examples/jotdown_wasm/demo.html @@ -1,6 +1,9 @@