diff options
| -rw-r--r-- | input.c | 15 | ||||
| -rw-r--r-- | inputs/test.but | 5 | ||||
| -rw-r--r-- | misc/buttress.sl | 2 |
3 files changed, 18 insertions, 4 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) diff --git a/inputs/test.but b/inputs/test.but index 57844ab..44d710e 100644 --- a/inputs/test.but +++ b/inputs/test.but @@ -13,7 +13,7 @@ a bit] \define{coopt} co\u00F6{-o}pt -\versionid $Id: test.but,v 1.10 1999/11/07 16:14:23 simon Exp $ +\versionid $Id: test.but,v 1.11 2000/11/22 20:11:48 simon Exp $ \C{ch\\ap} First chapter title @@ -63,6 +63,9 @@ A-paragraph-full-of-hyphens-to-test-the-idea-that-word-wrapping-can-happen-somew A\-paragraph\-full\-of\-nonbreaking\-hyphens to\-test\-the\-idea\-that\-word\-wrapping\-misses\-them. +A\_paragraph\_full\_of\_nonbreaking\_spaces +to\_test\_the\_idea\_that\_word\_wrapping\_misses\_them\_too. + Use of macros: let's talk about \coopt. And about \coopt some more. And a nested macro: \metacoopt. diff --git a/misc/buttress.sl b/misc/buttress.sl index 0d7e207..1a88515 100644 --- a/misc/buttress.sl +++ b/misc/buttress.sl @@ -13,7 +13,7 @@ set_syntax_flags ($1, 8); %enable_highlight_cache ("buttress.dfa", $1); define_highlight_rule ("\\\\#.*$", "comment", $1); define_highlight_rule ("^\\\\c([ \t].*)?$", "string", $1); -define_highlight_rule ("\\\\[\\\\{}]", "keyword0", $1); +define_highlight_rule ("\\\\[\\\\{}\\-_]", "keyword0", $1); define_highlight_rule ("\\\\[A-Za-tv-z][A-Za-z0-9]*", "keyword0", $1); define_highlight_rule ("\\\\u[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]", "keyword0", $1); |