Fossil SCM

Add an option to preserve newlines as hard line breaks on the www timeline display.

drh 2019-01-16 01:01 trunk
Commit 8af02551c5a71e05579843e414498fceffe8af83e341dc45a6ca74ac9e16a27d
--- src/printf.c
+++ src/printf.c
@@ -228,10 +228,13 @@
228228
}else{
229229
wikiFlags = WIKI_INLINE | WIKI_NOBLOCK | WIKI_NOBADLINKS;
230230
}
231231
if( db_get_boolean("timeline-plaintext", 0) ){
232232
wikiFlags |= WIKI_LINKSONLY;
233
+ }
234
+ if( db_get_boolean("timeline-hard-newlines", 0) ){
235
+ wikiFlags |= WIKI_NEWLINE;
233236
}
234237
}
235238
return wikiFlags;
236239
}
237240
238241
--- src/printf.c
+++ src/printf.c
@@ -228,10 +228,13 @@
228 }else{
229 wikiFlags = WIKI_INLINE | WIKI_NOBLOCK | WIKI_NOBADLINKS;
230 }
231 if( db_get_boolean("timeline-plaintext", 0) ){
232 wikiFlags |= WIKI_LINKSONLY;
 
 
 
233 }
234 }
235 return wikiFlags;
236 }
237
238
--- src/printf.c
+++ src/printf.c
@@ -228,10 +228,13 @@
228 }else{
229 wikiFlags = WIKI_INLINE | WIKI_NOBLOCK | WIKI_NOBADLINKS;
230 }
231 if( db_get_boolean("timeline-plaintext", 0) ){
232 wikiFlags |= WIKI_LINKSONLY;
233 }
234 if( db_get_boolean("timeline-hard-newlines", 0) ){
235 wikiFlags |= WIKI_NEWLINE;
236 }
237 }
238 return wikiFlags;
239 }
240
241
+10 -2
--- src/setup.c
+++ src/setup.c
@@ -692,14 +692,22 @@
692692
@ without any wiki or HTML interpretation. Use CSS to change
693693
@ display formatting features such as fonts and line-wrapping behavior.
694694
@ (Property: "timeline-plaintext")</p>
695695
696696
@ <hr />
697
- onoff_attribute("Truncate comment at first blank line",
697
+ onoff_attribute("Truncate comment at first blank line (Git-style)",
698698
"timeline-truncate-at-blank", "ttb", 0, 0);
699699
@ <p>In timeline displays, check-in comments are displayed only through
700
- @ the first blank line. (Property: "timeline-truncate-at-blank")</p>
700
+ @ the first blank line. This is the traditional way to display comments
701
+ @ in Git repositories (Property: "timeline-truncate-at-blank")</p>
702
+
703
+ @ <hr />
704
+ onoff_attribute("Break comments at newline characters",
705
+ "timeline-hard-newlines", "thnl", 0, 0);
706
+ @ <p>In timeline displays, newline characters in check-in comments force
707
+ @ a line break on the display.
708
+ @ (Property: "timeline-hard-newlines")</p>
701709
702710
@ <hr />
703711
onoff_attribute("Use Universal Coordinated Time (UTC)",
704712
"timeline-utc", "utc", 1, 0);
705713
@ <p>Show times as UTC (also sometimes called Greenwich Mean Time (GMT) or
706714
--- src/setup.c
+++ src/setup.c
@@ -692,14 +692,22 @@
692 @ without any wiki or HTML interpretation. Use CSS to change
693 @ display formatting features such as fonts and line-wrapping behavior.
694 @ (Property: "timeline-plaintext")</p>
695
696 @ <hr />
697 onoff_attribute("Truncate comment at first blank line",
698 "timeline-truncate-at-blank", "ttb", 0, 0);
699 @ <p>In timeline displays, check-in comments are displayed only through
700 @ the first blank line. (Property: "timeline-truncate-at-blank")</p>
 
 
 
 
 
 
 
 
701
702 @ <hr />
703 onoff_attribute("Use Universal Coordinated Time (UTC)",
704 "timeline-utc", "utc", 1, 0);
705 @ <p>Show times as UTC (also sometimes called Greenwich Mean Time (GMT) or
706
--- src/setup.c
+++ src/setup.c
@@ -692,14 +692,22 @@
692 @ without any wiki or HTML interpretation. Use CSS to change
693 @ display formatting features such as fonts and line-wrapping behavior.
694 @ (Property: "timeline-plaintext")</p>
695
696 @ <hr />
697 onoff_attribute("Truncate comment at first blank line (Git-style)",
698 "timeline-truncate-at-blank", "ttb", 0, 0);
699 @ <p>In timeline displays, check-in comments are displayed only through
700 @ the first blank line. This is the traditional way to display comments
701 @ in Git repositories (Property: "timeline-truncate-at-blank")</p>
702
703 @ <hr />
704 onoff_attribute("Break comments at newline characters",
705 "timeline-hard-newlines", "thnl", 0, 0);
706 @ <p>In timeline displays, newline characters in check-in comments force
707 @ a line break on the display.
708 @ (Property: "timeline-hard-newlines")</p>
709
710 @ <hr />
711 onoff_attribute("Use Universal Coordinated Time (UTC)",
712 "timeline-utc", "utc", 1, 0);
713 @ <p>Show times as UTC (also sometimes called Greenwich Mean Time (GMT) or
714
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -29,10 +29,11 @@
2929
#define WIKI_INLINE 0x002 /* Do not surround with <p>..</p> */
3030
#define WIKI_NOBLOCK 0x004 /* No block markup of any kind */
3131
#define WIKI_BUTTONS 0x008 /* Allow sub-menu buttons */
3232
#define WIKI_NOBADLINKS 0x010 /* Ignore broken hyperlinks */
3333
#define WIKI_LINKSONLY 0x020 /* No markup. Only decorate links */
34
+#define WIKI_NEWLINE 0x040 /* Honor \n - break lines at each \n */
3435
#endif
3536
3637
3738
/*
3839
** These are the only markup attributes allowed.
@@ -681,11 +682,11 @@
681682
if( z[0]=='\n' ){
682683
n = paragraphBreakLength(z);
683684
if( n>0 ){
684685
*pTokenType = TOKEN_PARAGRAPH;
685686
return n;
686
- }else if( fossil_isspace(z[1]) ){
687
+ }else{
687688
*pTokenType = TOKEN_NEWLINE;
688689
return 1;
689690
}
690691
}
691692
if( (p->state & AT_NEWLINE)!=0 && fossil_isspace(z[0]) ){
@@ -1379,11 +1380,15 @@
13791380
}
13801381
p->state |= AT_PARAGRAPH|AT_NEWLINE;
13811382
break;
13821383
}
13831384
case TOKEN_NEWLINE: {
1384
- blob_append(p->pOut, "\n", 1);
1385
+ if( p->renderFlags & WIKI_NEWLINE ){
1386
+ blob_append(p->pOut, "<br>\n", 5);
1387
+ }else{
1388
+ blob_append(p->pOut, "\n", 1);
1389
+ }
13851390
p->state |= AT_NEWLINE;
13861391
break;
13871392
}
13881393
case TOKEN_BUL_LI: {
13891394
if( inlineOnly ){
13901395
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -29,10 +29,11 @@
29 #define WIKI_INLINE 0x002 /* Do not surround with <p>..</p> */
30 #define WIKI_NOBLOCK 0x004 /* No block markup of any kind */
31 #define WIKI_BUTTONS 0x008 /* Allow sub-menu buttons */
32 #define WIKI_NOBADLINKS 0x010 /* Ignore broken hyperlinks */
33 #define WIKI_LINKSONLY 0x020 /* No markup. Only decorate links */
 
34 #endif
35
36
37 /*
38 ** These are the only markup attributes allowed.
@@ -681,11 +682,11 @@
681 if( z[0]=='\n' ){
682 n = paragraphBreakLength(z);
683 if( n>0 ){
684 *pTokenType = TOKEN_PARAGRAPH;
685 return n;
686 }else if( fossil_isspace(z[1]) ){
687 *pTokenType = TOKEN_NEWLINE;
688 return 1;
689 }
690 }
691 if( (p->state & AT_NEWLINE)!=0 && fossil_isspace(z[0]) ){
@@ -1379,11 +1380,15 @@
1379 }
1380 p->state |= AT_PARAGRAPH|AT_NEWLINE;
1381 break;
1382 }
1383 case TOKEN_NEWLINE: {
1384 blob_append(p->pOut, "\n", 1);
 
 
 
 
1385 p->state |= AT_NEWLINE;
1386 break;
1387 }
1388 case TOKEN_BUL_LI: {
1389 if( inlineOnly ){
1390
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -29,10 +29,11 @@
29 #define WIKI_INLINE 0x002 /* Do not surround with <p>..</p> */
30 #define WIKI_NOBLOCK 0x004 /* No block markup of any kind */
31 #define WIKI_BUTTONS 0x008 /* Allow sub-menu buttons */
32 #define WIKI_NOBADLINKS 0x010 /* Ignore broken hyperlinks */
33 #define WIKI_LINKSONLY 0x020 /* No markup. Only decorate links */
34 #define WIKI_NEWLINE 0x040 /* Honor \n - break lines at each \n */
35 #endif
36
37
38 /*
39 ** These are the only markup attributes allowed.
@@ -681,11 +682,11 @@
682 if( z[0]=='\n' ){
683 n = paragraphBreakLength(z);
684 if( n>0 ){
685 *pTokenType = TOKEN_PARAGRAPH;
686 return n;
687 }else{
688 *pTokenType = TOKEN_NEWLINE;
689 return 1;
690 }
691 }
692 if( (p->state & AT_NEWLINE)!=0 && fossil_isspace(z[0]) ){
@@ -1379,11 +1380,15 @@
1380 }
1381 p->state |= AT_PARAGRAPH|AT_NEWLINE;
1382 break;
1383 }
1384 case TOKEN_NEWLINE: {
1385 if( p->renderFlags & WIKI_NEWLINE ){
1386 blob_append(p->pOut, "<br>\n", 5);
1387 }else{
1388 blob_append(p->pOut, "\n", 1);
1389 }
1390 p->state |= AT_NEWLINE;
1391 break;
1392 }
1393 case TOKEN_BUL_LI: {
1394 if( inlineOnly ){
1395

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button