diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-14 14:09:13 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-14 14:09:13 +0000 |
commit | 2c007cf07ebf64bc30ad05e3d9ee10e333cfa60c (patch) | |
tree | 4a53a897ed8e547b4c357b69e649182d8da15c52 | |
parent | 7309f0de77a908a98032b0508c2d2b426c244099 (diff) | |
download | mandoc-2c007cf07ebf64bc30ad05e3d9ee10e333cfa60c.tar.gz |
Block-implicit macros now up-propogate end-of-sentence spacing. NOTE: GROFF IS NOT SMART ENOUGH TO DO THIS.
-rw-r--r-- | mandoc.c | 3 | ||||
-rw-r--r-- | mdoc_macro.c | 20 |
2 files changed, 22 insertions, 1 deletions
@@ -305,7 +305,8 @@ int mandoc_eos(const char *p, size_t sz) { - assert(sz); + if (0 == sz) + return(0); switch (p[(int)sz - 1]) { case ('.'): diff --git a/mdoc_macro.c b/mdoc_macro.c index 438c39a0..caf7637c 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -26,6 +26,7 @@ #include <time.h> #include "libmdoc.h" +#include "libmandoc.h" enum rew { REWIND_REWIND, @@ -1155,6 +1156,25 @@ blk_part_imp(MACRO_PROT_ARGS) body = m->last; } + for (n = body->child; n && n->next; n = n->next) + /* Do nothing. */ ; + + /* + * End of sentence spacing: if the last node is a text node and + * has a trailing period, then mark it as being end-of-sentence. + */ + + if (n && MDOC_TEXT == n->type && n->string) + if (mandoc_eos(n->string, strlen(n->string))) + n->flags |= MDOC_EOS; + + /* Up-propogate the end-of-space flag. */ + + if (n && (MDOC_EOS & n->flags)) { + body->flags |= MDOC_EOS; + body->parent->flags |= MDOC_EOS; + } + /* * If we can't rewind to our body, then our scope has already * been closed by another macro (like `Oc' closing `Op'). This |