Subversion Repositories spacemission

Rev

Rev 76 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 76 Rev 79
Line 32... Line 32...
32
procedure THilfeForm.ShowHTMLHelp(AHTML: string);
32
procedure THilfeForm.ShowHTMLHelp(AHTML: string);
33
var
33
var
34
  DOC: Variant;
34
  DOC: Variant;
35
begin
35
begin
36
  if not Assigned(WebBrowser1.Document) then
36
  if not Assigned(WebBrowser1.Document) then
37
    WebBrowser1.Navigate('about:blank');
37
    WebBrowser1.Navigate('about:blank'); // do not localize
38
 
38
 
39
  DOC := WebBrowser1.Document;
39
  DOC := WebBrowser1.Document;
40
  DOC.Clear;
40
  DOC.Clear;
41
  DOC.Write(AHTML);
41
  DOC.Write(AHTML);
42
  Doc.Close;
42
  Doc.Close;
Line 51... Line 51...
51
  FDirectory := ExtractFilePath(AMarkDownFile);
51
  FDirectory := ExtractFilePath(AMarkDownFile);
52
  slHtml := TStringList.Create();
52
  slHtml := TStringList.Create();
53
  slCss := TStringList.Create();
53
  slCss := TStringList.Create();
54
  try
54
  try
55
    slHtml.LoadFromFile(AMarkDownFile);
55
    slHtml.LoadFromFile(AMarkDownFile);
56
    cssFile := IncludeTrailingPathDelimiter(FDirectory) + 'Style.css';
56
    cssFile := IncludeTrailingPathDelimiter(FDirectory) + 'Style.css'; // do not localize
57
    if FileExists(cssFile) then
57
    if FileExists(cssFile) then
58
      slCss.LoadFromFile(cssFile);
58
      slCss.LoadFromFile(cssFile);
59
    md := TMarkdownProcessor.CreateDialect(mdCommonMark);
59
    md := TMarkdownProcessor.CreateDialect(mdCommonMark);
60
    try
60
    try
61
      //md.AllowUnsafe := true;
61
      //md.AllowUnsafe := true;
62
      ShowHTMLHelp(
62
      ShowHTMLHelp(
63
        '<html>'+
63
        '<html>'+                                                                // do not localize
64
        '<head>'+
64
        '<head>'+                                                                // do not localize
65
        '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'+
65
        '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'+   // do not localize
66
        '<style>'+slCss.Text+'</style>'+
66
        '<style>'+slCss.Text+'</style>'+                                         // do not localize
67
        '</head>'+
67
        '</head>'+                                                               // do not localize
68
        '<body>'+
68
        '<body>'+                                                                // do not localize
69
        md.process(UTF8ToString(RawByteString(slHtml.Text)))+
69
        md.process(UTF8ToString(RawByteString(slHtml.Text)))+
70
        '</body>'+
70
        '</body>'+                                                               // do not localize
71
        '</html>');
71
        '</html>');                                                              // do not localize
72
    finally
72
    finally
73
      FreeAndNil(md);
73
      FreeAndNil(md);
74
    end;
74
    end;
75
  finally
75
  finally
76
    FreeAndNil(slHtml);
76
    FreeAndNil(slHtml);
Line 80... Line 80...
80
 
80
 
81
procedure THilfeForm.WebBrowser1BeforeNavigate2(ASender: TObject;
81
procedure THilfeForm.WebBrowser1BeforeNavigate2(ASender: TObject;
82
  const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData,
82
  const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData,
83
  Headers: OleVariant; var Cancel: WordBool);
83
  Headers: OleVariant; var Cancel: WordBool);
84
begin
84
begin
85
  if SameText(Copy(URL,1,7),'http://') or
85
  if SameText(Copy(URL,1,7),'http://') or      // do not localize
86
     SameText(Copy(URL,1,8),'https://') or
86
     SameText(Copy(URL,1,8),'https://') or     // do not localize
87
     SameText(Copy(URL,1,7),'mailto:') then
87
     SameText(Copy(URL,1,7),'mailto:') then    // do not localize
88
  begin
88
  begin
89
    // Links in default Browser anzeigen
89
    // Links in default Browser anzeigen
90
    ShellExecute(handle, 'open', PChar(string(URL)), '', '', SW_NORMAL);
90
    ShellExecute(handle, 'open', PChar(string(URL)), '', '', SW_NORMAL);  // do not localize
91
    Cancel := true;
91
    Cancel := true;
92
  end
92
  end
93
  else if SameText(ExtractFileExt(URL), '.md') then
93
  else if SameText(ExtractFileExt(URL), '.md') then // do not localize
94
  begin
94
  begin
95
    if SameText(Copy(URL,1,6), 'about:') then
95
    if SameText(Copy(URL,1,6), 'about:') then // do not localize
96
      ShowMarkDownHelp(IncludeTrailingPathDelimiter(FDirectory) + Copy(URL,7,Length(URL)))
96
      ShowMarkDownHelp(IncludeTrailingPathDelimiter(FDirectory) + Copy(URL,7,Length(URL)))
97
    else
97
    else
98
      ShowMarkDownHelp(URL);
98
      ShowMarkDownHelp(URL);
99
    Cancel := true;
99
    Cancel := true;
100
  end
100
  end