diff options
| author | Simon Tatham <anakin@pobox.com> | 2000-11-22 20:11:48 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2000-11-22 20:11:48 +0000 |
| commit | cd4e3150d31094b1d20f5718bb0e2b1812ec3bb3 (patch) | |
| tree | df7195804dbabda2f8642b26335a98143f89d7bf /input.c | |
| parent | cc04717cb665d50d6843d9760a5cddf584ba126e (diff) | |
| download | halibut-cd4e3150d31094b1d20f5718bb0e2b1812ec3bb3.zip halibut-cd4e3150d31094b1d20f5718bb0e2b1812ec3bb3.tar.gz halibut-cd4e3150d31094b1d20f5718bb0e2b1812ec3bb3.tar.bz2 halibut-cd4e3150d31094b1d20f5718bb0e2b1812ec3bb3.tar.xz | |
Add nonbreaking space as \_
[originally from svn r810]
Diffstat (limited to 'input.c')
| -rw-r--r-- | input.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -163,6 +163,7 @@ enum { c__invalid, /* invalid command */ c__comment, /* comment command (\#) */ c__escaped, /* escaped character */ + c__nbsp, /* nonbreaking space */ c_A, /* appendix heading */ c_B, /* bibliography entry */ c_BR, /* bibliography rewrite */ @@ -238,6 +239,7 @@ static void match_kw(token *tok) { {"U", c_U}, /* unnumbered-chapter heading */ {"W", c_W}, /* Web hyperlink */ {"\\", c__escaped}, /* escaped backslash (\\) */ + {"_", c__nbsp}, /* nonbreaking space (\_) */ {"b", c_b}, /* bulletted list */ {"c", c_c}, /* code */ {"cfg", c_cfg}, /* configuration directive */ @@ -350,7 +352,8 @@ token get_token(input *in) { return ret; } else if (c == '\\') { /* tok_cmd */ c = get(in, &cpos); - if (c == '-' || c == '\\' || c == '#' || c == '{' || c == '}') { + if (c == '-' || c == '\\' || c == '_' || + c == '#' || c == '{' || c == '}') { /* single-char command */ rdadd(&rs, c); } else if (c == 'u') { @@ -654,8 +657,10 @@ static void read_file(paragraph ***ret, input *in, index *idx) { while (dtor(t), t = get_token(in), t.type == tok_word || t.type == tok_white || + (t.type == tok_cmd && t.cmd == c__nbsp) || (t.type == tok_cmd && t.cmd == c__escaped)) { - if (t.type == tok_white) + if (t.type == tok_white || + (t.type == tok_cmd && t.cmd == c__nbsp)) rdadd(&rs, ' '); else rdadds(&rs, t.text); @@ -742,6 +747,12 @@ static void read_file(paragraph ***ret, input *in, index *idx) { t.type = tok_word; /* nice and simple */ t.aux = 0; /* even if `\-' - nonbreaking! */ } + if (t.type == tok_cmd && t.cmd == c__nbsp) { + t.type = tok_word; /* nice and simple */ + sfree(t.text); + t.text = ustrdup(L" "); /* text is ` ' not `_' */ + t.aux = 0; /* (nonbreaking) */ + } switch (t.type) { case tok_white: if (whptr == &par.words) |