aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--readme.md4
-rw-r--r--src/tokenizer.rs7
-rw-r--r--tests/definition.rs11
-rw-r--r--tests/misc_tabs.rs88
4 files changed, 53 insertions, 57 deletions
diff --git a/readme.md b/readme.md
index e50a21b..6c2e57d 100644
--- a/readme.md
+++ b/readme.md
@@ -66,15 +66,15 @@ cargo doc --document-private-items
### Small things
+- [ ] (1) Handle BOM at start
+- [ ] (1) Parse initial and final whitespace of paragraphs (in text)
- [ ] (1) Add docs to subtokenize
- [ ] (1) Add module docs to parser
- [ ] (1) Add overview docs on how everything works
- [ ] (1) Move safe protocols to constants
-- [ ] (1) Parse initial and final whitespace of paragraphs (in text)
- [ ] (3) Clean compiler
- [ ] (1) Use preferred line ending style in markdown
- [ ] (1) Add tests for `default-line-ending`, `line-ending`
-- [ ] (1) Handle BOM at start
- [ ] (1) Make sure tabs are handled properly and that positional info is perfect
- [ ] (1) Make sure crlf/cr/lf are working perfectly
- [ ] (3) Figure out lifetimes of things (see `life time` in source)
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index de27d12..d31c8c5 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -704,7 +704,12 @@ pub fn as_codes(value: &str) -> Vec<Code> {
// Send a tab and virtual spaces.
'\t' => {
// To do: is this correct?
- let virtual_spaces = TAB_SIZE - (column % TAB_SIZE);
+ let remainder = column % TAB_SIZE;
+ let virtual_spaces = if remainder == 0 {
+ 0
+ } else {
+ TAB_SIZE - remainder
+ };
codes.push(Code::Char(char));
column += 1;
let mut index = 0;
diff --git a/tests/definition.rs b/tests/definition.rs
index f0869a3..c15e44b 100644
--- a/tests/definition.rs
+++ b/tests/definition.rs
@@ -49,12 +49,11 @@ fn definition() {
// "should support line endings in titles"
// );
- // To do: some bug
- // assert_eq!(
- // micromark("[foo]: /url 'title\n\nwith blank line'\n\n[foo]"),
- // "<p>[foo]: /url 'title</p>\n<p>with blank line'</p>\n<p>[foo]</p>",
- // "should not support blank lines in titles"
- // );
+ assert_eq!(
+ micromark("[foo]: /url 'title\n\nwith blank line'\n\n[foo]"),
+ "<p>[foo]: /url 'title</p>\n<p>with blank line'</p>\n<p>[foo]</p>",
+ "should not support blank lines in titles"
+ );
// To do: link (reference).
// assert_eq!(
diff --git a/tests/misc_tabs.rs b/tests/misc_tabs.rs
index 0d05be9..46588e7 100644
--- a/tests/misc_tabs.rs
+++ b/tests/misc_tabs.rs
@@ -32,12 +32,11 @@ fn tabs_flow() {
"should support a 2*SP + HT to start code"
);
- // To do: bug with tabs/vs.
- // assert_eq!(
- // micromark(" \tx"),
- // "<pre><code>x\n</code></pre>",
- // "should support a 3*SP + HT to start code"
- // );
+ assert_eq!(
+ micromark(" \tx"),
+ "<pre><code>x\n</code></pre>",
+ "should support a 3*SP + HT to start code"
+ );
assert_eq!(
micromark(" \tx"),
@@ -45,54 +44,47 @@ fn tabs_flow() {
"should support a 4*SP to start code, and leave the next HT as code data"
);
- // To do: bug with tabs/vs.
- // assert_eq!(
- // micromark(" \t# x"),
- // "<pre><code># x\n</code></pre>",
- // "should not support a 3*SP + HT to start an ATX heading"
- // );
+ assert_eq!(
+ micromark(" \t# x"),
+ "<pre><code># x\n</code></pre>",
+ "should not support a 3*SP + HT to start an ATX heading"
+ );
- // To do: bug with tabs/vs.
- // assert_eq!(
- // micromark(" \t> x"),
- // "<pre><code>&gt; x\n</code></pre>",
- // "should not support a 3*SP + HT to start a block quote"
- // );
+ assert_eq!(
+ micromark(" \t> x"),
+ "<pre><code>&gt; x\n</code></pre>",
+ "should not support a 3*SP + HT to start a block quote"
+ );
- // To do: bug with tabs/vs.
- // assert_eq!(
- // micromark(" \t- x"),
- // "<pre><code>- x\n</code></pre>",
- // "should not support a 3*SP + HT to start a list item"
- // );
+ assert_eq!(
+ micromark(" \t- x"),
+ "<pre><code>- x\n</code></pre>",
+ "should not support a 3*SP + HT to start a list item"
+ );
- // To do: bug with tabs/vs.
- // assert_eq!(
- // micromark(" \t---"),
- // "<pre><code>---\n</code></pre>",
- // "should not support a 3*SP + HT to start a thematic break"
- // );
+ assert_eq!(
+ micromark(" \t---"),
+ "<pre><code>---\n</code></pre>",
+ "should not support a 3*SP + HT to start a thematic break"
+ );
- // To do: bug with tabs/vs.
- // assert_eq!(
- // micromark(" \t---"),
- // "<pre><code>---\n</code></pre>",
- // "should not support a 3*SP + HT to start a thematic break"
- // );
+ assert_eq!(
+ micromark(" \t---"),
+ "<pre><code>---\n</code></pre>",
+ "should not support a 3*SP + HT to start a thematic break"
+ );
- // To do: bug with tabs/vs.
- // assert_eq!(
- // micromark(" \t```"),
- // "<pre><code>```\n</code></pre>",
- // "should not support a 3*SP + HT to start a fenced code"
- // );
+ assert_eq!(
+ micromark(" \t```"),
+ "<pre><code>```\n</code></pre>",
+ "should not support a 3*SP + HT to start a fenced code"
+ );
- // To do: bug with tabs/vs.
- // assert_eq!(
- // micromark(" \t<div>"),
- // "<pre><code>&lt;div&gt;\n</code></pre>",
- // "should not support a 3*SP + HT to start HTML"
- // );
+ assert_eq!(
+ micromark(" \t<div>"),
+ "<pre><code>&lt;div&gt;\n</code></pre>",
+ "should not support a 3*SP + HT to start HTML"
+ );
assert_eq!(
micromark("#\tx\t#\t"),