summaryrefslogtreecommitdiff
path: root/bk_info.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2013-03-10 16:58:01 +0000
committerSimon Tatham <anakin@pobox.com>2013-03-10 16:58:01 +0000
commitdcf080aa0e011de37a154e9e8a97dd7546a4a1b1 (patch)
tree891d703334a6d4f4899f058234c52d56cb7bdb3b /bk_info.c
parent1489dc15967970576d08f3f2b22c6e1c939bcbcf (diff)
downloadhalibut-dcf080aa0e011de37a154e9e8a97dd7546a4a1b1.zip
halibut-dcf080aa0e011de37a154e9e8a97dd7546a4a1b1.tar.gz
halibut-dcf080aa0e011de37a154e9e8a97dd7546a4a1b1.tar.bz2
halibut-dcf080aa0e011de37a154e9e8a97dd7546a4a1b1.tar.xz
Add \s for 'strong' text, i.e. bold rather than italics. I've missed
this a couple of times in Halibut markup recently (in particular, it's handy to have a typographical distinction between 'this term is emphasised because it's new' and 'this term is emphasised because I want you to pay attention to it'), so here's an implementation, basically parallel to \e. One slight oddity is that strong text in headings will not be distinguished in some output formats, since they already use bolded text for their headings. [originally from svn r9772]
Diffstat (limited to 'bk_info.c')
-rw-r--r--bk_info.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/bk_info.c b/bk_info.c
index 69cd1e2..1c6e033 100644
--- a/bk_info.c
+++ b/bk_info.c
@@ -69,6 +69,7 @@ typedef struct {
int nasect;
wchar_t *bullet, *listsuffix;
wchar_t *startemph, *endemph;
+ wchar_t *startstrong, *endstrong;
wchar_t *lquote, *rquote;
wchar_t *sectsuffix;
wchar_t *rule;
@@ -143,6 +144,8 @@ static infoconfig info_configure(paragraph *source) {
ret.rule = L"\x2500\0-\0\0";
ret.startemph = L"_\0_\0\0";
ret.endemph = uadv(ret.startemph);
+ ret.startstrong = L"*\0*\0\0";
+ ret.endstrong = uadv(ret.startstrong);
ret.lquote = L"\x2018\0\x2019\0`\0'\0\0";
ret.rquote = uadv(ret.lquote);
ret.sectsuffix = L": ";
@@ -233,6 +236,11 @@ static infoconfig info_configure(paragraph *source) {
ret.startemph = uadv(p->keyword);
ret.endemph = uadv(ret.startemph);
}
+ } else if (!ustricmp(p->keyword, L"info-strong")) {
+ if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) {
+ ret.startstrong = uadv(p->keyword);
+ ret.endstrong = uadv(ret.startstrong);
+ }
} else if (!ustricmp(p->keyword, L"info-quotes")) {
if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) {
ret.lquote = uadv(p->keyword);
@@ -260,6 +268,13 @@ static infoconfig info_configure(paragraph *source) {
ret.endemph = uadv(ret.startemph);
}
+ while (*uadv(ret.endstrong) && *uadv(uadv(ret.endstrong)) &&
+ (!cvt_ok(ret.charset, ret.startstrong) ||
+ !cvt_ok(ret.charset, ret.endstrong))) {
+ ret.startstrong = uadv(ret.endstrong);
+ ret.endstrong = uadv(ret.startstrong);
+ }
+
while (*ret.atitle.underline && *uadv(ret.atitle.underline) &&
!cvt_ok(ret.charset, ret.atitle.underline))
ret.atitle.underline = uadv(ret.atitle.underline);
@@ -861,14 +876,17 @@ static int info_rdaddwc(info_data *id, word *words, word *end, int xrefs,
case word_Normal:
case word_Emph:
+ case word_Strong:
case word_Code:
case word_WeakCode:
case word_WhiteSpace:
case word_EmphSpace:
+ case word_StrongSpace:
case word_CodeSpace:
case word_WkCodeSpace:
case word_Quote:
case word_EmphQuote:
+ case word_StrongQuote:
case word_CodeQuote:
case word_WkCodeQuote:
assert(words->type != word_CodeQuote &&
@@ -877,6 +895,10 @@ static int info_rdaddwc(info_data *id, word *words, word *end, int xrefs,
(attraux(words->aux) == attr_First ||
attraux(words->aux) == attr_Only))
ret += info_rdadds(id, cfg->startemph);
+ else if (towordstyle(words->type) == word_Strong &&
+ (attraux(words->aux) == attr_First ||
+ attraux(words->aux) == attr_Only))
+ ret += info_rdadds(id, cfg->startstrong);
else if (towordstyle(words->type) == word_Code &&
(attraux(words->aux) == attr_First ||
attraux(words->aux) == attr_Only))
@@ -896,6 +918,10 @@ static int info_rdaddwc(info_data *id, word *words, word *end, int xrefs,
(attraux(words->aux) == attr_Last ||
attraux(words->aux) == attr_Only))
ret += info_rdadds(id, cfg->endemph);
+ else if (towordstyle(words->type) == word_Strong &&
+ (attraux(words->aux) == attr_Last ||
+ attraux(words->aux) == attr_Only))
+ ret += info_rdadds(id, cfg->endstrong);
else if (towordstyle(words->type) == word_Code &&
(attraux(words->aux) == attr_Last ||
attraux(words->aux) == attr_Only))
@@ -956,22 +982,25 @@ static int info_width_internal(word *words, int xrefs, infoconfig *cfg) {
wid = 0;
attr = towordstyle(words->type);
- if (attr == word_Emph || attr == word_Code) {
+ if (attr == word_Emph || attr == word_Strong || attr == word_Code) {
if (attraux(words->aux) == attr_Only ||
attraux(words->aux) == attr_First)
- wid += ustrwid(attr == word_Emph ? cfg->startemph : cfg->lquote,
- cfg->charset);
+ wid += ustrwid(attr == word_Emph ? cfg->startemph :
+ attr == word_Strong ? cfg->startstrong :
+ cfg->lquote, cfg->charset);
}
- if (attr == word_Emph || attr == word_Code) {
+ if (attr == word_Emph || attr == word_Strong || attr == word_Code) {
if (attraux(words->aux) == attr_Only ||
attraux(words->aux) == attr_Last)
- wid += ustrwid(attr == word_Emph ? cfg->startemph : cfg->lquote,
- cfg->charset);
+ wid += ustrwid(attr == word_Emph ? cfg->startemph :
+ attr == word_Strong ? cfg->startstrong :
+ cfg->lquote, cfg->charset);
}
switch (words->type) {
case word_Normal:
case word_Emph:
+ case word_Strong:
case word_Code:
case word_WeakCode:
if (cvt_ok(cfg->charset, words->text) || !words->alt)
@@ -982,10 +1011,12 @@ static int info_width_internal(word *words, int xrefs, infoconfig *cfg) {
case word_WhiteSpace:
case word_EmphSpace:
+ case word_StrongSpace:
case word_CodeSpace:
case word_WkCodeSpace:
case word_Quote:
case word_EmphQuote:
+ case word_StrongQuote:
case word_CodeQuote:
case word_WkCodeQuote:
assert(words->type != word_CodeQuote &&