0000: 0d 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 ..#include <stdi
0010: 6f 2e 68 3e 0d 0a 23 69 6e 63 6c 75 64 65 20 3c o.h>..#include <
0020: 73 74 64 6c 69 62 2e 68 3e 0d 0a 23 69 6e 63 6c stdlib.h>..#incl
0030: 75 64 65 20 22 6d 61 72 6b 64 6f 77 6e 2e 68 22 ude "markdown.h"
0040: 0d 0a 20 20 0d 0a 0d 0a 20 20 0d 0a 2f 2f 20 76 .. .... ..// v
0050: 6f 69 64 20 70 72 6f 63 65 73 73 5f 6d 61 72 6b oid process_mark
0060: 64 6f 77 6e 28 29 0d 0a 2f 2f 20 7b 0d 0a 2f 2f down()..// {..//
0070: 20 20 20 4d 79 54 53 63 68 61 72 26 20 66 69 6c MyTSchar& fil
0080: 65 4e 61 6d 65 3b 0d 0a 2f 2f 20 20 20 0d 0a 2f eName;..// ../
0090: 2f 20 20 20 0d 0a 2f 2f 20 20 20 54 63 6c 5f 4f / ..// Tcl_O
00a0: 62 6a 2a 20 72 65 61 64 4f 62 6a 50 74 72 3d 54 bj* readObjPtr=T
00b0: 63 6c 5f 4e 65 77 4f 62 6a 28 29 3b 0d 0a 2f 2f cl_NewObj();..//
00c0: 20 20 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 20 63 Tcl_Channel c
00d0: 68 61 6e 6e 65 6c 3d 54 63 6c 5f 4f 70 65 6e 46 hannel=Tcl_OpenF
00e0: 69 6c 65 43 68 61 6e 6e 65 6c 28 73 74 61 74 65 ileChannel(state
00f0: 4d 2e 69 70 5f 2c 66 69 6c 65 4e 61 6d 65 2e 76 M.ip_,fileName.v
0100: 28 29 2c 22 72 22 2c 30 29 3b 0d 0a 2f 2f 20 20 (),"r",0);..//
0110: 20 69 66 28 21 63 68 61 6e 6e 65 6c 29 7b 0d 0a if(!channel){..
0120: 2f 2f 20 20 20 20 20 72 65 74 75 72 6e 20 63 75 // return cu
0130: 5f 70 72 69 6e 74 5f 65 72 72 6f 72 28 73 74 61 _print_error(sta
0140: 74 65 4d 2e 69 70 5f 2c 22 43 6f 75 6c 64 20 6e teM.ip_,"Could n
0150: 6f 74 20 6f 70 65 6e 20 66 69 6c 65 20 27 25 73 ot open file '%s
0160: 27 22 2c 66 69 6c 65 4e 61 6d 65 2e 76 28 29 29 '",fileName.v())
0170: 3b 0d 0a 2f 2f 20 20 20 7d 0d 0a 2f 2f 20 20 20 ;..// }..//
0180: 54 63 6c 5f 53 65 74 43 68 61 6e 6e 65 6c 4f 70 Tcl_SetChannelOp
0190: 74 69 6f 6e 28 73 74 61 74 65 4d 2e 69 70 5f 2c tion(stateM.ip_,
01a0: 63 68 61 6e 6e 65 6c 2c 22 2d 65 6e 63 6f 64 69 channel,"-encodi
01b0: 6e 67 22 2c 22 75 74 66 2d 38 22 29 3b 0d 0a 2f ng","utf-8");../
01c0: 2f 20 20 20 54 63 6c 5f 52 65 61 64 43 68 61 72 / Tcl_ReadChar
01d0: 73 28 63 68 61 6e 6e 65 6c 2c 72 65 61 64 4f 62 s(channel,readOb
01e0: 6a 50 74 72 2c 32 30 30 30 2c 30 29 3b 0d 0a 2f jPtr,2000,0);../
01f0: 2f 20 20 20 63 68 61 72 2a 20 74 62 75 66 3d 28 / char* tbuf=(
0200: 63 68 61 72 2a 29 54 63 6c 5f 47 65 74 53 74 72 char*)Tcl_GetStr
0210: 69 6e 67 46 72 6f 6d 4f 62 6a 28 72 65 61 64 4f ingFromObj(readO
0220: 62 6a 50 74 72 2c 26 6c 65 6e 67 74 68 29 3b 0d bjPtr,&length);.
0230: 0a 2f 2f 20 20 20 72 65 73 75 6c 74 3d 54 63 6c .// result=Tcl
0240: 5f 43 6c 6f 73 65 28 73 74 61 74 65 4d 2e 69 70 _Close(stateM.ip
0250: 5f 2c 63 68 61 6e 6e 65 6c 29 3b 0d 0a 2f 2f 20 _,channel);..//
0260: 0d 0a 2f 2f 20 20 20 54 63 6c 5f 44 65 63 72 52 ..// Tcl_DecrR
0270: 65 66 43 6f 75 6e 74 28 72 65 61 64 4f 62 6a 50 efCount(readObjP
0280: 74 72 29 3b 0d 0a 2f 2f 20 20 20 72 65 74 75 72 tr);..// retur
0290: 6e 20 30 3b 0d 0a 2f 2f 20 7d 0d 0a 0d 0a 69 6e n 0;..// }....in
02a0: 6c 69 6e 65 20 69 6e 74 20 69 73 5f 63 68 61 72 line int is_char
02b0: 73 28 69 6e 74 20 6d 79 63 68 61 72 2c 63 6f 6e s(int mychar,con
02c0: 73 74 20 63 68 61 72 2a 20 63 68 61 72 73 29 0d st char* chars).
02d0: 0a 7b 0d 0a 20 20 72 65 74 75 72 6e 20 73 74 72 .{.. return str
02e0: 63 68 72 28 63 68 61 72 73 2c 6d 79 63 68 61 72 chr(chars,mychar
02f0: 29 21 3d 4e 55 4c 4c 3b 0d 0a 7d 0d 0a 0d 0a 69 )!=NULL;..}....i
0300: 6e 6c 69 6e 65 20 69 6e 74 20 69 73 5f 73 61 6d nline int is_sam
0310: 65 5f 63 68 61 72 5f 6c 69 6e 65 28 4d 79 54 53 e_char_line(MyTS
0320: 63 68 61 72 26 20 62 75 66 66 65 72 2c 69 6e 74 char& buffer,int
0330: 20 73 74 61 72 74 2c 69 6e 74 20 65 6e 64 2c 0d start,int end,.
0340: 0a 20 20 69 6e 74 20 61 6c 6c 6f 77 5f 73 70 61 . int allow_spa
0350: 63 65 73 2c 69 6e 74 20 6d 69 6e 5f 63 68 61 72 ces,int min_char
0360: 73 29 0d 0a 7b 0d 0a 20 20 69 6e 74 20 6e 75 6d s)..{.. int num
0370: 5f 63 68 61 72 73 3d 31 3b 0d 0a 20 20 66 6f 72 _chars=1;.. for
0380: 28 69 6e 74 20 69 3d 73 74 61 72 74 2b 31 3b 69 (int i=start+1;i
0390: 3c 65 6e 64 3b 69 2b 2b 29 7b 0d 0a 20 20 20 20 <end;i++){..
03a0: 69 66 28 69 73 5f 63 68 61 72 73 28 62 75 66 66 if(is_chars(buff
03b0: 65 72 5b 69 5d 2c 22 20 5c 74 22 29 29 7b 0d 0a er[i]," \t")){..
03c0: 20 20 20 20 20 20 69 66 28 61 6c 6c 6f 77 5f 73 if(allow_s
03d0: 70 61 63 65 73 3d 3d 30 29 20 72 65 74 75 72 6e paces==0) return
03e0: 20 30 3b 0d 0a 20 20 20 20 7d 20 65 6c 73 65 20 0;.. } else
03f0: 69 66 28 62 75 66 66 65 72 5b 69 5d 21 3d 62 75 if(buffer[i]!=bu
0400: 66 66 65 72 5b 73 74 61 72 74 5d 29 7b 0d 0a 20 ffer[start]){..
0410: 20 20 20 20 20 72 65 74 75 72 6e 20 30 3b 0d 0a return 0;..
0420: 20 20 20 20 7d 20 65 6c 73 65 20 7b 0d 0a 20 20 } else {..
0430: 20 20 20 20 6e 75 6d 5f 63 68 61 72 73 2b 2b 3b num_chars++;
0440: 20 0d 0a 20 20 20 20 7d 0d 0a 20 20 7d 0d 0a 20 .. }.. }..
0450: 20 69 66 28 6e 75 6d 5f 63 68 61 72 73 3e 3d 6d if(num_chars>=m
0460: 69 6e 5f 63 68 61 72 73 29 20 72 65 74 75 72 6e in_chars) return
0470: 20 31 3b 0d 0a 20 20 65 6c 73 65 20 72 65 74 75 1;.. else retu
0480: 72 6e 20 30 3b 0d 0a 7d 0d 0a 0d 0a 69 6e 6c 69 rn 0;..}....inli
0490: 6e 65 20 69 6e 74 20 6e 75 6d 5f 73 61 6d 65 5f ne int num_same_
04a0: 63 68 61 72 5f 6c 69 6e 65 5f 70 72 65 66 69 78 char_line_prefix
04b0: 28 4d 79 54 53 63 68 61 72 26 20 62 75 66 66 65 (MyTSchar& buffe
04c0: 72 2c 69 6e 74 20 73 74 61 72 74 2c 69 6e 74 20 r,int start,int
04d0: 65 6e 64 2c 0d 0a 20 20 69 6e 74 20 61 6c 6c 6f end,.. int allo
04e0: 77 5f 73 70 61 63 65 73 29 0d 0a 7b 0d 0a 20 20 w_spaces)..{..
04f0: 69 6e 74 20 6e 75 6d 5f 63 68 61 72 73 3d 31 3b int num_chars=1;
0500: 0d 0a 20 20 66 6f 72 28 69 6e 74 20 69 3d 73 74 .. for(int i=st
0510: 61 72 74 2b 31 3b 69 3c 65 6e 64 3b 69 2b 2b 29 art+1;i<end;i++)
0520: 7b 0d 0a 20 20 20 20 69 66 28 69 73 5f 63 68 61 {.. if(is_cha
0530: 72 73 28 62 75 66 66 65 72 5b 69 5d 2c 22 20 5c rs(buffer[i]," \
0540: 74 22 29 29 7b 0d 0a 20 20 20 20 20 20 69 66 28 t")){.. if(
0550: 61 6c 6c 6f 77 5f 73 70 61 63 65 73 3d 3d 30 29 allow_spaces==0)
0560: 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 7d 20 65 break;.. } e
0570: 6c 73 65 20 69 66 28 62 75 66 66 65 72 5b 69 5d lse if(buffer[i]
0580: 21 3d 62 75 66 66 65 72 5b 73 74 61 72 74 5d 29 !=buffer[start])
0590: 7b 0d 0a 20 20 20 20 20 20 62 72 65 61 6b 3b 0d {.. break;.
05a0: 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b 0d 0a 20 . } else {..
05b0: 20 20 20 20 20 6e 75 6d 5f 63 68 61 72 73 2b 2b num_chars++
05c0: 3b 20 0d 0a 20 20 20 20 7d 0d 0a 20 20 7d 0d 0a ; .. }.. }..
05d0: 20 20 72 65 74 75 72 6e 20 6e 75 6d 5f 63 68 61 return num_cha
05e0: 72 73 3b 0d 0a 7d 0d 0a 0d 0a 69 6e 6c 69 6e 65 rs;..}....inline
05f0: 20 69 6e 74 20 6c 69 6e 6b 5f 6c 61 62 65 6c 5f int link_label_
0600: 6e 75 6d 28 4d 79 54 53 63 68 61 72 26 20 62 75 num(MyTSchar& bu
0610: 66 66 65 72 2c 69 6e 74 20 73 74 61 72 74 29 0d ffer,int start).
0620: 0a 7b 0d 0a 20 20 69 6e 74 20 69 73 5f 6f 70 65 .{.. int is_ope
0630: 6e 3d 30 2c 6e 75 6d 5f 63 68 61 72 73 3d 30 3b n=0,num_chars=0;
0640: 0d 0a 20 20 66 6f 72 28 69 6e 74 20 69 3d 73 74 .. for(int i=st
0650: 61 72 74 3b 69 3c 62 75 66 66 65 72 2e 6e 75 6d art;i<buffer.num
0660: 28 29 3b 69 2b 2b 29 7b 0d 0a 20 20 20 20 69 66 ();i++){.. if
0670: 28 69 73 5f 63 68 61 72 73 28 62 75 66 66 65 72 (is_chars(buffer
0680: 5b 69 5d 2c 22 20 5c 74 22 29 29 7b 0d 0a 20 20 [i]," \t")){..
0690: 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 20 continue;..
06a0: 20 20 20 7d 20 65 6c 73 65 20 69 66 28 69 73 5f } else if(is_
06b0: 63 68 61 72 73 28 62 75 66 66 65 72 5b 69 5d 2c chars(buffer[i],
06c0: 22 5c 72 5c 6e 22 29 29 7b 0d 0a 20 20 20 20 20 "\r\n")){..
06d0: 20 72 65 74 75 72 6e 20 30 3b 0d 0a 20 20 20 20 return 0;..
06e0: 7d 20 65 6c 73 65 20 69 66 28 69 73 5f 63 68 61 } else if(is_cha
06f0: 72 73 28 62 75 66 66 65 72 5b 69 5d 2c 22 5b 22 rs(buffer[i],"["
0700: 29 29 7b 0d 0a 20 20 20 20 20 20 69 66 28 21 69 )){.. if(!i
0710: 73 5f 6f 70 65 6e 29 20 69 73 5f 6f 70 65 6e 3d s_open) is_open=
0720: 31 3b 0d 0a 20 20 20 20 20 20 65 6c 73 65 20 72 1;.. else r
0730: 65 74 75 72 6e 20 30 3b 0d 0a 20 20 20 20 7d 20 eturn 0;.. }
0740: 65 6c 73 65 20 69 66 28 69 73 5f 63 68 61 72 73 else if(is_chars
0750: 28 62 75 66 66 65 72 5b 69 5d 2c 22 5d 22 29 29 (buffer[i],"]"))
0760: 7b 0d 0a 20 20 20 20 20 20 69 66 28 6e 75 6d 5f {.. if(num_
0770: 63 68 61 72 73 3d 3d 30 29 20 72 65 74 75 72 6e chars==0) return
0780: 20 30 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 0;.. retur
0790: 6e 20 69 3b 0d 0a 20 20 20 20 7d 20 65 6c 73 65 n i;.. } else
07a0: 20 69 66 28 69 73 5f 63 68 61 72 73 28 62 75 66 if(is_chars(buf
07b0: 66 65 72 5b 69 5d 2c 22 5c 5c 22 29 29 7b 0d 0a fer[i],"\\")){..
07c0: 20 20 20 20 20 20 6e 75 6d 5f 63 68 61 72 73 2b num_chars+
07d0: 2b 3b 0d 0a 20 20 20 20 20 20 69 2b 2b 3b 0d 0a +;.. i++;..
07e0: 20 20 20 20 7d 20 65 6c 73 65 20 7b 0d 0a 20 20 } else {..
07f0: 20 20 20 20 6e 75 6d 5f 63 68 61 72 73 2b 2b 3b num_chars++;
0800: 0d 0a 20 20 20 20 7d 0d 0a 20 20 7d 0d 0a 20 20 .. }.. }..
0810: 72 65 74 75 72 6e 20 30 3b 0d 0a 7d 0d 0a 0d 0a return 0;..}....
0820: 69 6e 6c 69 6e 65 20 69 6e 74 20 6c 69 6e 6b 5f inline int link_
0830: 64 65 73 74 69 6e 61 74 69 6f 6e 5f 6e 75 6d 28 destination_num(
0840: 4d 79 54 53 63 68 61 72 26 20 62 75 66 66 65 72 MyTSchar& buffer
0850: 2c 69 6e 74 20 73 74 61 72 74 29 0d 0a 7b 0d 0a ,int start)..{..
0860: 20 20 69 6e 74 20 69 73 5f 6f 70 65 6e 3d 30 2c int is_open=0,
0870: 6e 75 6d 5f 65 6e 64 6c 69 6e 65 73 3d 30 2c 73 num_endlines=0,s
0880: 6d 61 6c 6c 65 72 5f 74 68 61 6e 3d 30 2c 70 61 maller_than=0,pa
0890: 72 65 6e 74 68 65 73 65 73 3d 30 3b 0d 0a 20 20 rentheses=0;..
08a0: 0d 0a 20 20 66 6f 72 28 69 6e 74 20 69 3d 73 74 .. for(int i=st
08b0: 61 72 74 3b 69 3c 62 75 66 66 65 72 2e 6e 75 6d art;i<buffer.num
08c0: 28 29 3b 69 2b 2b 29 7b 0d 0a 20 20 20 20 69 66 ();i++){.. if
08d0: 28 69 73 5f 63 68 61 72 73 28 62 75 66 66 65 72 (is_chars(buffer
08e0: 5b 69 5d 2c 22 20 5c 74 22 29 29 7b 0d 0a 20 20 [i]," \t")){..
08f0: 20 20 20 20 69 66 28 69 73 5f 6f 70 65 6e 20 26 if(is_open &
0900: 26 20 73 6d 61 6c 6c 65 72 5f 74 68 61 6e 3d 3d & smaller_than==
0910: 30 29 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 28 0){.. if(
0920: 70 61 72 65 6e 74 68 65 73 65 73 29 20 72 65 74 parentheses) ret
0930: 75 72 6e 20 30 3b 0d 0a 20 20 20 20 20 20 20 20 urn 0;..
0940: 72 65 74 75 72 6e 20 69 3b 0d 0a 20 20 20 20 20 return i;..
0950: 20 7d 0d 0a 20 20 20 20 20 20 63 6f 6e 74 69 6e }.. contin
0960: 75 65 3b 0d 0a 20 20 20 20 7d 20 65 6c 73 65 20 ue;.. } else
0970: 69 66 28 69 73 5f 63 68 61 72 73 28 62 75 66 66 if(is_chars(buff
0980: 65 72 5b 69 5d 2c 22 5c 72 5c 6e 22 29 29 7b 0d er[i],"\r\n")){.
0990: 0a 20 20 20 20 20 20 69 66 28 21 69 73 5f 6f 70 . if(!is_op
09a0: 65 6e 29 7b 0d 0a 20 20 20 20 20 20 20 20 6e 75 en){.. nu
09b0: 6d 5f 65 6e 64 6c 69 6e 65 73 2b 2b 3b 0d 0a 20 m_endlines++;..
09c0: 20 20 20 20 20 20 20 69 66 28 6e 75 6d 5f 65 6e if(num_en
09d0: 64 6c 69 6e 65 73 3e 31 29 20 72 65 74 75 72 6e dlines>1) return
09e0: 20 30 3b 0d 0a 20 20 20 20 20 20 7d 20 65 6c 73 0;.. } els
09f0: 65 20 69 66 28 73 6d 61 6c 6c 65 72 5f 74 68 61 e if(smaller_tha
0a00: 6e 3d 3d 30 29 7b 0d 0a 20 20 20 20 20 20 20 20 n==0){..
0a10: 69 66 28 70 61 72 65 6e 74 68 65 73 65 73 29 20 if(parentheses)
0a20: 72 65 74 75 72 6e 20 30 3b 20 0d 0a 20 20 20 20 return 0; ..
0a30: 20 20 20 20 72 65 74 75 72 6e 20 69 3b 0d 0a 20 return i;..
0a40: 20 20 20 20 20 7d 20 65 6c 73 65 20 72 65 74 75 } else retu
0a50: 72 6e 20 30 3b 0d 0a 20 20 20 20 7d 20 65 6c 73 rn 0;.. } els
0a60: 65 20 69 66 28 69 73 5f 63 68 61 72 73 28 62 75 e if(is_chars(bu
0a70: 66 66 65 72 5b 69 5d 2c 22 3c 22 29 29 7b 0d 0a ffer[i],"<")){..
0a80: 20 20 20 20 20 20 69 66 28 21 69 73 5f 6f 70 65 if(!is_ope
0a90: 6e 29 7b 0d 0a 20 20 20 20 20 20 20 20 69 73 5f n){.. is_
0aa0: 6f 70 65 6e 3d 31 3b 0d 0a 20 20 20 20 20 20 20 open=1;..
0ab0: 20 73 6d 61 6c 6c 65 72 5f 74 68 61 6e 3d 31 3b smaller_than=1;
0ac0: 0d 0a 20 20 20 20 20 20 7d 20 65 6c 73 65 20 69 .. } else i
0ad0: 66 28 73 6d 61 6c 6c 65 72 5f 74 68 61 6e 3e 30 f(smaller_than>0
0ae0: 29 7b 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 ){.. retu
0af0: 72 6e 20 30 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a rn 0;.. }..
0b00: 20 20 20 20 7d 20 65 6c 73 65 20 69 66 28 69 73 } else if(is
0b10: 5f 63 68 61 72 73 28 62 75 66 66 65 72 5b 69 5d _chars(buffer[i]
0b20: 2c 22 3e 22 29 29 7b 0d 0a 20 20 20 20 20 20 69 ,">")){.. i
0b30: 66 28 73 6d 61 6c 6c 65 72 5f 74 68 61 6e 3e 30 f(smaller_than>0
0b40: 29 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 28 70 ){.. if(p
0b50: 61 72 65 6e 74 68 65 73 65 73 29 20 72 65 74 75 arentheses) retu
0b60: 72 6e 20 30 3b 0d 0a 20 20 20 20 20 20 20 20 72 rn 0;.. r
0b70: 65 74 75 72 6e 20 69 2b 31 3b 0d 0a 20 20 20 20 eturn i+1;..
0b80: 20 20 7d 0d 0a 20 20 20 20 20 20 69 73 5f 6f 70 }.. is_op
0b90: 65 6e 3d 31 3b 0d 0a 20 20 20 20 7d 20 65 6c 73 en=1;.. } els
0ba0: 65 20 69 66 28 69 73 5f 63 68 61 72 73 28 62 75 e if(is_chars(bu
0bb0: 66 66 65 72 5b 69 5d 2c 22 28 22 29 29 7b 0d 0a ffer[i],"(")){..
0bc0: 20 20 20 20 20 20 70 61 72 65 6e 74 68 65 73 65 parenthese
0bd0: 73 2b 2b 3b 0d 0a 20 20 20 20 20 20 69 73 5f 6f s++;.. is_o
0be0: 70 65 6e 3d 31 3b 0d 0a 20 20 20 20 7d 20 65 6c pen=1;.. } el
0bf0: 73 65 20 69 66 28 69 73 5f 63 68 61 72 73 28 62 se if(is_chars(b
0c00: 75 66 66 65 72 5b 69 5d 2c 22 29 22 29 29 7b 0d uffer[i],")")){.
0c10: 0a 20 20 20 20 20 20 70 61 72 65 6e 74 68 65 73 . parenthes
0c20: 65 73 2d 2d 3b 0d 0a 20 20 20 20 20 20 69 73 5f es--;.. is_
0c30: 6f 70 65 6e 3d 31 3b 0d 0a 20 20 20 20 7d 20 65 open=1;.. } e
0c40: 6c 73 65 20 69 66 28 69 73 5f 63 68 61 72 73 28 lse if(is_chars(
0c50: 62 75 66 66 65 72 5b 69 5d 2c 22 5c 5c 22 29 29 buffer[i],"\\"))
0c60: 7b 0d 0a 20 20 20 20 20 20 69 73 5f 6f 70 65 6e {.. is_open
0c70: 3d 31 3b 0d 0a 20 20 20 20 20 20 69 2b 2b 3b 0d =1;.. i++;.
0c80: 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b 0d 0a 20 . } else {..
0c90: 20 20 20 20 20 69 73 5f 6f 70 65 6e 3d 31 3b 0d is_open=1;.
0ca0: 0a 20 20 20 20 7d 0d 0a 20 20 7d 0d 0a 20 20 69 . }.. }.. i
0cb0: 66 28 69 73 5f 6f 70 65 6e 20 26 26 20 73 6d 61 f(is_open && sma
0cc0: 6c 6c 65 72 5f 74 68 61 6e 3d 3d 30 29 20 72 65 ller_than==0) re
0cd0: 74 75 72 6e 20 62 75 66 66 65 72 2e 6e 75 6d 28 turn buffer.num(
0ce0: 29 3b 0d 0a 20 20 72 65 74 75 72 6e 20 30 3b 0d );.. return 0;.
0cf0: 0a 7d 0d 0a 0d 0a 69 6e 6c 69 6e 65 20 69 6e 74 .}....inline int
0d00: 20 73 70 61 63 65 73 5f 6e 75 6d 28 4d 79 54 53 spaces_num(MyTS
0d10: 63 68 61 72 26 20 62 75 66 66 65 72 2c 69 6e 74 char& buffer,int
0d20: 20 73 74 61 72 74 2c 69 6e 74 26 20 6e 75 6d 5f start,int& num_
0d30: 73 70 61 63 65 73 29 0d 0a 7b 0d 0a 20 20 6e 75 spaces)..{.. nu
0d40: 6d 5f 73 70 61 63 65 73 3d 30 3b 0d 0a 20 20 66 m_spaces=0;.. f
0d50: 6f 72 28 69 6e 74 20 69 3d 73 74 61 72 74 3b 69 or(int i=start;i
0d60: 3c 62 75 66 66 65 72 2e 6e 75 6d 28 29 3b 69 2b <buffer.num();i+
0d70: 2b 29 7b 0d 0a 20 20 20 20 69 66 28 69 73 5f 63 +){.. if(is_c
0d80: 68 61 72 73 28 62 75 66 66 65 72 5b 69 5d 2c 22 hars(buffer[i],"
0d90: 20 22 29 29 7b 0d 0a 20 20 20 20 20 20 6e 75 6d ")){.. num
0da0: 5f 73 70 61 63 65 73 2b 2b 3b 0d 0a 20 20 20 20 _spaces++;..
0db0: 7d 20 65 6c 73 65 20 69 66 28 69 73 5f 63 68 61 } else if(is_cha
0dc0: 72 73 28 62 75 66 66 65 72 5b 69 5d 2c 22 5c 74 rs(buffer[i],"\t
0dd0: 22 29 29 7b 0d 0a 20 20 20 20 20 20 6e 75 6d 5f ")){.. num_
0de0: 73 70 61 63 65 73 2b 3d 34 3b 0d 0a 20 20 20 20 spaces+=4;..
0df0: 7d 20 65 6c 73 65 20 69 66 28 69 73 5f 63 68 61 } else if(is_cha
0e00: 72 73 28 62 75 66 66 65 72 5b 69 5d 2c 22 5c 72 rs(buffer[i],"\r
0e10: 5c 6e 22 29 29 7b 0d 0a 20 20 20 20 20 20 72 65 \n")){.. re
0e20: 74 75 72 6e 20 69 3b 0d 0a 20 20 20 20 7d 20 65 turn i;.. } e
0e30: 6c 73 65 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 lse {.. ret
0e40: 75 72 6e 20 30 3b 0d 0a 20 20 20 20 7d 0d 0a 20 urn 0;.. }..
0e50: 20 7d 0d 0a 20 20 72 65 74 75 72 6e 20 62 75 66 }.. return buf
0e60: 66 65 72 2e 6e 75 6d 28 29 3b 0d 0a 7d 0d 0a 20 fer.num();..}..
0e70: 20 0d 0a 0d 0a 69 6e 6c 69 6e 65 20 69 6e 74 20 ....inline int
0e80: 6c 69 6e 6b 5f 74 69 74 6c 65 5f 6e 75 6d 28 4d link_title_num(M
0e90: 79 54 53 63 68 61 72 26 20 62 75 66 66 65 72 2c yTSchar& buffer,
0ea0: 69 6e 74 20 73 74 61 72 74 29 0d 0a 7b 0d 0a 20 int start)..{..
0eb0: 20 69 6e 74 20 69 73 5f 6f 70 65 6e 3d 30 2c 6e int is_open=0,n
0ec0: 75 6d 5f 73 70 61 63 65 73 3d 30 2c 6e 75 6d 5f um_spaces=0,num_
0ed0: 65 6e 64 6c 69 6e 65 73 3d 30 2c 6e 75 6d 5f 65 endlines=0,num_e
0ee0: 6e 6c 69 6e 65 73 41 3d 30 3b 0d 0a 20 20 63 68 nlinesA=0;.. ch
0ef0: 61 72 20 6f 70 65 6e 43 3b 0d 0a 20 20 0d 0a 20 ar openC;.. ..
0f00: 20 66 6f 72 28 69 6e 74 20 69 3d 73 74 61 72 74 for(int i=start
0f10: 3b 69 3c 62 75 66 66 65 72 2e 6e 75 6d 28 29 3b ;i<buffer.num();
0f20: 69 2b 2b 29 7b 0d 0a 20 20 20 20 69 66 28 69 73 i++){.. if(is
0f30: 5f 63 68 61 72 73 28 62 75 66 66 65 72 5b 69 5d _chars(buffer[i]
0f40: 2c 22 20 5c 74 22 29 29 7b 0d 0a 20 20 20 20 20 ," \t")){..
0f50: 20 6e 75 6d 5f 73 70 61 63 65 73 2b 2b 3b 0d 0a num_spaces++;..
0f60: 20 20 20 20 7d 20 65 6c 73 65 20 69 66 28 69 73 } else if(is
0f70: 5f 63 68 61 72 73 28 62 75 66 66 65 72 5b 69 5d _chars(buffer[i]
0f80: 2c 22 5c 72 5c 6e 22 29 29 7b 0d 0a 20 20 20 20 ,"\r\n")){..
0f90: 20 20 69 66 28 21 69 73 5f 6f 70 65 6e 29 7b 0d if(!is_open){.
0fa0: 0a 20 20 20 20 20 20 20 20 6e 75 6d 5f 73 70 61 . num_spa
0fb0: 63 65 73 2b 2b 3b 0d 0a 20 20 20 20 20 20 20 20 ces++;..
0fc0: 6e 75 6d 5f 65 6e 64 6c 69 6e 65 73 2b 2b 3b 0d num_endlines++;.
0fd0: 0a 20 20 20 20 20 20 20 20 69 66 28 6e 75 6d 5f . if(num_
0fe0: 65 6e 64 6c 69 6e 65 73 3e 31 29 20 72 65 74 75 endlines>1) retu
0ff0: 72 6e 20 30 3b 0d 0a 20 20 20 20 20 20 7d 20 65 rn 0;.. } e
1000: 6c 73 65 20 7b 0d 0a 20 20 20 20 20 20 20 20 69 lse {.. i
1010: 66 28 6e 75 6d 5f 65 6e 6c 69 6e 65 73 41 3e 30 f(num_enlinesA>0
1020: 29 20 72 65 74 75 72 6e 20 30 3b 0d 0a 20 20 20 ) return 0;..
1030: 20 20 20 20 20 6e 75 6d 5f 65 6e 6c 69 6e 65 73 num_enlines
1040: 41 2b 2b 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 A++;.. }..
1050: 20 20 20 7d 20 65 6c 73 65 20 69 66 28 69 73 5f } else if(is_
1060: 63 68 61 72 73 28 62 75 66 66 65 72 5b 69 5d 2c chars(buffer[i],
1070: 22 5c 22 27 22 29 29 7b 0d 0a 20 20 20 20 20 20 "\"'")){..
1080: 69 66 28 21 69 73 5f 6f 70 65 6e 29 7b 0d 0a 20 if(!is_open){..
1090: 20 20 20 20 20 20 20 6f 70 65 6e 43 3d 62 75 66 openC=buf
10a0: 66 65 72 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 fer[i];..
10b0: 20 69 73 5f 6f 70 65 6e 3d 31 3b 0d 0a 20 20 20 is_open=1;..
10c0: 20 20 20 7d 20 65 6c 73 65 20 69 66 28 62 75 66 } else if(buf
10d0: 66 65 72 5b 69 5d 3d 3d 6f 70 65 6e 43 29 7b 0d fer[i]==openC){.
10e0: 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 . return
10f0: 69 2b 31 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 i+1;.. }..
1100: 20 20 20 7d 20 65 6c 73 65 20 69 66 28 69 73 5f } else if(is_
1110: 63 68 61 72 73 28 62 75 66 66 65 72 5b 69 5d 2c chars(buffer[i],
1120: 22 28 22 29 29 7b 0d 0a 20 20 20 20 20 20 69 66 "(")){.. if
1130: 28 21 69 73 5f 6f 70 65 6e 29 7b 0d 0a 20 20 20 (!is_open){..
1140: 20 20 20 20 20 6f 70 65 6e 43 3d 62 75 66 66 65 openC=buffe
1150: 72 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 69 r[i];.. i
1160: 73 5f 6f 70 65 6e 3d 31 3b 0d 0a 20 20 20 20 20 s_open=1;..
1170: 20 7d 20 65 6c 73 65 20 69 66 28 6f 70 65 6e 43 } else if(openC
1180: 3d 3d 27 28 27 29 7b 0d 0a 20 20 20 20 20 20 20 =='('){..
1190: 20 72 65 74 75 72 6e 20 30 3b 0d 0a 20 20 20 20 return 0;..
11a0: 20 20 7d 0d 0a 20 20 20 20 7d 20 65 6c 73 65 20 }.. } else
11b0: 69 66 28 69 73 5f 63 68 61 72 73 28 62 75 66 66 if(is_chars(buff
11c0: 65 72 5b 69 5d 2c 22 29 22 29 29 7b 0d 0a 20 20 er[i],")")){..
11d0: 20 20 20 20 69 66 28 21 69 73 5f 6f 70 65 6e 29 if(!is_open)
11e0: 20 72 65 74 75 72 6e 20 30 3b 0d 0a 20 20 20 20 return 0;..
11f0: 20 20 65 6c 73 65 20 69 66 28 6f 70 65 6e 43 3d else if(openC=
1200: 3d 27 28 27 29 7b 0d 0a 20 20 20 20 20 20 20 20 ='('){..
1210: 72 65 74 75 72 6e 20 69 2b 31 3b 0d 0a 20 20 20 return i+1;..
1220: 20 20 20 7d 0d 0a 20 20 20 20 7d 20 65 6c 73 65 }.. } else
1230: 20 69 66 28 69 73 5f 63 68 61 72 73 28 62 75 66 if(is_chars(buf
1240: 66 65 72 5b 69 5d 2c 22 5c 5c 22 29 29 7b 0d 0a fer[i],"\\")){..
1250: 20 20 20 20 20 20 69 66 28 21 69 73 5f 6f 70 65 if(!is_ope
1260: 6e 29 20 72 65 74 75 72 6e 20 30 3b 0d 0a 20 20 n) return 0;..
1270: 20 20 20 20 69 2b 2b 3b 0d 0a 20 20 20 20 7d 20 i++;.. }
1280: 65 6c 73 65 20 7b 0d 0a 20 20 20 20 20 20 69 66 else {.. if
1290: 28 21 69 73 5f 6f 70 65 6e 29 20 72 65 74 75 72 (!is_open) retur
12a0: 6e 20 30 3b 0d 0a 20 20 20 20 20 20 69 73 5f 6f n 0;.. is_o
12b0: 70 65 6e 3d 31 3b 0d 0a 20 20 20 20 7d 0d 0a 20 pen=1;.. }..
12c0: 20 7d 0d 0a 20 20 72 65 74 75 72 6e 20 30 3b 0d }.. return 0;.
12d0: 0a 7d 0d 0a 0d 0a 69 6e 6c 69 6e 65 20 69 6e 74 .}....inline int
12e0: 20 6c 69 6e 6b 5f 75 72 6c 5f 6e 75 6d 28 4d 79 link_url_num(My
12f0: 54 53 63 68 61 72 26 20 62 75 66 66 65 72 2c 69 TSchar& buffer,i
1300: 6e 74 20 73 74 61 72 74 29 0d 0a 7b 0d 0a 20 20 nt start)..{..
1310: 69 6e 74 20 69 73 5f 6f 70 65 6e 3d 30 2c 6e 75 int is_open=0,nu
1320: 6d 5f 63 68 61 72 73 3d 30 3b 0d 0a 20 20 66 6f m_chars=0;.. fo
1330: 72 28 69 6e 74 20 69 3d 73 74 61 72 74 3b 69 3c r(int i=start;i<
1340: 62 75 66 66 65 72 2e 6e 75 6d 28 29 3b 69 2b 2b buffer.num();i++
1350: 29 7b 0d 0a 20 20 20 20 69 66 28 69 73 5f 63 68 ){.. if(is_ch
1360: 61 72 73 28 62 75 66 66 65 72 5b 69 5d 2c 22 20 ars(buffer[i],"
1370: 5c 74 22 29 29 7b 0d 0a 20 20 20 20 20 20 63 6f \t")){.. co
1380: 6e 74 69 6e 75 65 3b 0d 0a 20 20 20 20 7d 20 65 ntinue;.. } e
1390: 6c 73 65 20 69 66 28 69 73 5f 63 68 61 72 73 28 lse if(is_chars(
13a0: 62 75 66 66 65 72 5b 69 5d 2c 22 5c 72 5c 6e 22 buffer[i],"\r\n"
13b0: 29 29 7b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 )){.. retur
13c0: 6e 20 30 3b 0d 0a 20 20 20 20 7d 20 65 6c 73 65 n 0;.. } else
13d0: 20 69 66 28 69 73 5f 63 68 61 72 73 28 62 75 66 if(is_chars(buf
13e0: 66 65 72 5b 69 5d 2c 22 5b 22 29 29 7b 0d 0a 20 fer[i],"[")){..
13f0: 20 20 20 20 20 69 66 28 21 69 73 5f 6f 70 65 6e if(!is_open
1400: 29 20 69 73 5f 6f 70 65 6e 3d 31 3b 0d 0a 20 20 ) is_open=1;..
1410: 20 20 20 20 65 6c 73 65 20 72 65 74 75 72 6e 20 else return
1420: 30 3b 0d 0a 20 20 20 20 7d 20 65 6c 73 65 20 69 0;.. } else i
1430: 66 28 69 73 5f 63 68 61 72 73 28 62 75 66 66 65 f(is_chars(buffe
1440: 72 5b 69 5d 2c 22 5d 22 29 29 7b 0d 0a 20 20 20 r[i],"]")){..
1450: 20 20 20 69 66 28 6e 75 6d 5f 63 68 61 72 73 3d if(num_chars=
1460: 3d 30 29 20 72 65 74 75 72 6e 20 30 3b 0d 0a 20 =0) return 0;..
1470: 20 20 20 20 20 72 65 74 75 72 6e 20 69 2d 73 74 return i-st
1480: 61 72 74 2b 31 3b 0d 0a 20 20 20 20 7d 20 65 6c art+1;.. } el
1490: 73 65 20 69 66 28 69 73 5f 63 68 61 72 73 28 62 se if(is_chars(b
14a0: 75 66 66 65 72 5b 69 5d 2c 22 5c 5c 22 29 29 7b uffer[i],"\\")){
14b0: 0d 0a 20 20 20 20 20 20 6e 75 6d 5f 63 68 61 72 .. num_char
14c0: 73 2b 2b 3b 0d 0a 20 20 20 20 20 20 69 2b 2b 3b s++;.. i++;
14d0: 0d 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b 0d 0a .. } else {..
14e0: 20 20 20 20 20 20 6e 75 6d 5f 63 68 61 72 73 2b num_chars+
14f0: 2b 3b 0d 0a 20 20 20 20 7d 0d 0a 20 20 7d 0d 0a +;.. }.. }..
1500: 20 20 72 65 74 75 72 6e 20 30 3b 0d 0a 7d 0d 0a return 0;..}..
1510: 0d 0a 76 6f 69 64 20 4d 4b 73 74 61 74 65 3a 3a ..void MKstate::
1520: 63 72 65 61 74 65 5f 61 70 70 65 6e 64 5f 70 61 create_append_pa
1530: 72 61 67 72 61 70 68 28 4d 79 54 53 63 68 61 72 ragraph(MyTSchar
1540: 26 20 62 75 66 66 65 72 2c 69 6e 74 20 70 61 72 & buffer,int par
1550: 65 6e 74 5f 6c 65 76 65 6c 29 0d 0a 7b 0d 0a 20 ent_level)..{..
1560: 20 69 6e 74 20 6e 75 6d 5f 73 70 61 63 65 73 3b int num_spaces;
1570: 0d 0a 20 20 0d 0a 2f 2f 23 23 23 23 23 23 23 23 .. ..//########
1580: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1590: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
15a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
15b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
15c0: 23 23 23 23 23 23 23 23 0d 0a 2f 2f 20 20 20 20 ########..//
15d0: 62 6c 6f 63 6b 5f 71 75 6f 74 65 0d 0a 2f 2f 23 block_quote..//#
15e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
15f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1600: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1610: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1620: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0d ###############.
1630: 0a 20 20 0d 0a 20 20 69 66 28 62 6c 61 6e 6b 73 . .. if(blanks
1640: 5f 6c 69 6e 65 5f 5b 30 5d 3c 3d 33 20 26 26 20 _line_[0]<=3 &&
1650: 69 73 5f 63 68 61 72 73 28 62 75 66 66 65 72 5b is_chars(buffer[
1660: 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b SE_lineNoBlank_[
1670: 30 5d 5d 2c 22 3c 22 29 29 7b 0d 0a 20 20 20 20 0]],"<")){..
1680: 69 66 28 74 68 69 73 2d 3e 67 69 76 65 5f 74 79 if(this->give_ty
1690: 70 65 28 70 61 72 65 6e 74 5f 6c 65 76 65 6c 29 pe(parent_level)
16a0: 21 3d 4d 4b 3a 3a 62 6c 6f 63 6b 5f 71 75 6f 74 !=MK::block_quot
16b0: 65 29 7b 0d 0a 20 20 20 20 20 20 69 66 28 74 68 e){.. if(th
16c0: 69 73 2d 3e 67 69 76 65 5f 63 75 72 72 5f 74 79 is->give_curr_ty
16d0: 70 65 28 29 3d 3d 4d 4b 3a 3a 66 65 6e 63 65 64 pe()==MK::fenced
16e0: 5f 63 6f 64 65 5f 62 6c 6f 63 6b 29 7b 0d 0a 20 _code_block){..
16f0: 20 20 20 20 20 20 20 67 6f 74 6f 20 6e 6f 5f 62 goto no_b
1700: 6c 6f 63 6b 5f 71 75 6f 74 65 3b 0d 0a 20 20 20 lock_quote;..
1710: 20 20 20 7d 0d 0a 20 20 20 20 20 20 77 68 69 6c }.. whil
1720: 65 28 6f 70 65 6e 5f 62 6c 6f 63 6b 73 5f 2e 6e e(open_blocks_.n
1730: 75 6d 28 29 3e 70 61 72 65 6e 74 5f 6c 65 76 65 um()>parent_leve
1740: 6c 29 20 74 68 69 73 2d 3e 63 75 72 72 5f 63 6c l) this->curr_cl
1750: 6f 73 65 28 29 3b 0d 0a 20 20 20 20 20 20 74 68 ose();.. th
1760: 69 73 2d 3e 61 70 70 65 6e 64 5f 62 6c 6f 63 6b is->append_block
1770: 28 4d 4b 3a 3a 62 6c 6f 63 6b 5f 71 75 6f 74 65 (MK::block_quote
1780: 2c 53 45 5f 6c 69 6e 65 5f 2c 53 45 5f 6c 69 6e ,SE_line_,SE_lin
1790: 65 4e 6f 42 6c 61 6e 6b 5f 2c 0d 0a 20 20 20 20 eNoBlank_,..
17a0: 20 20 20 20 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f blanks_line_
17b0: 29 3b 0d 0a 20 20 20 20 7d 0d 0a 20 20 20 20 53 );.. }.. S
17c0: 45 5f 6c 69 6e 65 5f 5b 30 5d 3d 53 45 5f 6c 69 E_line_[0]=SE_li
17d0: 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 30 5d 2b 31 3b neNoBlank_[0]+1;
17e0: 0d 0a 20 20 20 20 69 66 28 69 73 5f 63 68 61 72 .. if(is_char
17f0: 73 28 62 75 66 66 65 72 5b 53 45 5f 6c 69 6e 65 s(buffer[SE_line
1800: 5f 5b 30 5d 5d 2c 22 20 22 29 29 20 53 45 5f 6c _[0]]," ")) SE_l
1810: 69 6e 65 5f 5b 30 5d 2b 2b 3b 0d 0a 20 20 20 20 ine_[0]++;..
1820: 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b SE_lineNoBlank_[
1830: 30 5d 3d 73 70 61 63 65 73 5f 6e 75 6d 28 62 75 0]=spaces_num(bu
1840: 66 66 65 72 2c 53 45 5f 6c 69 6e 65 5f 5b 30 5d ffer,SE_line_[0]
1850: 2c 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f 5b 30 5d ,blanks_line_[0]
1860: 29 3b 0d 0a 20 20 20 20 74 68 69 73 2d 3e 63 72 );.. this->cr
1870: 65 61 74 65 5f 61 70 70 65 6e 64 5f 70 61 72 61 eate_append_para
1880: 67 72 61 70 68 28 62 75 66 66 65 72 2c 70 61 72 graph(buffer,par
1890: 65 6e 74 5f 6c 65 76 65 6c 2b 31 29 3b 0d 0a 20 ent_level+1);..
18a0: 20 20 20 72 65 74 75 72 6e 3b 0d 0a 20 20 7d 0d return;.. }.
18b0: 0a 20 20 0d 0a 20 20 69 66 28 70 61 72 65 6e 74 . .. if(parent
18c0: 5f 6c 65 76 65 6c 3e 30 20 26 26 20 74 68 69 73 _level>0 && this
18d0: 2d 3e 67 69 76 65 5f 74 79 70 65 28 70 61 72 65 ->give_type(pare
18e0: 6e 74 5f 6c 65 76 65 6c 29 3d 3d 4d 4b 3a 3a 62 nt_level)==MK::b
18f0: 6c 6f 63 6b 5f 71 75 6f 74 65 29 7b 0d 0a 20 20 lock_quote){..
1900: 20 20 77 68 69 6c 65 28 6f 70 65 6e 5f 62 6c 6f while(open_blo
1910: 63 6b 73 5f 2e 6e 75 6d 28 29 3e 70 61 72 65 6e cks_.num()>paren
1920: 74 5f 6c 65 76 65 6c 29 20 74 68 69 73 2d 3e 63 t_level) this->c
1930: 75 72 72 5f 63 6c 6f 73 65 28 29 3b 0d 0a 20 20 urr_close();..
1940: 7d 0d 0a 20 20 0d 0a 20 20 3a 6e 6f 5f 62 6c 6f }.. .. :no_blo
1950: 63 6b 5f 71 75 6f 74 65 3b 0d 0a 20 20 0d 0a 2f ck_quote;.. ../
1960: 2f 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 /###############
1970: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1980: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1990: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
19a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
19b0: 23 0d 0a 2f 2f 20 20 20 20 66 65 6e 63 65 64 5f #..// fenced_
19c0: 63 6f 64 65 5f 62 6c 6f 63 6b 0d 0a 2f 2f 23 23 code_block..//##
19d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
19e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
19f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1a00: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1a10: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0d 0a ##############..
1a20: 20 20 0d 0a 20 20 69 66 28 74 68 69 73 2d 3e 67 .. if(this->g
1a30: 69 76 65 5f 63 75 72 72 5f 74 79 70 65 28 29 3d ive_curr_type()=
1a40: 3d 4d 4b 3a 3a 66 65 6e 63 65 64 5f 63 6f 64 65 =MK::fenced_code
1a50: 5f 62 6c 6f 63 6b 29 7b 0d 0a 20 20 20 20 69 66 _block){.. if
1a60: 28 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f 5b 30 5d (blanks_line_[0]
1a70: 3c 3d 33 20 26 26 20 69 73 5f 63 68 61 72 73 28 <=3 && is_chars(
1a80: 62 75 66 66 65 72 5b 53 45 5f 6c 69 6e 65 4e 6f buffer[SE_lineNo
1a90: 42 6c 61 6e 6b 5f 5b 30 5d 5d 2c 22 60 7e 22 29 Blank_[0]],"`~")
1aa0: 29 7b 0d 0a 20 20 20 20 20 20 4d 4b 62 6c 6f 63 ){.. MKbloc
1ab0: 6b 73 26 20 62 6c 6f 63 6b 3d 62 6c 6f 63 6b 73 ks& block=blocks
1ac0: 5f 5b 6f 70 65 6e 5f 62 6c 6f 63 6b 73 5f 5b 65 _[open_blocks_[e
1ad0: 6e 64 5f 4d 54 53 5d 5d 3b 0d 0a 20 20 20 20 20 nd_MTS]];..
1ae0: 20 69 6e 74 20 76 61 6c 69 64 3d 69 73 5f 73 61 int valid=is_sa
1af0: 6d 65 5f 63 68 61 72 5f 6c 69 6e 65 28 62 75 66 me_char_line(buf
1b00: 66 65 72 2c 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 fer,SE_lineNoBla
1b10: 6e 6b 5f 5b 30 5d 2c 0d 0a 20 20 20 20 20 20 20 nk_[0],..
1b20: 20 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f SE_lineNoBlank_
1b30: 5b 31 5d 2c 30 2c 62 6c 6f 63 6b 2e 6c 65 76 65 [1],0,block.leve
1b40: 6c 5f 29 3b 0d 0a 20 20 20 20 20 20 69 66 28 62 l_);.. if(b
1b50: 75 66 66 65 72 5b 53 45 5f 6c 69 6e 65 4e 6f 42 uffer[SE_lineNoB
1b60: 6c 61 6e 6b 5f 5b 30 5d 5d 21 3d 62 75 66 66 65 lank_[0]]!=buffe
1b70: 72 5b 62 6c 6f 63 6b 2e 70 6f 73 4e 6f 42 6c 61 r[block.posNoBla
1b80: 6e 6b 5f 5b 30 5d 5d 29 20 76 61 6c 69 64 3d 30 nk_[0]]) valid=0
1b90: 3b 0d 0a 20 20 20 20 20 20 69 66 28 76 61 6c 69 ;.. if(vali
1ba0: 64 29 7b 0d 0a 20 20 20 20 20 20 20 20 62 6c 6f d){.. blo
1bb0: 63 6b 2e 70 6f 73 5f 5b 31 5d 3d 53 45 5f 6c 69 ck.pos_[1]=SE_li
1bc0: 6e 65 5f 5b 31 5d 3b 0d 0a 20 20 20 20 20 20 20 ne_[1];..
1bd0: 20 62 6c 6f 63 6b 2e 70 6f 73 4e 6f 42 6c 61 6e block.posNoBlan
1be0: 6b 5f 5b 31 5d 3d 53 45 5f 6c 69 6e 65 4e 6f 42 k_[1]=SE_lineNoB
1bf0: 6c 61 6e 6b 5f 5b 31 5d 3b 0d 0a 20 20 20 20 20 lank_[1];..
1c00: 20 20 20 62 6c 6f 63 6b 2e 62 6c 61 6e 6b 73 5f block.blanks_
1c10: 5b 31 5d 3d 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f [1]=blanks_line_
1c20: 5b 31 5d 3b 0d 0a 20 20 20 20 20 20 20 20 74 68 [1];.. th
1c30: 69 73 2d 3e 63 75 72 72 5f 63 6c 6f 73 65 28 29 is->curr_close()
1c40: 3b 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 ;.. retur
1c50: 6e 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 n;.. }..
1c60: 20 7d 0d 0a 20 20 20 20 4d 4b 62 6c 6f 63 6b 73 }.. MKblocks
1c70: 26 20 62 6c 6f 63 6b 3d 62 6c 6f 63 6b 73 5f 5b & block=blocks_[
1c80: 6f 70 65 6e 5f 62 6c 6f 63 6b 73 5f 5b 65 6e 64 open_blocks_[end
1c90: 5f 4d 54 53 5d 5d 3b 0d 0a 20 20 20 20 62 6c 6f _MTS]];.. blo
1ca0: 63 6b 2e 70 6f 73 5f 5b 31 5d 3d 53 45 5f 6c 69 ck.pos_[1]=SE_li
1cb0: 6e 65 5f 5b 31 5d 3b 0d 0a 20 20 20 20 62 6c 6f ne_[1];.. blo
1cc0: 63 6b 2e 70 6f 73 4e 6f 42 6c 61 6e 6b 5f 5b 31 ck.posNoBlank_[1
1cd0: 5d 3d 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b ]=SE_lineNoBlank
1ce0: 5f 5b 31 5d 3b 0d 0a 20 20 20 20 62 6c 6f 63 6b _[1];.. block
1cf0: 2e 62 6c 61 6e 6b 73 5f 5b 31 5d 3d 62 6c 61 6e .blanks_[1]=blan
1d00: 6b 73 5f 6c 69 6e 65 5f 5b 31 5d 3b 0d 0a 20 20 ks_line_[1];..
1d10: 20 20 72 65 74 75 72 6e 3b 0d 0a 20 20 7d 0d 0a return;.. }..
1d20: 20 20 0d 0a 20 20 69 66 28 62 6c 61 6e 6b 73 5f .. if(blanks_
1d30: 6c 69 6e 65 5f 5b 30 5d 3c 3d 33 20 26 26 20 69 line_[0]<=3 && i
1d40: 73 5f 63 68 61 72 73 28 62 75 66 66 65 72 5b 53 s_chars(buffer[S
1d50: 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 30 E_lineNoBlank_[0
1d60: 5d 5d 2c 22 60 7e 22 29 29 7b 0d 0a 20 20 20 20 ]],"`~")){..
1d70: 69 6e 74 20 6c 65 76 65 6c 3d 6e 75 6d 5f 73 61 int level=num_sa
1d80: 6d 65 5f 63 68 61 72 5f 6c 69 6e 65 5f 70 72 65 me_char_line_pre
1d90: 66 69 78 28 62 75 66 66 65 72 2c 53 45 5f 6c 69 fix(buffer,SE_li
1da0: 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 30 5d 2c 53 45 neNoBlank_[0],SE
1db0: 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 31 5d _lineNoBlank_[1]
1dc0: 2c 30 29 3b 0d 0a 20 20 20 20 69 66 28 6c 65 76 ,0);.. if(lev
1dd0: 65 6c 3e 3d 33 29 7b 0d 0a 20 20 20 20 20 20 69 el>=3){.. i
1de0: 66 28 62 6c 6f 63 6b 71 75 6f 74 65 5f 6c 65 76 f(blockquote_lev
1df0: 65 6c 4e 21 3d 62 6c 6f 63 6b 71 75 6f 74 65 5f elN!=blockquote_
1e00: 6c 65 76 65 6c 29 20 74 68 69 73 2d 3e 63 6c 6f level) this->clo
1e10: 73 65 5f 61 6c 6c 28 29 3b 0d 0a 20 20 20 20 20 se_all();..
1e20: 20 65 6c 73 65 20 69 66 28 74 68 69 73 2d 3e 63 else if(this->c
1e30: 75 72 72 5f 69 73 5f 6f 70 65 6e 28 29 29 20 74 urr_is_open()) t
1e40: 68 69 73 2d 3e 63 75 72 72 5f 63 6c 6f 73 65 28 his->curr_close(
1e50: 29 3b 0d 0a 20 20 20 20 20 20 4d 4b 62 6c 6f 63 );.. MKbloc
1e60: 6b 73 26 20 62 6c 6f 63 6b 3d 74 68 69 73 2d 3e ks& block=this->
1e70: 61 70 70 65 6e 64 5f 62 6c 6f 63 6b 28 4d 4b 3a append_block(MK:
1e80: 3a 66 65 6e 63 65 64 5f 63 6f 64 65 5f 62 6c 6f :fenced_code_blo
1e90: 63 6b 2c 53 45 5f 6c 69 6e 65 5f 2c 0d 0a 20 20 ck,SE_line_,..
1ea0: 20 20 20 20 20 20 53 45 5f 6c 69 6e 65 4e 6f 42 SE_lineNoB
1eb0: 6c 61 6e 6b 5f 2c 62 6c 61 6e 6b 73 5f 6c 69 6e lank_,blanks_lin
1ec0: 65 5f 29 3b 0d 0a 20 20 20 20 20 20 62 6c 6f 63 e_);.. bloc
1ed0: 6b 2e 6c 65 76 65 6c 5f 3d 6c 65 76 65 6c 3b 0d k.level_=level;.
1ee0: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a . return;..
1ef0: 20 20 20 20 7d 0d 0a 20 20 7d 0d 0a 20 20 20 20 }.. }..
1f00: 20 20 0d 0a 2f 2f 23 23 23 23 23 23 23 23 23 23 ..//##########
1f10: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1f20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1f30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1f40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1f50: 23 23 23 23 23 23 0d 0a 2f 2f 20 20 20 20 69 6e ######..// in
1f60: 64 65 6e 74 65 64 5f 63 6f 64 65 5f 62 6c 6f 63 dented_code_bloc
1f70: 6b 0d 0a 2f 2f 23 23 23 23 23 23 23 23 23 23 23 k..//###########
1f80: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1f90: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1fa0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1fb0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1fc0: 23 23 23 23 23 0d 0a 20 20 0d 0a 20 20 69 66 28 #####.. .. if(
1fd0: 74 68 69 73 2d 3e 67 69 76 65 5f 63 75 72 72 5f this->give_curr_
1fe0: 74 79 70 65 28 29 3d 3d 4d 4b 3a 3a 69 6e 64 65 type()==MK::inde
1ff0: 6e 74 65 64 5f 63 6f 64 65 5f 62 6c 6f 63 6b 29 nted_code_block)
2000: 7b 0d 0a 20 20 20 20 69 66 28 62 6c 61 6e 6b 73 {.. if(blanks
2010: 5f 6c 69 6e 65 5f 5b 30 5d 3e 3d 34 29 7b 0d 0a _line_[0]>=4){..
2020: 20 20 20 20 20 20 4d 4b 62 6c 6f 63 6b 73 26 20 MKblocks&
2030: 62 6c 6f 63 6b 3d 62 6c 6f 63 6b 73 5f 5b 6f 70 block=blocks_[op
2040: 65 6e 5f 62 6c 6f 63 6b 73 5f 5b 65 6e 64 5f 4d en_blocks_[end_M
2050: 54 53 5d 5d 3b 0d 0a 20 20 20 20 20 20 62 6c 6f TS]];.. blo
2060: 63 6b 2e 70 6f 73 5f 5b 31 5d 3d 53 45 5f 6c 69 ck.pos_[1]=SE_li
2070: 6e 65 5f 5b 31 5d 3b 0d 0a 20 20 20 20 20 20 62 ne_[1];.. b
2080: 6c 6f 63 6b 2e 70 6f 73 4e 6f 42 6c 61 6e 6b 5f lock.posNoBlank_
2090: 5b 31 5d 3d 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 [1]=SE_lineNoBla
20a0: 6e 6b 5f 5b 31 5d 3b 0d 0a 20 20 20 20 20 20 62 nk_[1];.. b
20b0: 6c 6f 63 6b 2e 62 6c 61 6e 6b 73 5f 5b 31 5d 3d lock.blanks_[1]=
20c0: 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f 5b 31 5d 3b blanks_line_[1];
20d0: 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d .. return;.
20e0: 0a 20 20 20 20 7d 0d 0a 20 20 20 20 74 68 69 73 . }.. this
20f0: 2d 3e 63 75 72 72 5f 63 6c 6f 73 65 28 29 3b 0d ->curr_close();.
2100: 0a 20 20 7d 0d 0a 20 20 69 66 28 21 74 68 69 73 . }.. if(!this
2110: 2d 3e 63 75 72 72 5f 69 73 5f 6f 70 65 6e 28 29 ->curr_is_open()
2120: 20 26 26 20 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f && blanks_line_
2130: 5b 30 5d 3e 3d 34 29 7b 0d 0a 20 20 20 20 74 68 [0]>=4){.. th
2140: 69 73 2d 3e 61 70 70 65 6e 64 5f 62 6c 6f 63 6b is->append_block
2150: 28 4d 4b 3a 3a 69 6e 64 65 6e 74 65 64 5f 63 6f (MK::indented_co
2160: 64 65 5f 62 6c 6f 63 6b 2c 53 45 5f 6c 69 6e 65 de_block,SE_line
2170: 5f 2c 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b _,SE_lineNoBlank
2180: 5f 2c 0d 0a 20 20 20 20 20 20 62 6c 61 6e 6b 73 _,.. blanks
2190: 5f 6c 69 6e 65 5f 29 3b 0d 0a 20 20 20 20 72 65 _line_);.. re
21a0: 74 75 72 6e 3b 0d 0a 20 20 7d 0d 0a 20 20 20 20 turn;.. }..
21b0: 20 20 0d 0a 2f 2f 23 23 23 23 23 23 23 23 23 23 ..//##########
21c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
21d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
21e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
21f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2200: 23 23 23 23 23 23 0d 0a 2f 2f 20 20 20 20 73 65 ######..// se
2210: 74 65 78 74 5f 68 65 61 64 69 6e 67 0d 0a 2f 2f text_heading..//
2220: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2230: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2240: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2250: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2260: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2270: 0d 0a 20 20 0d 0a 20 20 69 66 28 74 68 69 73 2d .. .. if(this-
2280: 3e 67 69 76 65 5f 63 75 72 72 5f 74 79 70 65 28 >give_curr_type(
2290: 29 3d 3d 4d 4b 3a 3a 70 61 72 61 67 72 61 70 68 )==MK::paragraph
22a0: 20 26 26 0d 0a 20 20 20 20 62 6c 61 6e 6b 73 5f &&.. blanks_
22b0: 6c 69 6e 65 5f 5b 30 5d 3c 3d 33 20 26 26 0d 0a line_[0]<=3 &&..
22c0: 20 20 20 20 69 73 5f 63 68 61 72 73 28 62 75 66 is_chars(buf
22d0: 66 65 72 5b 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 fer[SE_lineNoBla
22e0: 6e 6b 5f 5b 30 5d 5d 2c 22 2d 3d 22 29 29 7b 0d nk_[0]],"-=")){.
22f0: 0a 20 20 20 20 69 6e 74 20 76 61 6c 69 64 3d 69 . int valid=i
2300: 73 5f 73 61 6d 65 5f 63 68 61 72 5f 6c 69 6e 65 s_same_char_line
2310: 28 62 75 66 66 65 72 2c 53 45 5f 6c 69 6e 65 4e (buffer,SE_lineN
2320: 6f 42 6c 61 6e 6b 5f 5b 30 5d 2c 53 45 5f 6c 69 oBlank_[0],SE_li
2330: 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 31 5d 2c 30 2c neNoBlank_[1],0,
2340: 31 29 3b 0d 0a 20 20 20 20 69 66 28 76 61 6c 69 1);.. if(vali
2350: 64 29 7b 0d 0a 20 20 20 20 20 20 4d 4b 62 6c 6f d){.. MKblo
2360: 63 6b 73 26 20 62 6c 6f 63 6b 3d 62 6c 6f 63 6b cks& block=block
2370: 73 5f 5b 6f 70 65 6e 5f 62 6c 6f 63 6b 73 5f 5b s_[open_blocks_[
2380: 65 6e 64 5f 4d 54 53 5d 5d 3b 0d 0a 20 20 20 20 end_MTS]];..
2390: 20 20 62 6c 6f 63 6b 2e 6d 74 79 70 65 5f 3d 4d block.mtype_=M
23a0: 4b 3a 3a 73 65 74 65 78 74 5f 68 65 61 64 69 6e K::setext_headin
23b0: 67 3b 0d 0a 20 20 20 20 20 20 69 66 28 62 75 66 g;.. if(buf
23c0: 66 65 72 5b 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 fer[SE_lineNoBla
23d0: 6e 6b 5f 5b 30 5d 5d 3d 3d 27 3d 27 29 20 62 6c nk_[0]]=='=') bl
23e0: 6f 63 6b 2e 6c 65 76 65 6c 5f 3d 31 3b 0d 0a 20 ock.level_=1;..
23f0: 20 20 20 20 20 65 6c 73 65 20 62 6c 6f 63 6b 2e else block.
2400: 6c 65 76 65 6c 5f 3d 32 3b 0d 0a 20 20 20 20 20 level_=2;..
2410: 20 74 68 69 73 2d 3e 63 75 72 72 5f 63 6c 6f 73 this->curr_clos
2420: 65 28 29 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 e();.. retu
2430: 72 6e 3b 0d 0a 20 20 20 20 7d 0d 0a 20 20 7d 0d rn;.. }.. }.
2440: 0a 0d 0a 2f 2f 23 23 23 23 23 23 23 23 23 23 23 ...//###########
2450: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2460: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2470: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2480: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2490: 23 23 23 23 23 0d 0a 2f 2f 20 20 20 20 74 68 65 #####..// the
24a0: 6d 61 74 69 63 5f 62 72 65 61 6b 0d 0a 2f 2f 23 matic_break..//#
24b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
24c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
24d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
24e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
24f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0d ###############.
2500: 0a 20 20 0d 0a 20 20 69 66 28 62 6c 61 6e 6b 73 . .. if(blanks
2510: 5f 6c 69 6e 65 5f 5b 30 5d 3c 3d 33 20 26 26 20 _line_[0]<=3 &&
2520: 69 73 5f 63 68 61 72 73 28 62 75 66 66 65 72 5b is_chars(buffer[
2530: 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b SE_lineNoBlank_[
2540: 30 5d 5d 2c 22 2d 5f 2a 22 29 29 7b 0d 0a 20 20 0]],"-_*")){..
2550: 20 20 69 6e 74 20 76 61 6c 69 64 3d 69 73 5f 73 int valid=is_s
2560: 61 6d 65 5f 63 68 61 72 5f 6c 69 6e 65 28 62 75 ame_char_line(bu
2570: 66 66 65 72 2c 53 45 5f 6c 69 6e 65 4e 6f 42 6c ffer,SE_lineNoBl
2580: 61 6e 6b 5f 5b 30 5d 2c 53 45 5f 6c 69 6e 65 4e ank_[0],SE_lineN
2590: 6f 42 6c 61 6e 6b 5f 5b 31 5d 2c 31 2c 33 29 3b oBlank_[1],1,3);
25a0: 0d 0a 20 20 20 20 69 66 28 76 61 6c 69 64 29 7b .. if(valid){
25b0: 0d 0a 20 20 20 20 20 20 69 66 28 62 6c 6f 63 6b .. if(block
25c0: 71 75 6f 74 65 5f 6c 65 76 65 6c 4e 21 3d 62 6c quote_levelN!=bl
25d0: 6f 63 6b 71 75 6f 74 65 5f 6c 65 76 65 6c 29 20 ockquote_level)
25e0: 74 68 69 73 2d 3e 63 6c 6f 73 65 5f 61 6c 6c 28 this->close_all(
25f0: 29 3b 0d 0a 20 20 20 20 20 20 65 6c 73 65 20 69 );.. else i
2600: 66 28 74 68 69 73 2d 3e 63 75 72 72 5f 69 73 5f f(this->curr_is_
2610: 6f 70 65 6e 28 29 29 20 74 68 69 73 2d 3e 63 75 open()) this->cu
2620: 72 72 5f 63 6c 6f 73 65 28 29 3b 0d 0a 20 20 20 rr_close();..
2630: 20 20 20 74 68 69 73 2d 3e 61 70 70 65 6e 64 5f this->append_
2640: 62 6c 6f 63 6b 28 4d 4b 3a 3a 74 68 65 6d 61 74 block(MK::themat
2650: 69 63 5f 62 72 65 61 6b 2c 53 45 5f 6c 69 6e 65 ic_break,SE_line
2660: 5f 2c 0d 0a 20 20 20 20 20 20 20 20 53 45 5f 6c _,.. SE_l
2670: 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 2c 62 6c 61 6e ineNoBlank_,blan
2680: 6b 73 5f 6c 69 6e 65 5f 29 3b 0d 0a 20 20 20 20 ks_line_);..
2690: 20 20 74 68 69 73 2d 3e 63 75 72 72 5f 63 6c 6f this->curr_clo
26a0: 73 65 28 29 3b 0d 0a 20 20 20 20 20 20 72 65 74 se();.. ret
26b0: 75 72 6e 3b 0d 0a 20 20 20 20 7d 0d 0a 20 20 7d urn;.. }.. }
26c0: 0d 0a 20 20 0d 0a 2f 2f 23 23 23 23 23 23 23 23 .. ..//########
26d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
26e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
26f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2700: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2710: 23 23 23 23 23 23 23 23 0d 0a 2f 2f 20 20 20 20 ########..//
2720: 41 54 58 5f 68 65 61 64 69 6e 67 0d 0a 2f 2f 23 ATX_heading..//#
2730: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2740: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2750: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2760: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2770: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0d ###############.
2780: 0a 20 20 0d 0a 20 20 69 66 28 62 6c 61 6e 6b 73 . .. if(blanks
2790: 5f 6c 69 6e 65 5f 5b 30 5d 3c 3d 33 20 26 26 20 _line_[0]<=3 &&
27a0: 69 73 5f 63 68 61 72 73 28 62 75 66 66 65 72 5b is_chars(buffer[
27b0: 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b SE_lineNoBlank_[
27c0: 30 5d 5d 2c 22 23 22 29 29 7b 0d 0a 20 20 20 20 0]],"#")){..
27d0: 49 6e 74 56 65 63 74 6f 72 32 44 20 6c 65 76 65 IntVector2D leve
27e0: 6c 2c 73 74 61 72 74 5f 65 6e 64 2c 62 6c 61 6e l,start_end,blan
27f0: 6b 3b 0d 0a 20 20 20 20 6c 65 76 65 6c 5b 30 5d k;.. level[0]
2800: 3d 31 3b 0d 0a 20 20 20 20 66 6f 72 28 69 6e 74 =1;.. for(int
2810: 20 69 3d 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e i=SE_lineNoBlan
2820: 6b 5f 5b 30 5d 2b 31 3b 69 3c 53 45 5f 6c 69 6e k_[0]+1;i<SE_lin
2830: 65 4e 6f 42 6c 61 6e 6b 5f 5b 31 5d 3b 69 2b 2b eNoBlank_[1];i++
2840: 29 7b 0d 0a 20 20 20 20 20 20 69 66 28 69 73 5f ){.. if(is_
2850: 63 68 61 72 73 28 62 75 66 66 65 72 5b 69 5d 2c chars(buffer[i],
2860: 22 23 22 29 20 26 26 20 73 74 61 72 74 5f 65 6e "#") && start_en
2870: 64 5b 30 5d 3d 3d 30 29 7b 0d 0a 20 20 20 20 20 d[0]==0){..
2880: 20 20 20 6c 65 76 65 6c 5b 30 5d 2b 2b 3b 0d 0a level[0]++;..
2890: 20 20 20 20 20 20 7d 20 65 6c 73 65 20 69 66 28 } else if(
28a0: 69 73 5f 63 68 61 72 73 28 62 75 66 66 65 72 5b is_chars(buffer[
28b0: 69 5d 2c 22 23 22 29 20 26 26 20 62 6c 61 6e 6b i],"#") && blank
28c0: 5b 31 5d 3e 30 29 7b 0d 0a 20 20 20 20 20 20 20 [1]>0){..
28d0: 20 6c 65 76 65 6c 5b 31 5d 2b 2b 3b 0d 0a 20 20 level[1]++;..
28e0: 20 20 20 20 7d 20 65 6c 73 65 20 69 66 28 69 73 } else if(is
28f0: 5f 63 68 61 72 73 28 62 75 66 66 65 72 5b 69 5d _chars(buffer[i]
2900: 2c 22 20 5c 74 22 29 29 7b 0d 0a 20 20 20 20 20 ," \t")){..
2910: 20 20 20 69 66 28 73 74 61 72 74 5f 65 6e 64 5b if(start_end[
2920: 30 5d 3d 3d 30 29 20 62 6c 61 6e 6b 5b 30 5d 2b 0]==0) blank[0]+
2930: 2b 3b 0d 0a 20 20 20 20 20 20 20 20 65 6c 73 65 +;.. else
2940: 20 62 6c 61 6e 6b 5b 31 5d 2b 2b 3b 0d 0a 20 20 blank[1]++;..
2950: 20 20 20 20 7d 20 65 6c 73 65 20 7b 0d 0a 20 20 } else {..
2960: 20 20 20 20 20 20 69 66 28 73 74 61 72 74 5f 65 if(start_e
2970: 6e 64 5b 30 5d 3d 3d 30 29 20 73 74 61 72 74 5f nd[0]==0) start_
2980: 65 6e 64 5b 30 5d 3d 69 3b 0d 0a 20 20 20 20 20 end[0]=i;..
2990: 20 20 20 73 74 61 72 74 5f 65 6e 64 5b 31 5d 3d start_end[1]=
29a0: 69 3b 0d 0a 20 20 20 20 20 20 20 20 62 6c 61 6e i;.. blan
29b0: 6b 5b 31 5d 3d 30 3b 0d 0a 20 20 20 20 20 20 7d k[1]=0;.. }
29c0: 0d 0a 20 20 20 20 7d 0d 0a 20 20 20 20 69 66 28 .. }.. if(
29d0: 6c 65 76 65 6c 5b 30 5d 3e 3d 36 20 26 26 20 62 level[0]>=6 && b
29e0: 6c 61 6e 6b 5b 30 5d 3e 3d 31 29 7b 0d 0a 20 20 lank[0]>=1){..
29f0: 20 20 20 20 69 66 28 62 6c 6f 63 6b 71 75 6f 74 if(blockquot
2a00: 65 5f 6c 65 76 65 6c 4e 21 3d 62 6c 6f 63 6b 71 e_levelN!=blockq
2a10: 75 6f 74 65 5f 6c 65 76 65 6c 29 20 74 68 69 73 uote_level) this
2a20: 2d 3e 63 6c 6f 73 65 5f 61 6c 6c 28 29 3b 0d 0a ->close_all();..
2a30: 20 20 20 20 20 20 65 6c 73 65 20 69 66 28 74 68 else if(th
2a40: 69 73 2d 3e 63 75 72 72 5f 69 73 5f 6f 70 65 6e is->curr_is_open
2a50: 28 29 29 20 74 68 69 73 2d 3e 63 75 72 72 5f 63 ()) this->curr_c
2a60: 6c 6f 73 65 28 29 3b 0d 0a 20 20 20 20 20 20 73 lose();.. s
2a70: 74 61 72 74 5f 65 6e 64 5b 31 5d 2b 2b 3b 0d 0a tart_end[1]++;..
2a80: 20 20 20 20 20 20 4d 4b 62 6c 6f 63 6b 73 26 20 MKblocks&
2a90: 62 6c 6f 63 6b 3d 74 68 69 73 2d 3e 61 70 70 65 block=this->appe
2aa0: 6e 64 5f 62 6c 6f 63 6b 28 4d 4b 3a 3a 41 54 58 nd_block(MK::ATX
2ab0: 5f 68 65 61 64 69 6e 67 2c 53 45 5f 6c 69 6e 65 _heading,SE_line
2ac0: 5f 2c 73 74 61 72 74 5f 65 6e 64 2c 0d 0a 20 20 _,start_end,..
2ad0: 20 20 20 20 20 20 62 6c 61 6e 6b 73 5f 6c 69 6e blanks_lin
2ae0: 65 5f 29 3b 0d 0a 20 20 20 20 20 20 62 6c 6f 63 e_);.. bloc
2af0: 6b 2e 6c 65 76 65 6c 5f 3d 6c 65 76 65 6c 5b 30 k.level_=level[0
2b00: 5d 3b 0d 0a 20 20 20 20 20 20 74 68 69 73 2d 3e ];.. this->
2b10: 63 75 72 72 5f 63 6c 6f 73 65 28 29 3b 0d 0a 20 curr_close();..
2b20: 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 20 20 return;..
2b30: 20 20 7d 0d 0a 20 20 7d 0d 0a 20 20 0d 0a 2f 2f }.. }.. ..//
2b40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2b50: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2b60: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2b70: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2b80: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2b90: 0d 0a 2f 2f 20 20 20 20 48 54 4d 4c 5f 62 6c 6f ..// HTML_blo
2ba0: 63 6b 0d 0a 2f 2f 23 23 23 23 23 23 23 23 23 23 ck..//##########
2bb0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2bc0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2bd0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2be0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2bf0: 23 23 23 23 23 23 0d 0a 20 20 0d 0a 20 20 69 66 ######.. .. if
2c00: 28 74 68 69 73 2d 3e 67 69 76 65 5f 63 75 72 72 (this->give_curr
2c10: 5f 74 79 70 65 28 29 3d 3d 4d 4b 3a 3a 48 54 4d _type()==MK::HTM
2c20: 4c 5f 62 6c 6f 63 6b 29 7b 0d 0a 20 20 20 20 63 L_block){.. c
2c30: 6f 6e 73 74 20 63 68 61 72 2a 20 72 65 78 73 45 onst char* rexsE
2c40: 6e 64 5b 5d 3d 7b 0d 0a 20 20 20 20 20 20 20 20 nd[]={..
2c50: 22 3c 28 3f 69 6e 29 5c 5c 41 3c 2f 28 73 63 72 "<(?in)\\A</(scr
2c60: 69 70 74 7c 70 72 65 7c 73 74 79 6c 65 29 5c 5c ipt|pre|style)\\
2c70: 73 2a 3e 3f 24 22 2c 0d 0a 20 20 20 20 20 20 20 s*>?$",..
2c80: 20 22 28 3f 69 6e 29 5c 5c 41 2e 2a 2d 2d 3e 22 "(?in)\\A.*-->"
2c90: 2c 0d 0a 20 20 20 20 20 20 20 20 22 28 3f 69 6e ,.. "(?in
2ca0: 29 5c 5c 41 2e 2a 5c 5c 3f 3e 22 2c 0d 0a 20 20 )\\A.*\\?>",..
2cb0: 20 20 20 20 20 20 22 28 3f 69 6e 29 5c 5c 41 2e "(?in)\\A.
2cc0: 2a 3e 22 2c 0d 0a 20 20 20 20 20 20 20 20 22 28 *>",.. "(
2cd0: 3f 69 6e 29 5c 5c 41 2e 2a 5c 5c 5d 5c 5c 5d 3e ?in)\\A.*\\]\\]>
2ce0: 22 2c 0d 0a 20 20 20 20 20 20 20 20 22 28 3f 69 ",.. "(?i
2cf0: 6e 29 5c 5c 41 5c 5c 73 2a 24 22 2c 0d 0a 20 20 n)\\A\\s*$",..
2d00: 20 20 20 20 20 20 22 28 3f 69 6e 29 5c 5c 41 5c "(?in)\\A\
2d10: 5c 73 2a 24 22 0d 0a 20 20 20 20 20 20 7d 3b 0d \s*$".. };.
2d20: 0a 20 20 20 20 4d 4b 62 6c 6f 63 6b 73 26 20 62 . MKblocks& b
2d30: 6c 6f 63 6b 3d 62 6c 6f 63 6b 73 5f 5b 6f 70 65 lock=blocks_[ope
2d40: 6e 5f 62 6c 6f 63 6b 73 5f 5b 65 6e 64 5f 4d 54 n_blocks_[end_MT
2d50: 53 5d 5d 3b 0d 0a 20 20 20 20 62 6c 6f 63 6b 2e S]];.. block.
2d60: 70 6f 73 5f 5b 31 5d 3d 53 45 5f 6c 69 6e 65 5f pos_[1]=SE_line_
2d70: 5b 31 5d 3b 0d 0a 20 20 20 20 62 6c 6f 63 6b 2e [1];.. block.
2d80: 70 6f 73 4e 6f 42 6c 61 6e 6b 5f 5b 31 5d 3d 53 posNoBlank_[1]=S
2d90: 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 31 E_lineNoBlank_[1
2da0: 5d 3b 0d 0a 20 20 20 20 62 6c 6f 63 6b 2e 62 6c ];.. block.bl
2db0: 61 6e 6b 73 5f 5b 31 5d 3d 62 6c 61 6e 6b 73 5f anks_[1]=blanks_
2dc0: 6c 69 6e 65 5f 5b 31 5d 3b 0d 0a 20 20 20 20 0d line_[1];.. .
2dd0: 0a 20 20 20 20 69 66 28 62 75 66 66 65 72 2e 72 . if(buffer.r
2de0: 65 67 65 78 70 28 53 45 5f 6c 69 6e 65 4e 6f 42 egexp(SE_lineNoB
2df0: 6c 61 6e 6b 5f 5b 30 5d 2c 72 65 78 73 45 6e 64 lank_[0],rexsEnd
2e00: 5b 62 6c 6f 63 6b 2e 6c 65 76 65 6c 5f 2d 31 5d [block.level_-1]
2e10: 29 29 7b 0d 0a 20 20 20 20 20 20 74 68 69 73 2d )){.. this-
2e20: 3e 63 75 72 72 5f 63 6c 6f 73 65 28 29 3b 0d 0a >curr_close();..
2e30: 20 20 20 20 7d 0d 0a 20 20 20 20 72 65 74 75 72 }.. retur
2e40: 6e 3b 0d 0a 20 20 7d 0d 0a 20 20 0d 0a 20 20 69 n;.. }.. .. i
2e50: 66 28 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f 5b 30 f(blanks_line_[0
2e60: 5d 3c 3d 33 20 26 26 20 69 73 5f 63 68 61 72 73 ]<=3 && is_chars
2e70: 28 62 75 66 66 65 72 5b 53 45 5f 6c 69 6e 65 4e (buffer[SE_lineN
2e80: 6f 42 6c 61 6e 6b 5f 5b 30 5d 5d 2c 22 3c 22 29 oBlank_[0]],"<")
2e90: 29 7b 0d 0a 20 20 20 20 63 6f 6e 73 74 20 63 68 ){.. const ch
2ea0: 61 72 2a 20 72 65 78 73 53 74 61 72 74 5b 5d 3d ar* rexsStart[]=
2eb0: 7b 0d 0a 20 20 20 20 20 20 22 28 3f 69 6e 29 5c {.. "(?in)\
2ec0: 5c 41 3c 28 73 63 72 69 70 74 7c 70 72 65 7c 73 \A<(script|pre|s
2ed0: 74 79 6c 65 29 5c 5c 73 2a 3e 3f 24 22 2c 0d 0a tyle)\\s*>?$",..
2ee0: 20 20 20 20 20 20 20 20 22 28 3f 69 6e 29 5c 5c "(?in)\\
2ef0: 41 3c 21 2d 2d 22 2c 0d 0a 20 20 20 20 20 20 20 A<!--",..
2f00: 20 22 28 3f 69 6e 29 5c 5c 41 3c 5c 5c 3f 22 2c "(?in)\\A<\\?",
2f10: 0d 0a 20 20 20 20 20 20 20 20 22 28 3f 69 6e 29 .. "(?in)
2f20: 5c 5c 41 3c 21 5b 41 2d 5a 5d 22 2c 0d 0a 20 20 \\A<![A-Z]",..
2f30: 20 20 20 20 20 20 22 28 3f 69 6e 29 5c 5c 41 3c "(?in)\\A<
2f40: 21 5c 5c 5b 43 44 41 54 41 5c 5c 5b 22 2c 0d 0a !\\[CDATA\\[",..
2f50: 20 20 20 20 20 20 20 20 22 28 3f 69 6e 29 5c 5c "(?in)\\
2f60: 41 3c 2f 3f 28 61 64 64 72 65 73 73 7c 61 72 74 A</?(address|art
2f70: 69 63 6c 65 7c 61 73 69 64 65 7c 62 61 73 65 7c icle|aside|base|
2f80: 62 61 73 65 66 6f 6e 74 7c 62 6c 6f 63 6b 71 75 basefont|blockqu
2f90: 6f 74 65 7c 62 6f 64 79 7c 63 61 70 74 69 6f 6e ote|body|caption
2fa0: 7c 63 65 6e 74 65 72 7c 63 6f 6c 7c 63 6f 6c 67 |center|col|colg
2fb0: 72 6f 75 70 7c 22 0d 0a 20 20 20 20 20 20 20 20 roup|"..
2fc0: 22 64 64 7c 64 65 74 61 69 6c 73 7c 64 69 61 6c "dd|details|dial
2fd0: 6f 67 7c 64 69 72 7c 64 69 76 7c 64 6c 7c 64 74 og|dir|div|dl|dt
2fe0: 7c 66 69 65 6c 64 73 65 74 7c 66 69 67 63 61 70 |fieldset|figcap
2ff0: 74 69 6f 6e 7c 66 69 67 75 72 65 7c 66 6f 6f 74 tion|figure|foot
3000: 65 72 7c 66 6f 72 6d 7c 66 72 61 6d 65 7c 66 72 er|form|frame|fr
3010: 61 6d 65 73 65 74 7c 22 0d 0a 20 20 20 20 20 20 ameset|"..
3020: 20 20 22 68 31 7c 68 32 7c 68 33 7c 68 34 7c 68 "h1|h2|h3|h4|h
3030: 35 7c 68 36 7c 68 65 61 64 7c 68 65 61 64 65 72 5|h6|head|header
3040: 7c 68 72 7c 68 74 6d 6c 7c 69 66 72 61 6d 65 7c |hr|html|iframe|
3050: 6c 65 67 65 6e 64 7c 6c 69 7c 6c 69 6e 6b 7c 6d legend|li|link|m
3060: 61 69 6e 7c 6d 65 6e 75 7c 6d 65 6e 75 69 74 65 ain|menu|menuite
3070: 6d 7c 6e 61 76 7c 22 0d 0a 20 20 20 20 20 20 20 m|nav|"..
3080: 20 22 6e 6f 66 72 61 6d 65 73 7c 6f 6c 7c 6f 70 "noframes|ol|op
3090: 74 67 72 6f 75 70 7c 6f 70 74 69 6f 6e 7c 70 7c tgroup|option|p|
30a0: 70 61 72 61 6d 7c 73 65 63 74 69 6f 6e 7c 73 6f param|section|so
30b0: 75 72 63 65 7c 73 75 6d 6d 61 72 79 7c 74 61 62 urce|summary|tab
30c0: 6c 65 7c 74 62 6f 64 79 7c 74 64 7c 74 66 6f 6f le|tbody|td|tfoo
30d0: 74 7c 74 68 7c 22 0d 0a 20 20 20 20 20 20 20 20 t|th|"..
30e0: 22 74 68 65 61 64 7c 74 69 74 6c 65 7c 74 72 7c "thead|title|tr|
30f0: 74 72 61 63 6b 7c 75 6c 29 5c 5c 73 2a 2f 2a 3e track|ul)\\s*/*>
3100: 3f 24 22 2c 0d 0a 20 20 20 20 20 20 20 20 22 28 ?$",.. "(
3110: 3f 69 6e 29 5c 5c 41 3c 2f 3f 5b 2d 5c 5c 77 5d ?in)\\A</?[-\\w]
3120: 2b 5b 5e 3e 5d 2a 3e 24 22 0d 0a 20 20 20 20 20 +[^>]*>$"..
3130: 20 7d 3b 0d 0a 20 20 20 20 69 6e 74 20 6c 65 76 };.. int lev
3140: 65 6c 3d 30 3b 0d 0a 20 20 20 20 66 6f 72 28 69 el=0;.. for(i
3150: 6e 74 20 69 3d 30 3b 69 3c 37 3b 69 2b 2b 29 7b nt i=0;i<7;i++){
3160: 0d 0a 20 20 20 20 20 20 69 66 28 62 75 66 66 65 .. if(buffe
3170: 72 2e 72 65 67 65 78 70 28 53 45 5f 6c 69 6e 65 r.regexp(SE_line
3180: 4e 6f 42 6c 61 6e 6b 5f 5b 30 5d 2c 72 65 78 73 NoBlank_[0],rexs
3190: 53 74 61 72 74 5b 69 5d 29 29 7b 0d 0a 20 20 20 Start[i])){..
31a0: 20 20 20 20 20 6c 65 76 65 6c 3d 69 2b 31 3b 0d level=i+1;.
31b0: 0a 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d . break;.
31c0: 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d . }.. }.
31d0: 0a 20 20 20 20 69 66 28 28 6c 65 76 65 6c 3e 30 . if((level>0
31e0: 20 26 26 20 6c 65 76 65 6c 3c 37 29 20 7c 7c 20 && level<7) ||
31f0: 28 6c 65 76 65 6c 3d 3d 37 20 26 26 20 74 68 69 (level==7 && thi
3200: 73 2d 3e 63 75 72 72 5f 69 73 5f 6f 70 65 6e 28 s->curr_is_open(
3210: 29 3d 3d 30 29 29 7b 0d 0a 20 20 20 20 20 20 69 )==0)){.. i
3220: 66 28 62 6c 6f 63 6b 71 75 6f 74 65 5f 6c 65 76 f(blockquote_lev
3230: 65 6c 4e 21 3d 62 6c 6f 63 6b 71 75 6f 74 65 5f elN!=blockquote_
3240: 6c 65 76 65 6c 29 20 74 68 69 73 2d 3e 63 6c 6f level) this->clo
3250: 73 65 5f 61 6c 6c 28 29 3b 0d 0a 20 20 20 20 20 se_all();..
3260: 20 65 6c 73 65 20 69 66 28 74 68 69 73 2d 3e 63 else if(this->c
3270: 75 72 72 5f 69 73 5f 6f 70 65 6e 28 29 29 20 74 urr_is_open()) t
3280: 68 69 73 2d 3e 63 75 72 72 5f 63 6c 6f 73 65 28 his->curr_close(
3290: 29 3b 0d 0a 20 20 20 20 20 20 4d 4b 62 6c 6f 63 );.. MKbloc
32a0: 6b 73 26 20 62 6c 6f 63 6b 3d 74 68 69 73 2d 3e ks& block=this->
32b0: 61 70 70 65 6e 64 5f 62 6c 6f 63 6b 28 4d 4b 3a append_block(MK:
32c0: 3a 48 54 4d 4c 5f 62 6c 6f 63 6b 2c 53 45 5f 6c :HTML_block,SE_l
32d0: 69 6e 65 5f 2c 0d 0a 20 20 20 20 20 20 20 20 53 ine_,.. S
32e0: 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 2c 62 E_lineNoBlank_,b
32f0: 6c 61 6e 6b 73 5f 6c 69 6e 65 5f 29 3b 0d 0a 20 lanks_line_);..
3300: 20 20 20 20 20 62 6c 6f 63 6b 2e 6c 65 76 65 6c block.level
3310: 5f 3d 6c 65 76 65 6c 3b 0d 0a 20 20 20 20 20 20 _=level;..
3320: 72 65 74 75 72 6e 3b 0d 0a 20 20 20 20 7d 0d 0a return;.. }..
3330: 20 20 7d 0d 0a 20 20 0d 0a 2f 2f 23 23 23 23 23 }.. ..//#####
3340: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3350: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3360: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3370: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3380: 23 23 23 23 23 23 23 23 23 23 23 0d 0a 2f 2f 20 ###########..//
3390: 20 20 20 6c 69 6e 6b 5f 72 65 66 65 72 65 6e 63 link_referenc
33a0: 65 5f 64 65 66 69 6e 69 74 69 6f 6e 0d 0a 2f 2f e_definition..//
33b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
33c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
33d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
33e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
33f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3400: 0d 0a 20 20 0d 0a 20 20 69 66 28 21 74 68 69 73 .. .. if(!this
3410: 2d 3e 63 75 72 72 5f 69 73 5f 6f 70 65 6e 28 29 ->curr_is_open()
3420: 20 26 26 20 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f && blanks_line_
3430: 5b 30 5d 3c 3d 33 20 20 26 26 0d 0a 20 20 20 20 [0]<=3 &&..
3440: 69 73 5f 63 68 61 72 73 28 62 75 66 66 65 72 5b is_chars(buffer[
3450: 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b SE_lineNoBlank_[
3460: 30 5d 5d 2c 22 5b 22 29 29 7b 0d 0a 20 20 20 20 0]],"[")){..
3470: 69 6e 74 20 63 3d 6c 69 6e 6b 5f 6c 61 62 65 6c int c=link_label
3480: 5f 6e 75 6d 28 62 75 66 66 65 72 2c 53 45 5f 6c _num(buffer,SE_l
3490: 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 30 5d 29 3b ineNoBlank_[0]);
34a0: 0d 0a 20 20 20 20 69 6e 74 20 63 5f 6e 6f 62 6c .. int c_nobl
34b0: 61 6e 6b 3b 0d 0a 20 20 20 20 69 66 28 63 29 7b ank;.. if(c){
34c0: 0d 0a 20 20 20 20 20 20 69 66 28 62 75 66 66 65 .. if(buffe
34d0: 72 5b 63 5d 21 3d 27 3a 27 29 20 63 3d 30 3b 0d r[c]!=':') c=0;.
34e0: 0a 20 20 20 20 20 20 65 6c 73 65 20 63 2b 2b 3b . else c++;
34f0: 0d 0a 20 20 20 20 7d 0d 0a 20 20 20 20 69 66 28 .. }.. if(
3500: 63 29 7b 0d 0a 20 20 20 20 20 20 63 3d 6c 69 6e c){.. c=lin
3510: 6b 5f 64 65 73 74 69 6e 61 74 69 6f 6e 5f 6e 75 k_destination_nu
3520: 6d 28 62 75 66 66 65 72 2c 63 29 3b 0d 0a 20 20 m(buffer,c);..
3530: 20 20 7d 0d 0a 20 20 20 20 69 66 28 63 29 7b 0d }.. if(c){.
3540: 0a 20 20 20 20 20 20 69 6e 74 20 63 5f 61 6c 74 . int c_alt
3550: 3d 6c 69 6e 6b 5f 74 69 74 6c 65 5f 6e 75 6d 28 =link_title_num(
3560: 62 75 66 66 65 72 2c 63 29 3b 0d 0a 20 20 20 20 buffer,c);..
3570: 20 20 69 66 28 63 5f 61 6c 74 21 3d 30 29 7b 0d if(c_alt!=0){.
3580: 0a 20 20 20 20 20 20 20 20 69 6e 74 20 63 5f 61 . int c_a
3590: 6c 74 32 3d 73 70 61 63 65 73 5f 6e 75 6d 28 62 lt2=spaces_num(b
35a0: 75 66 66 65 72 2c 63 5f 61 6c 74 2c 6e 75 6d 5f uffer,c_alt,num_
35b0: 73 70 61 63 65 73 29 3b 0d 0a 20 20 20 20 20 20 spaces);..
35c0: 20 20 69 66 28 63 5f 61 6c 74 32 21 3d 30 29 7b if(c_alt2!=0){
35d0: 0d 0a 20 20 20 20 20 20 20 20 20 20 63 5f 6e 6f .. c_no
35e0: 62 6c 61 6e 6b 3d 63 5f 61 6c 74 3b 0d 0a 20 20 blank=c_alt;..
35f0: 20 20 20 20 20 20 20 20 63 3d 63 5f 61 6c 74 32 c=c_alt2
3600: 3b 0d 0a 20 20 20 20 20 20 20 20 7d 20 65 6c 73 ;.. } els
3610: 65 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 63 e {.. c
3620: 5f 61 6c 74 3d 30 3b 0d 0a 20 20 20 20 20 20 20 _alt=0;..
3630: 20 7d 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 }.. }..
3640: 20 20 20 69 66 28 63 5f 61 6c 74 3d 3d 30 29 7b if(c_alt==0){
3650: 0d 0a 20 20 20 20 20 20 20 20 63 5f 6e 6f 62 6c .. c_nobl
3660: 61 6e 6b 3d 63 3b 0d 0a 20 20 20 20 20 20 20 20 ank=c;..
3670: 63 3d 73 70 61 63 65 73 5f 6e 75 6d 28 62 75 66 c=spaces_num(buf
3680: 66 65 72 2c 63 2c 6e 75 6d 5f 73 70 61 63 65 73 fer,c,num_spaces
3690: 29 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 );.. }..
36a0: 20 7d 0d 0a 20 20 20 20 69 66 28 63 29 7b 0d 0a }.. if(c){..
36b0: 20 20 20 20 20 20 53 45 5f 6c 69 6e 65 4e 6f 42 SE_lineNoB
36c0: 6c 61 6e 6b 5f 5b 31 5d 3d 63 5f 6e 6f 62 6c 61 lank_[1]=c_nobla
36d0: 6e 6b 3b 0d 0a 20 20 20 20 20 20 53 45 5f 6c 69 nk;.. SE_li
36e0: 6e 65 5f 5b 31 5d 3d 63 3b 0d 0a 20 20 20 20 20 ne_[1]=c;..
36f0: 20 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f 5b 31 5d blanks_line_[1]
3700: 3d 63 2d 63 5f 6e 6f 62 6c 61 6e 6b 3b 0d 0a 20 =c-c_noblank;..
3710: 20 20 20 20 20 74 68 69 73 2d 3e 61 70 70 65 6e this->appen
3720: 64 5f 62 6c 6f 63 6b 28 4d 4b 3a 3a 6c 69 6e 6b d_block(MK::link
3730: 5f 72 65 66 65 72 65 6e 63 65 5f 64 65 66 69 6e _reference_defin
3740: 69 74 69 6f 6e 2c 53 45 5f 6c 69 6e 65 5f 2c 0d ition,SE_line_,.
3750: 0a 20 20 20 20 20 20 20 20 53 45 5f 6c 69 6e 65 . SE_line
3760: 4e 6f 42 6c 61 6e 6b 5f 2c 62 6c 61 6e 6b 73 5f NoBlank_,blanks_
3770: 6c 69 6e 65 5f 29 3b 0d 0a 20 20 20 20 20 20 70 line_);.. p
3780: 6f 73 5f 3d 53 45 5f 6c 69 6e 65 5f 5b 31 5d 3b os_=SE_line_[1];
3790: 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d .. return;.
37a0: 0a 20 20 20 20 7d 0d 0a 20 20 7d 0d 0a 20 20 0d . }.. }.. .
37b0: 0a 2f 2f 23 23 23 23 23 23 23 23 23 23 23 23 23 .//#############
37c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
37d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
37e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
37f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3800: 23 23 23 0d 0a 2f 2f 20 20 20 20 6e 6f 72 6d 61 ###..// norma
3810: 6c 20 70 61 72 61 67 72 61 70 68 0d 0a 2f 2f 23 l paragraph..//#
3820: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3830: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3840: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3850: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3860: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0d ###############.
3870: 0a 20 20 0d 0a 20 20 69 66 28 53 45 5f 6c 69 6e . .. if(SE_lin
3880: 65 4e 6f 42 6c 61 6e 6b 5f 5b 30 5d 3d 3d 53 45 eNoBlank_[0]==SE
3890: 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 31 5d _lineNoBlank_[1]
38a0: 2d 31 29 7b 0d 0a 20 20 20 20 69 66 28 62 6c 6f -1){.. if(blo
38b0: 63 6b 71 75 6f 74 65 5f 6c 65 76 65 6c 4e 21 3d ckquote_levelN!=
38c0: 62 6c 6f 63 6b 71 75 6f 74 65 5f 6c 65 76 65 6c blockquote_level
38d0: 29 20 74 68 69 73 2d 3e 63 6c 6f 73 65 5f 61 6c ) this->close_al
38e0: 6c 28 29 3b 0d 0a 20 20 20 20 65 6c 73 65 20 69 l();.. else i
38f0: 66 28 74 68 69 73 2d 3e 63 75 72 72 5f 69 73 5f f(this->curr_is_
3900: 6f 70 65 6e 28 29 29 20 74 68 69 73 2d 3e 63 75 open()) this->cu
3910: 72 72 5f 63 6c 6f 73 65 28 29 3b 0d 0a 20 20 7d rr_close();.. }
3920: 20 65 6c 73 65 20 69 66 28 74 68 69 73 2d 3e 63 else if(this->c
3930: 75 72 72 5f 69 73 5f 6f 70 65 6e 28 29 29 7b 0d urr_is_open()){.
3940: 0a 20 20 20 20 4d 4b 62 6c 6f 63 6b 73 26 20 62 . MKblocks& b
3950: 6c 6f 63 6b 3d 62 6c 6f 63 6b 73 5f 5b 6f 70 65 lock=blocks_[ope
3960: 6e 5f 62 6c 6f 63 6b 73 5f 5b 65 6e 64 5f 4d 54 n_blocks_[end_MT
3970: 53 5d 5d 3b 0d 0a 20 20 20 20 62 6c 6f 63 6b 2e S]];.. block.
3980: 70 6f 73 5f 5b 31 5d 3d 53 45 5f 6c 69 6e 65 5f pos_[1]=SE_line_
3990: 5b 31 5d 3b 0d 0a 20 20 20 20 62 6c 6f 63 6b 2e [1];.. block.
39a0: 70 6f 73 4e 6f 42 6c 61 6e 6b 5f 5b 31 5d 3d 53 posNoBlank_[1]=S
39b0: 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 31 E_lineNoBlank_[1
39c0: 5d 3b 0d 0a 20 20 20 20 62 6c 6f 63 6b 2e 62 6c ];.. block.bl
39d0: 61 6e 6b 73 5f 5b 31 5d 3d 62 6c 61 6e 6b 73 5f anks_[1]=blanks_
39e0: 6c 69 6e 65 5f 5b 31 5d 3b 0d 0a 20 20 7d 20 65 line_[1];.. } e
39f0: 6c 73 65 20 7b 0d 0a 20 20 20 20 69 66 28 62 6c lse {.. if(bl
3a00: 6f 63 6b 71 75 6f 74 65 5f 6c 65 76 65 6c 4e 21 ockquote_levelN!
3a10: 3d 62 6c 6f 63 6b 71 75 6f 74 65 5f 6c 65 76 65 =blockquote_leve
3a20: 6c 29 20 74 68 69 73 2d 3e 63 6c 6f 73 65 5f 61 l) this->close_a
3a30: 6c 6c 28 29 3b 0d 0a 20 20 20 20 74 68 69 73 2d ll();.. this-
3a40: 3e 61 70 70 65 6e 64 5f 62 6c 6f 63 6b 28 4d 4b >append_block(MK
3a50: 3a 3a 70 61 72 61 67 72 61 70 68 2c 53 45 5f 6c ::paragraph,SE_l
3a60: 69 6e 65 5f 2c 53 45 5f 6c 69 6e 65 4e 6f 42 6c ine_,SE_lineNoBl
3a70: 61 6e 6b 5f 2c 0d 0a 20 20 20 20 20 20 62 6c 61 ank_,.. bla
3a80: 6e 6b 73 5f 6c 69 6e 65 5f 29 3b 0d 0a 20 20 7d nks_line_);.. }
3a90: 0d 0a 7d 0d 0a 0d 0a 76 6f 69 64 20 4d 4b 73 74 ..}....void MKst
3aa0: 61 74 65 3a 3a 70 72 6f 63 65 73 73 5f 6d 61 72 ate::process_mar
3ab0: 6b 64 6f 77 6e 28 4d 79 54 53 63 68 61 72 26 20 kdown(MyTSchar&
3ac0: 62 75 66 66 65 72 29 0d 0a 7b 0d 0a 20 20 4d 4b buffer)..{.. MK
3ad0: 62 6c 6f 63 6b 73 26 20 62 6c 6f 63 6b 3d 74 68 blocks& block=th
3ae0: 69 73 2d 3e 61 70 70 65 6e 64 5f 62 6c 6f 63 6b is->append_block
3af0: 28 4d 4b 3a 3a 64 6f 63 75 6d 65 6e 74 29 3b 0d (MK::document);.
3b00: 0a 20 20 62 6c 6f 63 6b 2e 6f 70 65 6e 5f 3d 30 . block.open_=0
3b10: 3b 0d 0a 20 20 20 20 0d 0a 20 20 66 6f 72 28 69 ;.. .. for(i
3b20: 6e 74 20 69 3d 30 3b 69 3c 62 75 66 66 65 72 2e nt i=0;i<buffer.
3b30: 6e 75 6d 28 29 3b 69 2b 2b 29 7b 0d 0a 20 20 20 num();i++){..
3b40: 20 73 77 69 74 63 68 28 62 75 66 66 65 72 5b 69 switch(buffer[i
3b50: 5d 29 7b 0d 0a 20 20 20 20 20 20 63 61 73 65 20 ]){.. case
3b60: 27 20 27 3a 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 ' ':.. {..
3b70: 20 20 20 20 20 20 20 69 66 28 53 45 5f 6c 69 6e if(SE_lin
3b80: 65 5f 5b 30 5d 3d 3d 2d 31 29 7b 0d 0a 20 20 20 e_[0]==-1){..
3b90: 20 20 20 20 20 20 20 53 45 5f 6c 69 6e 65 5f 5b SE_line_[
3ba0: 30 5d 3d 69 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0]=i;.. }
3bb0: 0d 0a 20 20 20 20 20 20 20 20 69 66 28 53 45 5f .. if(SE_
3bc0: 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 30 5d 3d lineNoBlank_[0]=
3bd0: 3d 2d 31 29 7b 0d 0a 20 20 20 20 20 20 20 20 20 =-1){..
3be0: 20 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f 5b 30 5d blanks_line_[0]
3bf0: 2b 2b 3b 0d 0a 20 20 20 20 20 20 20 20 7d 20 65 ++;.. } e
3c00: 6c 73 65 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 lse {..
3c10: 20 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f 5b 31 5d blanks_line_[1]
3c20: 2b 2b 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a ++;.. }..
3c30: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 62 }.. b
3c40: 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 63 61 73 reak;.. cas
3c50: 65 20 27 5c 74 27 3a 0d 0a 20 20 20 20 20 20 7b e '\t':.. {
3c60: 0d 0a 20 20 20 20 20 20 20 20 69 66 28 53 45 5f .. if(SE_
3c70: 6c 69 6e 65 5f 5b 30 5d 3d 3d 2d 31 29 7b 0d 0a line_[0]==-1){..
3c80: 20 20 20 20 20 20 20 20 20 20 53 45 5f 6c 69 6e SE_lin
3c90: 65 5f 5b 30 5d 3d 69 3b 0d 0a 20 20 20 20 20 20 e_[0]=i;..
3ca0: 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 69 66 28 }.. if(
3cb0: 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b SE_lineNoBlank_[
3cc0: 30 5d 3d 3d 2d 31 29 7b 0d 0a 20 20 20 20 20 20 0]==-1){..
3cd0: 20 20 20 20 62 6c 61 6e 6b 73 5f 6c 69 6e 65 5f blanks_line_
3ce0: 5b 30 5d 2b 3d 34 3b 0d 0a 20 20 20 20 20 20 20 [0]+=4;..
3cf0: 20 7d 20 65 6c 73 65 20 7b 0d 0a 20 20 20 20 20 } else {..
3d00: 20 20 20 20 20 62 6c 61 6e 6b 73 5f 6c 69 6e 65 blanks_line
3d10: 5f 5b 31 5d 2b 3d 34 3b 0d 0a 20 20 20 20 20 20 _[1]+=4;..
3d20: 20 20 7d 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 }.. }..
3d30: 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 break;..
3d40: 20 20 63 61 73 65 20 27 5c 6e 27 3a 20 20 63 61 case '\n': ca
3d50: 73 65 20 27 5c 72 27 3a 0d 0a 20 20 20 20 20 20 se '\r':..
3d60: 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 28 53 45 {.. if(SE
3d70: 5f 6c 69 6e 65 5f 5b 30 5d 3d 3d 2d 31 29 7b 0d _line_[0]==-1){.
3d80: 0a 20 20 20 20 20 20 20 20 20 20 53 45 5f 6c 69 . SE_li
3d90: 6e 65 5f 5b 30 5d 3d 69 3b 0d 0a 20 20 20 20 20 ne_[0]=i;..
3da0: 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 69 66 }.. if
3db0: 28 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f (SE_lineNoBlank_
3dc0: 5b 30 5d 3d 3d 2d 31 29 7b 0d 0a 20 20 20 20 20 [0]==-1){..
3dd0: 20 20 20 20 20 53 45 5f 6c 69 6e 65 4e 6f 42 6c SE_lineNoBl
3de0: 61 6e 6b 5f 5b 30 5d 3d 69 3b 0d 0a 20 20 20 20 ank_[0]=i;..
3df0: 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 69 }.. i
3e00: 66 28 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b f(SE_lineNoBlank
3e10: 5f 5b 31 5d 3d 3d 2d 31 29 7b 0d 0a 20 20 20 20 _[1]==-1){..
3e20: 20 20 20 20 20 20 53 45 5f 6c 69 6e 65 4e 6f 42 SE_lineNoB
3e30: 6c 61 6e 6b 5f 5b 31 5d 3d 69 3b 0d 0a 20 20 20 lank_[1]=i;..
3e40: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
3e50: 53 45 5f 6c 69 6e 65 5f 5b 31 5d 3d 69 3b 0d 0a SE_line_[1]=i;..
3e60: 20 20 20 20 20 20 20 20 0d 0a 20 20 20 20 20 20 ..
3e70: 20 20 70 6f 73 5f 3d 69 3b 0d 0a 20 20 20 20 20 pos_=i;..
3e80: 20 20 20 74 68 69 73 2d 3e 63 72 65 61 74 65 5f this->create_
3e90: 61 70 70 65 6e 64 5f 70 61 72 61 67 72 61 70 68 append_paragraph
3ea0: 28 62 75 66 66 65 72 29 3b 0d 0a 20 20 20 20 20 (buffer);..
3eb0: 20 20 20 69 3d 70 6f 73 5f 3b 0d 0a 20 20 20 20 i=pos_;..
3ec0: 20 20 20 20 0d 0a 20 20 20 20 20 20 20 20 53 45 .. SE
3ed0: 5f 6c 69 6e 65 5f 5b 30 5d 3d 53 45 5f 6c 69 6e _line_[0]=SE_lin
3ee0: 65 5f 5b 31 5d 3d 2d 31 3b 0d 0a 20 20 20 20 20 e_[1]=-1;..
3ef0: 20 20 20 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e SE_lineNoBlan
3f00: 6b 5f 5b 30 5d 3d 53 45 5f 6c 69 6e 65 4e 6f 42 k_[0]=SE_lineNoB
3f10: 6c 61 6e 6b 5f 5b 31 5d 3d 2d 31 3b 0d 0a 20 20 lank_[1]=-1;..
3f20: 20 20 20 20 20 20 62 6c 61 6e 6b 73 5f 6c 69 6e blanks_lin
3f30: 65 5f 5b 30 5d 3d 30 3b 0d 0a 0d 0a 20 20 20 20 e_[0]=0;....
3f40: 20 20 20 20 69 66 28 69 3c 62 75 66 66 65 72 2e if(i<buffer.
3f50: 6e 75 6d 28 29 2d 31 20 26 26 20 62 75 66 66 65 num()-1 && buffe
3f60: 72 5b 69 5d 3d 3d 27 5c 72 27 20 26 26 20 62 75 r[i]=='\r' && bu
3f70: 66 66 65 72 5b 69 2b 31 5d 3d 3d 27 5c 6e 27 29 ffer[i+1]=='\n')
3f80: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 69 2b 2b {.. i++
3f90: 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 ;.. }..
3fa0: 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 62 72 65 }.. bre
3fb0: 61 6b 3b 0d 0a 20 20 20 20 20 20 64 65 66 61 75 ak;.. defau
3fc0: 6c 74 3a 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 lt:.. {..
3fd0: 20 20 20 20 20 20 69 66 28 53 45 5f 6c 69 6e 65 if(SE_line
3fe0: 5f 5b 30 5d 3d 3d 2d 31 29 7b 0d 0a 20 20 20 20 _[0]==-1){..
3ff0: 20 20 20 20 20 20 53 45 5f 6c 69 6e 65 5f 5b 30 SE_line_[0
4000: 5d 3d 69 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d ]=i;.. }.
4010: 0a 20 20 20 20 20 20 20 20 69 66 28 53 45 5f 6c . if(SE_l
4020: 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b 30 5d 3d 3d ineNoBlank_[0]==
4030: 2d 31 29 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 -1){..
4040: 53 45 5f 6c 69 6e 65 4e 6f 42 6c 61 6e 6b 5f 5b SE_lineNoBlank_[
4050: 30 5d 3d 69 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0]=i;.. }
4060: 0d 0a 20 20 20 20 20 20 20 20 53 45 5f 6c 69 6e .. SE_lin
4070: 65 4e 6f 42 6c 61 6e 6b 5f 5b 31 5d 3d 69 3b 0d eNoBlank_[1]=i;.
4080: 0a 20 20 20 20 20 20 20 20 62 6c 61 6e 6b 73 5f . blanks_
4090: 6c 69 6e 65 5f 5b 31 5d 3d 30 3b 0d 0a 20 20 20 line_[1]=0;..
40a0: 20 20 20 7d 0d 0a 20 20 20 20 20 20 62 72 65 61 }.. brea
40b0: 6b 3b 0d 0a 20 20 20 20 7d 0d 0a 20 20 7d 0d 0a k;.. }.. }..
40c0: 7d 0d 0a 0d 0a 69 6e 74 20 70 72 6f 63 65 73 73 }....int process
40d0: 5f 6d 61 72 6b 64 6f 77 6e 28 29 0d 0a 7b 0d 0a _markdown()..{..
40e0: 20 20 4d 79 54 53 63 68 61 72 20 62 75 66 66 65 MyTSchar buffe
40f0: 72 3b 0d 0a 20 20 0d 0a 20 20 63 6f 6e 73 74 20 r;.. .. const
4100: 63 68 61 72 2a 20 66 69 6c 65 49 6e 3d 22 43 3a char* fileIn="C:
4110: 5c 5c 55 73 65 72 73 5c 5c 72 61 6d 73 61 6e 5c \\Users\\ramsan\
4120: 5c 44 72 6f 70 62 6f 78 5c 5c 74 65 6d 70 6f 72 \Dropbox\\tempor
4130: 61 6c 5c 5c 6b 6b 64 6f 63 5c 5c 73 74 72 65 6e al\\kkdoc\\stren
4140: 67 74 68 73 5f 69 6e 5f 73 68 65 6c 6c 73 2e 6d gths_in_shells.m
4150: 64 22 3b 0d 0a 20 20 63 6f 6e 73 74 20 63 68 61 d";.. const cha
4160: 72 2a 20 66 69 6c 65 4f 75 74 3d 22 43 3a 5c 5c r* fileOut="C:\\
4170: 55 73 65 72 73 5c 5c 72 61 6d 73 61 6e 5c 5c 44 Users\\ramsan\\D
4180: 72 6f 70 62 6f 78 5c 5c 74 65 6d 70 6f 72 61 6c ropbox\\temporal
4190: 5c 5c 6b 6b 64 6f 63 5c 5c 73 74 72 65 6e 67 74 \\kkdoc\\strengt
41a0: 68 73 5f 69 6e 5f 73 68 65 6c 6c 73 2e 68 74 6d hs_in_shells.htm
41b0: 6c 22 3b 0d 0a 20 20 0d 0a 20 20 46 49 4c 45 2a l";.. .. FILE*
41c0: 20 66 69 6e 3d 66 6f 70 65 6e 28 66 69 6c 65 49 fin=fopen(fileI
41d0: 6e 2c 22 72 62 22 29 3b 0d 0a 20 20 69 66 28 21 n,"rb");.. if(!
41e0: 66 69 6e 29 7b 0d 0a 20 20 20 20 66 70 72 69 6e fin){.. fprin
41f0: 74 66 28 73 74 64 65 72 72 2c 22 66 69 6c 65 20 tf(stderr,"file
4200: 6e 6f 74 20 66 6f 75 6e 64 5c 6e 22 29 3b 0d 0a not found\n");..
4210: 20 20 20 20 65 78 69 74 28 32 29 3b 0d 0a 20 20 exit(2);..
4220: 7d 0d 0a 20 20 66 73 65 65 6b 28 66 69 6e 2c 30 }.. fseek(fin,0
4230: 2c 53 45 45 4b 5f 45 4e 44 29 3b 0d 0a 20 20 73 ,SEEK_END);.. s
4240: 69 7a 65 5f 74 20 6c 53 69 7a 65 3d 66 74 65 6c ize_t lSize=ftel
4250: 6c 28 66 69 6e 29 3b 0d 0a 20 20 72 65 77 69 6e l(fin);.. rewin
4260: 64 28 66 69 6e 29 3b 0d 0a 20 20 0d 0a 20 20 62 d(fin);.. .. b
4270: 75 66 66 65 72 2e 73 65 74 5f 6e 75 6d 28 6c 53 uffer.set_num(lS
4280: 69 7a 65 29 3b 0d 0a 20 20 73 69 7a 65 5f 74 20 ize);.. size_t
4290: 72 65 73 75 6c 74 3d 66 72 65 61 64 28 62 75 66 result=fread(buf
42a0: 66 65 72 2e 76 28 29 2c 31 2c 6c 53 69 7a 65 2c fer.v(),1,lSize,
42b0: 66 69 6e 29 3b 0d 0a 20 20 66 63 6c 6f 73 65 28 fin);.. fclose(
42c0: 66 69 6e 29 3b 0d 0a 20 20 69 66 28 72 65 73 75 fin);.. if(resu
42d0: 6c 74 21 3d 6c 53 69 7a 65 29 7b 0d 0a 20 20 20 lt!=lSize){..
42e0: 20 66 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c fprintf(stderr,
42f0: 22 66 69 6c 65 20 72 65 61 64 20 69 6e 63 6f 72 "file read incor
4300: 72 65 63 74 6c 79 5c 6e 22 29 3b 0d 0a 20 20 20 rectly\n");..
4310: 20 65 78 69 74 28 32 29 3b 0d 0a 20 20 7d 0d 0a exit(2);.. }..
4320: 20 20 4d 4b 73 74 61 74 65 20 6d 6b 73 74 61 74 MKstate mkstat
4330: 65 3b 0d 0a 20 20 6d 6b 73 74 61 74 65 2e 70 72 e;.. mkstate.pr
4340: 6f 63 65 73 73 5f 6d 61 72 6b 64 6f 77 6e 28 62 ocess_markdown(b
4350: 75 66 66 65 72 29 3b 0d 0a 20 20 72 65 74 75 72 uffer);.. retur
4360: 6e 20 30 3b 0d 0a 7d 0d 0a 20 20 n 0;..}..