Fossil SCM

A triple grave accent quoted text (```....```) is rendered inside of <pre>...</pre>.

drh 2019-08-08 20:35 trunk
Commit 2077ffe660ec2bcd6cfa5f241b55a9bab8f7eb6f2e2921c8a6fa6b85603e1a1a
+3 -3
--- src/markdown.c
+++ src/markdown.c
@@ -67,11 +67,11 @@
6767
void *opaque);
6868
6969
/* span level callbacks - NULL or return 0 prints the span verbatim */
7070
int (*autolink)(struct Blob *ob, struct Blob *link,
7171
enum mkd_autolink type, void *opaque);
72
- int (*codespan)(struct Blob *ob, struct Blob *text, void *opaque);
72
+ int (*codespan)(struct Blob *ob, struct Blob *text, int nSep, void *opaque);
7373
int (*double_emphasis)(struct Blob *ob, struct Blob *text,
7474
char c, void *opaque);
7575
int (*emphasis)(struct Blob *ob, struct Blob *text, char c,void*opaque);
7676
int (*image)(struct Blob *ob, struct Blob *link, struct Blob *title,
7777
struct Blob *alt, void *opaque);
@@ -748,13 +748,13 @@
748748
749749
/* real code span */
750750
if( f_begin<f_end ){
751751
struct Blob work = BLOB_INITIALIZER;
752752
blob_init(&work, data+f_begin, f_end-f_begin);
753
- if( !rndr->make.codespan(ob, &work, rndr->make.opaque) ) end = 0;
753
+ if( !rndr->make.codespan(ob, &work, nb, rndr->make.opaque) ) end = 0;
754754
}else{
755
- if( !rndr->make.codespan(ob, 0, rndr->make.opaque) ) end = 0;
755
+ if( !rndr->make.codespan(ob, 0, nb, rndr->make.opaque) ) end = 0;
756756
}
757757
return end;
758758
}
759759
760760
761761
--- src/markdown.c
+++ src/markdown.c
@@ -67,11 +67,11 @@
67 void *opaque);
68
69 /* span level callbacks - NULL or return 0 prints the span verbatim */
70 int (*autolink)(struct Blob *ob, struct Blob *link,
71 enum mkd_autolink type, void *opaque);
72 int (*codespan)(struct Blob *ob, struct Blob *text, void *opaque);
73 int (*double_emphasis)(struct Blob *ob, struct Blob *text,
74 char c, void *opaque);
75 int (*emphasis)(struct Blob *ob, struct Blob *text, char c,void*opaque);
76 int (*image)(struct Blob *ob, struct Blob *link, struct Blob *title,
77 struct Blob *alt, void *opaque);
@@ -748,13 +748,13 @@
748
749 /* real code span */
750 if( f_begin<f_end ){
751 struct Blob work = BLOB_INITIALIZER;
752 blob_init(&work, data+f_begin, f_end-f_begin);
753 if( !rndr->make.codespan(ob, &work, rndr->make.opaque) ) end = 0;
754 }else{
755 if( !rndr->make.codespan(ob, 0, rndr->make.opaque) ) end = 0;
756 }
757 return end;
758 }
759
760
761
--- src/markdown.c
+++ src/markdown.c
@@ -67,11 +67,11 @@
67 void *opaque);
68
69 /* span level callbacks - NULL or return 0 prints the span verbatim */
70 int (*autolink)(struct Blob *ob, struct Blob *link,
71 enum mkd_autolink type, void *opaque);
72 int (*codespan)(struct Blob *ob, struct Blob *text, int nSep, void *opaque);
73 int (*double_emphasis)(struct Blob *ob, struct Blob *text,
74 char c, void *opaque);
75 int (*emphasis)(struct Blob *ob, struct Blob *text, char c,void*opaque);
76 int (*image)(struct Blob *ob, struct Blob *link, struct Blob *title,
77 struct Blob *alt, void *opaque);
@@ -748,13 +748,13 @@
748
749 /* real code span */
750 if( f_begin<f_end ){
751 struct Blob work = BLOB_INITIALIZER;
752 blob_init(&work, data+f_begin, f_end-f_begin);
753 if( !rndr->make.codespan(ob, &work, nb, rndr->make.opaque) ) end = 0;
754 }else{
755 if( !rndr->make.codespan(ob, 0, nb, rndr->make.opaque) ) end = 0;
756 }
757 return end;
758 }
759
760
761
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -325,15 +325,20 @@
325325
}
326326
BLOB_APPEND_LITERAL(ob, "</a>");
327327
return 1;
328328
}
329329
330
-static int html_code_span(struct Blob *ob, struct Blob *text, void *opaque){
330
+static int html_code_span(
331
+ struct Blob *ob,
332
+ struct Blob *text, /* The stuff in between the code span marks */
333
+ int nSep, /* Number of grave accents marks as delimiters */
334
+ void *opaque
335
+){
331336
if( text ){
332
- BLOB_APPEND_LITERAL(ob, "<code>");
337
+ blob_append(ob, nSep>=3 ? "<pre>" : "<code>", -1);
333338
html_escape(ob, blob_buffer(text), blob_size(text));
334
- BLOB_APPEND_LITERAL(ob, "</code>");
339
+ blob_append(ob, nSep>=3 ? "</pre>" : "</code>", -1);
335340
}
336341
return 1;
337342
}
338343
339344
static int html_double_emphasis(
340345
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -325,15 +325,20 @@
325 }
326 BLOB_APPEND_LITERAL(ob, "</a>");
327 return 1;
328 }
329
330 static int html_code_span(struct Blob *ob, struct Blob *text, void *opaque){
 
 
 
 
 
331 if( text ){
332 BLOB_APPEND_LITERAL(ob, "<code>");
333 html_escape(ob, blob_buffer(text), blob_size(text));
334 BLOB_APPEND_LITERAL(ob, "</code>");
335 }
336 return 1;
337 }
338
339 static int html_double_emphasis(
340
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -325,15 +325,20 @@
325 }
326 BLOB_APPEND_LITERAL(ob, "</a>");
327 return 1;
328 }
329
330 static int html_code_span(
331 struct Blob *ob,
332 struct Blob *text, /* The stuff in between the code span marks */
333 int nSep, /* Number of grave accents marks as delimiters */
334 void *opaque
335 ){
336 if( text ){
337 blob_append(ob, nSep>=3 ? "<pre>" : "<code>", -1);
338 html_escape(ob, blob_buffer(text), blob_size(text));
339 blob_append(ob, nSep>=3 ? "</pre>" : "</code>", -1);
340 }
341 return 1;
342 }
343
344 static int html_double_emphasis(
345

Keyboard Shortcuts

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