Fossil

Check-in [b3664365]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Simplify title determining code
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | commonmark-markdown
Files: files | file ages | folders
SHA3-256:b36643651c6fb6815fed43db9696f18245eb1223ee70d5aec0d8e3f0b31306a3
User & Date: mjanssen 2017-10-04 11:37:24
Context
2017-10-04
12:07
Don't duplicate title in body check-in: 5ab4db5a user: mpcjanssen tags: commonmark-markdown
11:37
Simplify title determining code check-in: b3664365 user: mjanssen tags: commonmark-markdown
10:59
Add support for markdown page titles check-in: 4a298e69 user: mjanssen tags: commonmark-markdown
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/markdown_html.c.

411
412
413
414
415
416
417

418
419
420
421
422
423

424
425
426
427
428
429
430
431
  blob_reset(output_body);
  char * markdown_string = blob_str(input_markdown);
  char *cmark_result = cmark_markdown_to_html(markdown_string, blob_size(input_markdown), 0 );
  if( output_title ) {
     blob_reset(output_title);
     if (strlen(markdown_string) > 0 && markdown_string[0] == '#' ) {
       if (strlen(markdown_string + 1) > 0) {

	 int i = 1;
	 while (markdown_string[i]!='\0' &&
		(markdown_string[i]!='\n' && markdown_string[i]!='\r') ) {
	   blob_append(output_title, markdown_string+i, 1);
	   i++;
	 }

       }
     }
  }
  html_prolog(output_body,0);
  blob_append(output_body, cmark_result, strlen(cmark_result));
  html_epilog(output_body,0);
  free(cmark_result);
}







>
|


<


>








411
412
413
414
415
416
417
418
419
420
421

422
423
424
425
426
427
428
429
430
431
432
  blob_reset(output_body);
  char * markdown_string = blob_str(input_markdown);
  char *cmark_result = cmark_markdown_to_html(markdown_string, blob_size(input_markdown), 0 );
  if( output_title ) {
     blob_reset(output_title);
     if (strlen(markdown_string) > 0 && markdown_string[0] == '#' ) {
       if (strlen(markdown_string + 1) > 0) {
	 char * title_start = markdown_string + 1;
	 int i = 0;
	 while (markdown_string[i]!='\0' &&
		(markdown_string[i]!='\n' && markdown_string[i]!='\r') ) {

	   i++;
	 }
	 blob_append(output_title, title_start, i);
       }
     }
  }
  html_prolog(output_body,0);
  blob_append(output_body, cmark_result, strlen(cmark_result));
  html_epilog(output_body,0);
  free(cmark_result);
}