Browse Source

* Fix warnings

Michaël Van Canneyt 6 hours ago
parent
commit
798dc13f9b

+ 7 - 16
packages/fcl-md/src/markdown.fpdocrender.pas

@@ -65,7 +65,6 @@ type
     procedure RenderToStream(aDocument : TMarkDownDocument; aStream : TStream);
     Procedure RenderDocument(aDocument : TMarkDownDocument); override;overload;
     Procedure RenderDocument(aDocument : TMarkDownDocument; aDest : TStrings); overload;
-    procedure RenderChildren(aBlock : TMarkDownContainerBlock; aAppendNewLine : Boolean); overload;
     function RenderFPDoc(aDocument : TMarkDownDocument) : string;
     Property PackageName : String read FPackageName Write FPackageName;
     Property FPDoc : String Read FFPDoc;
@@ -253,7 +252,7 @@ end;
 
 procedure TFPDocMarkDownBlockRenderer.CheckParent(const aParent, aChild: String);
 begin
-  if (Parent.NodeName<>aParent) then
+  if (UTF8Encode(Parent.NodeName)<>aParent) then
     Raise EFPDocRender.CreateFmt('Cannot have %s below %s',[aChild,aParent]);
 end;
 
@@ -333,10 +332,10 @@ end;
 
 function TMarkDownFPDocRenderer.Push(const aElementName: String; const aName: string): TDOMElement;
 begin
-  Result:=FDoc.CreateElement(aElementName);
+  Result:=FDoc.CreateElement(UTF8Decode(aElementName));
   PushElement(Result);
   if aName<>'' then
-    Result['name']:=aName;
+    Result['name']:=UTF8Decode(aName);
 end;
 
 procedure TMarkDownFPDocRenderer.PushElement(aElement: TDomElement);
@@ -364,7 +363,7 @@ end;
 
 procedure TMarkDownFPDocRenderer.AppendText(const aContent: String);
 begin
-  Parent.AppendChild(FDoc.CreateTextNode(aContent))
+  Parent.AppendChild(FDoc.CreateTextNode(UTF8Decode(aContent)));
 end;
 
 function TMarkDownFPDocRenderer.PushSection(aSection: TSectionType): TDomElement;
@@ -380,7 +379,7 @@ end;
 
 function TMarkDownFPDocRenderer.PopTill(const aElementName: string): TDomElement;
 begin
-  PopTill([aElementName]);
+  Result:=PopTill([aElementName]);
 end;
 
 
@@ -442,14 +441,6 @@ begin
   aDest.Text:=RenderFPDoc(aDocument);
 end;
 
-procedure TMarkDownFPDocRenderer.RenderChildren(aBlock: TMarkDownContainerBlock; aAppendNewLine: Boolean);
-var
-  i : integer;
-begin
-  for I:=0 to aBlock.Blocks.Count-1 do
-    RenderBlock(aBlock.Blocks[I]);
-end;
-
 function TMarkDownFPDocRenderer.RenderFPDoc(aDocument: TMarkDownDocument): string;
 begin
   RenderDocument(aDocument);
@@ -618,7 +609,7 @@ function TFPDocMarkDownTextRenderer.renderAttrs(aElement: TMarkDownTextNode): An
   begin
     lKey:=KeyAlias(aKey);
     if lKey<>'' then
-      FPDoc.Parent[lKey]:=aValue;
+      FPDoc.Parent[UTF8Decode(lKey)]:=UTF8Decode(aValue);
   end;
 
 var
@@ -756,7 +747,7 @@ begin
   fpDoc.Push('li');
   For lBlock in lItemBlock.Blocks do
     if IsPlainBlock(lBlock) then
-      FPDoc.RenderChildren(lPar,True)
+      FPDoc.RenderChildren(lPar)
     else
       Renderer.RenderBlock(lBlock);
   fpDoc.Pop;

+ 3 - 2
packages/fcl-md/src/markdown.htmlrender.pas

@@ -658,10 +658,11 @@ var
   lLang : string;
 begin
   lLang:=lNode.Lang;
+  AppendNL('');
   if lLang<> '' then
-    Append('<pre><code class="language-'+lLang+'">')
+    AppendNl('<pre><code class="language-'+lLang+'">')
   else
-    Append('<pre><code>');
+    AppendNl('<pre><code>');
   for lBlock in LNode.Blocks do
     begin
     Renderer.RenderCodeBlock(LBlock,lLang);

+ 1 - 1
packages/fcl-md/src/markdown.latexrender.pas

@@ -23,7 +23,7 @@ uses
 {$IFDEF FPC_DOTTEDUNITS}
   System.Classes, System.SysUtils, System.StrUtils, System.Contnrs, 
 {$ELSE}
-  Classes, SysUtils, strutils, contnrs, 
+  Classes, SysUtils,  contnrs,
 {$ENDIF}  
   MarkDown.Elements, 
   MarkDown.Render, 

+ 1 - 1
packages/fcl-md/src/markdown.line.pas

@@ -51,7 +51,7 @@ type
     // Line is the text with initial tabs replaced by spaces.
     property Line : AnsiString Read FLine;
     property LineNo : integer Read FLineNo;
-
+    Property CursorPos : Integer Read FCursor;
   end;
   TMarkDownLineList = class (specialize TGFPObjectList<TMarkDownLine>);
 

+ 1 - 0
packages/fcl-md/src/markdown.render.pas

@@ -378,6 +378,7 @@ function TMarkDownElementRenderer.GetParentRenderers: TMarkDownElementRendererAr
 var
   i : integer;
 begin
+  Result:=[];
   SetLength(Result,Renderer.FRenderStack.Count);
   For I:=0 to Renderer.FRenderStack.Count-1 do
     Result[i]:=TMarkDownElementRenderer(Renderer.FRenderStack.items[i]);

+ 2 - 0
packages/fcl-md/tests/testmd.lpi

@@ -41,6 +41,7 @@
       <Unit>
         <Filename Value="utest.markdown.utils.pas"/>
         <IsPartOfProject Value="True"/>
+        <UnitName Value="UTest.Markdown.Utils"/>
       </Unit>
       <Unit>
         <Filename Value="../src/markdown.elements.pas"/>
@@ -105,6 +106,7 @@
       <Unit>
         <Filename Value="utest.markdown.parser.pas"/>
         <IsPartOfProject Value="True"/>
+        <UnitName Value="UTest.Markdown.Parser"/>
       </Unit>
       <Unit>
         <Filename Value="../src/markdown.processors.pas"/>

+ 1 - 2
packages/fcl-md/tests/utest.markdown.fpdocrender.pas

@@ -95,8 +95,7 @@ begin
 end;
 
 procedure TTestFPDocRender.StartDoc;
-var
-  l : TMarkDownBlock;
+
 begin
   CreateHeadingBlock('unit1',1);
   CreateHeadingBlock('a',2);

+ 1 - 1
packages/fcl-md/tests/utest.markdown.utils.pas

@@ -278,7 +278,7 @@ begin
   if Length(arr) = 3 then
   begin
     AssertEquals('First char should be a', 'a', arr[0]);
-    AssertEquals('Second char should be €','€', arr[1]);
+    AssertEquals('Second char should be €','€', UTF8Encode(arr[1]));
     AssertEquals('Third char should be b', 'b', arr[2]);
   end;
   AssertEquals('Array length for empty string', 0, Length(ToUnicodeChars('')));