Permalink
Browse files

let widont support dd and dt

  • Loading branch information...
1 parent 007c3ff commit 7f0b053df13b77c2d9358a1739a7954a5496023a @ddfreyne committed May 1, 2012
Showing with 22 additions and 1 deletion.
  1. +0 −1 README.md
  2. +8 −0 src/fast-aleck/fast-aleck-test.c
  3. +14 −0 src/fast-aleck/fast-aleck.c
View
@@ -50,5 +50,4 @@ If you intend to use the Ruby bindings, copy `libfast-aleck.so` to a public loca
To do
-----
-* Implement Widon't for other block elements (e.g. `h1` to `h6`)
* Implement turning HTML off inside `<title>`
@@ -248,6 +248,14 @@ int main(void)
"<blockquote>Foo bar baz.</blockquote><blockquote>Woof meow moo.</blockquote>",
"<blockquote>Foo bar&nbsp;baz.</blockquote><blockquote>Woof meow&nbsp;moo.</blockquote>");
+ fast_aleck_test(&test_case,
+ "<dd>Foo bar baz.</dd><dd>Woof meow moo.</dd>",
+ "<dd>Foo bar&nbsp;baz.</dd><dd>Woof meow&nbsp;moo.</dd>");
+
+ fast_aleck_test(&test_case,
+ "<dt>Foo bar baz.</dt><dt>Woof meow moo.</dt>",
+ "<dt>Foo bar&nbsp;baz.</dt><dt>Woof meow&nbsp;moo.</dt>");
+
test_case.widont = 0;
// WRAP CAPS TEST
@@ -424,13 +424,27 @@ char *fast_aleck(fast_aleck_config a_config, char *a_in, size_t a_in_size, size_
memcpy(out, "blockquote", 10);
out += 10;
}
+ else if (0 == strncmp(in, "dd", 2) && (isspace(*(in+2)) || *(in+2) == '>'))
+ {
+ _fa_handle_tag(&in, &out, &out_last_space, &is_at_start_of_run, &state, a_config);
+ in += 1;
+ memcpy(out, "dd", 2);
+ out += 2;
+ }
else if (0 == strncmp(in, "div", 3) && (isspace(*(in+3)) || *(in+3) == '>'))
{
_fa_handle_tag(&in, &out, &out_last_space, &is_at_start_of_run, &state, a_config);
in += 2;
memcpy(out, "div", 3);
out += 3;
}
+ else if (0 == strncmp(in, "dt", 2) && (isspace(*(in+2)) || *(in+2) == '>'))
+ {
+ _fa_handle_tag(&in, &out, &out_last_space, &is_at_start_of_run, &state, a_config);
+ in += 1;
+ memcpy(out, "dt", 2);
+ out += 2;
+ }
else if ('h' == *in && *(in+1) >= '1' && *(in+1) <= '6' && (isspace(*(in+2)) || *(in+2) == '>'))
{
_fa_handle_tag(&in, &out, &out_last_space, &is_at_start_of_run, &state, a_config);

0 comments on commit 7f0b053

Please sign in to comment.