|
@@ -17,6 +17,8 @@ Class MarkdownConvertor
|
|
|
|
|
|
_lineNum=0
|
|
_lineNum=0
|
|
|
|
|
|
|
|
+ _para=False
|
|
|
|
+
|
|
_buf.Clear()
|
|
_buf.Clear()
|
|
|
|
|
|
For Local i:=0 Until _lines.Length
|
|
For Local i:=0 Until _lines.Length
|
|
@@ -29,41 +31,55 @@ Class MarkdownConvertor
|
|
If Not line Continue
|
|
If Not line Continue
|
|
|
|
|
|
If line.StartsWith( "#" )
|
|
If line.StartsWith( "#" )
|
|
|
|
+
|
|
|
|
+ EndPara()
|
|
|
|
|
|
EmitHeader( line )
|
|
EmitHeader( line )
|
|
|
|
|
|
Else If line.StartsWith( "|" )
|
|
Else If line.StartsWith( "|" )
|
|
|
|
|
|
|
|
+ EndPara()
|
|
|
|
+
|
|
EmitTable( line )
|
|
EmitTable( line )
|
|
|
|
|
|
Else If line.StartsWith( "*" )
|
|
Else If line.StartsWith( "*" )
|
|
|
|
|
|
|
|
+ EndPara()
|
|
|
|
+
|
|
EmitList( line )
|
|
EmitList( line )
|
|
|
|
|
|
Else If line.StartsWith( "<" )
|
|
Else If line.StartsWith( "<" )
|
|
|
|
|
|
|
|
+ EndPara()
|
|
|
|
+
|
|
Emit( line+"\" )
|
|
Emit( line+"\" )
|
|
|
|
|
|
Else If line.StartsWith( "---" )
|
|
Else If line.StartsWith( "---" )
|
|
|
|
|
|
|
|
+ EndPara()
|
|
|
|
+
|
|
Emit( "<hr class="+_cls+">" )
|
|
Emit( "<hr class="+_cls+">" )
|
|
|
|
|
|
Else If line.StartsWith( "```" ) Or line.ToLower().StartsWith( "<pre>" )
|
|
Else If line.StartsWith( "```" ) Or line.ToLower().StartsWith( "<pre>" )
|
|
|
|
|
|
|
|
+ EndPara()
|
|
|
|
+
|
|
EmitCode( line )
|
|
EmitCode( line )
|
|
|
|
|
|
Else
|
|
Else
|
|
|
|
|
|
- If _lineNum>1 And _lines[_lineNum-2]=""
|
|
|
|
- Emit( "<p class="+_cls+">"+Escape( line ) )
|
|
|
|
- Else
|
|
|
|
- Emit( Escape( line ) )
|
|
|
|
|
|
+ If Not _para Or (_lineNum>1 And _lines[_lineNum-2]="")
|
|
|
|
+ EndPara()
|
|
|
|
+ BeginPara()
|
|
Endif
|
|
Endif
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ Emit( Escape( line ) )
|
|
Endif
|
|
Endif
|
|
|
|
|
|
Wend
|
|
Wend
|
|
|
|
|
|
|
|
+ EndPara()
|
|
|
|
+
|
|
Local html:=_buf.Join( "~n" )
|
|
Local html:=_buf.Join( "~n" )
|
|
|
|
|
|
html=html.Replace( "\~n","" )
|
|
html=html.Replace( "\~n","" )
|
|
@@ -87,9 +103,23 @@ Class MarkdownConvertor
|
|
Field _lineNum:=0
|
|
Field _lineNum:=0
|
|
Field _buf:=New StringStack
|
|
Field _buf:=New StringStack
|
|
|
|
|
|
|
|
+ Field _para:Bool=False
|
|
|
|
+
|
|
Property AtEnd:Bool()
|
|
Property AtEnd:Bool()
|
|
Return _lineNum>=_lines.Length
|
|
Return _lineNum>=_lines.Length
|
|
End
|
|
End
|
|
|
|
+
|
|
|
|
+ Method BeginPara()
|
|
|
|
+ If _para Return
|
|
|
|
+ Emit( "<p class="+_cls+">" )
|
|
|
|
+ _para=True
|
|
|
|
+ End
|
|
|
|
+
|
|
|
|
+ Method EndPara()
|
|
|
|
+ If Not _para Return
|
|
|
|
+ Emit( "</p>" )
|
|
|
|
+ _para=False
|
|
|
|
+ End
|
|
|
|
|
|
Method Emit( str:String )
|
|
Method Emit( str:String )
|
|
_buf.Push( str )
|
|
_buf.Push( str )
|