Fossil

Diff
Login

Differences From Artifact [13fcec9f56]:

To Artifact [c2daecf6e2]:


1303
1304
1305
1306
1307
1308
1309

1310
1311
1312
1313
1314





1315
1316
1317
1318

1319
1320



1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331


1332

1333

1334
1335
1336
1337
1338
1339
1340
1303
1304
1305
1306
1307
1308
1309
1310





1311
1312
1313
1314
1315
1316
1317
1318
1319
1320


1321
1322
1323
1324
1325
1326
1327
1328
1329
1330

1331


1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344







+
-
-
-
-
-
+
+
+
+
+




+
-
-
+
+
+







-

-
-
+
+

+

+







static size_t char_link(
  struct Blob *ob,
  struct render *rndr,
  char *data,
  size_t offset,
  size_t size     /* parse_inline() ensures that size > 0 */
){
  const int bFsfn = (size>3 && data[1]=='^'); /*free-standing footnote ref*/
  const int is_img = (offset && data[-1] == '!');
  size_t i = 1, txt_e;
  struct Blob *content = 0;
  struct Blob *link = 0;
  struct Blob *title = 0;
  const int bImg = !bFsfn && (offset && data[-1] == '!');
  size_t i, txt_e;
  struct Blob *content;
  struct Blob *link;
  struct Blob *title;
  struct footnote fn;
  int ret;

  /* checking whether the correct renderer exists */
  if( !bFsfn ){
  if( (is_img && !rndr->make.image) || (!is_img && !rndr->make.link) ){
    return 0;
    if( (bImg && !rndr->make.image) || (!bImg && !rndr->make.link) ){
      return 0;
    }
  }

  /* looking for the matching closing bracket */
  txt_e = matching_bracket_offset(data, data+size);
  if( !txt_e ) return 0;
  i = txt_e + 1;
  ret = 0; /* error if we don't get to the callback */
  fn.nUsed = 0;

  /* free-standing footnote refernece */
  if(!is_img && size>3 && data[1]=='^'){
  /* free-standing footnote reference */
  if( bFsfn ){
    fn = get_footnote(rndr, data+2, txt_e-2);
    content = link = title = 0;
  }else{
    fn.nUsed = 0;

    /* skip "inter-bracket-whitespace" - any amount of whitespace or newline */
    /* (this is much more lax than original markdown syntax) */
    while( i<size && (data[i]==' ' || data[i]=='\t' || data[i]=='\n') ){ i++; }

    /* allocate temporary buffers to store content, link and title */
    title = new_work_buffer(rndr);
1397
1398
1399
1400
1401
1402
1403
1404

1405
1406
1407
1408
1409

1410
1411
1412
1413
1414
1415
1416
1401
1402
1403
1404
1405
1406
1407

1408
1409
1410
1411
1412

1413
1414
1415
1416
1417
1418
1419
1420







-
+




-
+







      }
      /* rewinding an "inter-bracket-whitespace" */
      i = txt_e+1;
    }
  }
  /* building content: img alt is escaped, link content is parsed */
  if( txt_e>1 && content ){
    if( is_img ) blob_append(content, data+1, txt_e-1);
    if( bImg ) blob_append(content, data+1, txt_e-1);
    else parse_inline(content, rndr, data+1, txt_e-1);
  }

  /* calling the relevant rendering function */
  if( is_img ){
  if( bImg ){
    if( blob_size(ob)>0 && blob_buffer(ob)[blob_size(ob)-1]=='!' ){
      ob->nUsed--;
    }
    ret = rndr->make.image(ob, link, title, content, rndr->make.opaque);
  }else if( fn.nUsed ){
    if( rndr->make.footnote_ref ){
      ret = rndr->make.footnote_ref(ob, content, &fn.upc, fn.iMark,