Skip to content

Commit ee341d0

Browse files
ver. 1.3.0
- Added support for Delphi 13 - Added command line utility MarkDownToHTML.exe
1 parent c1e1c1d commit ee341d0

25 files changed

+2816
-41
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
call "C:\BDS\Studio\37.0\bin\rsvars.bat"
2+
msbuild.exe "MarkDownToHTML.dproj" /target:Clean;Build /p:Platform=Win64 /p:config=release
3+
msbuild.exe "MarkDownToHTML.dproj" /target:Clean;Build /p:Platform=Win32 /p:config=release
4+
5+
call D:\ETHEA\Certificate\SignFileWithSectico.bat D:\ETHEA\MarkdownProcessor\Cmd\MarkdownToHTML\Bin\Win32\MarkDownToHTML.exe
6+
call D:\ETHEA\Certificate\SignFileWithSectico.bat D:\ETHEA\MarkdownProcessor\Cmd\MarkdownToHTML\Bin\Win64\MarkDownToHTML.exe
7+
8+
:END
9+
pause
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
{******************************************************************************}
2+
{ }
3+
{ MarkDown To HTML Processor Command Line }
4+
{ }
5+
{ Copyright (c) 2025 (Ethea S.r.l.) }
6+
{ Author: Carlo Barazzetta }
7+
{ }
8+
{ https://github.com/EtheaDev/MarkdownProcessor }
9+
{ }
10+
{ Based on: Delphi Day 2020: Una CLI che i tuoi utenti ameranno }
11+
{ by Marco Breveglieri }
12+
{ https://www.breveglieri.it/eventi/2020-06-11-delphiday-creare-client-cli/ }
13+
{******************************************************************************}
14+
{ }
15+
{ Licensed under the Apache License, Version 2.0 (the "License"); }
16+
{ you may not use this file except in compliance with the License. }
17+
{ You may obtain a copy of the License at }
18+
{ }
19+
{ http://www.apache.org/licenses/LICENSE-2.0 }
20+
{ }
21+
{ Unless required by applicable law or agreed to in writing, software }
22+
{ distributed under the License is distributed on an "AS IS" BASIS, }
23+
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
24+
{ See the License for the specific language governing permissions and }
25+
{ limitations under the License. }
26+
{ }
27+
{******************************************************************************}
28+
program MarkDownToHTML;
29+
30+
{$APPTYPE CONSOLE}
31+
{$R *.res}
32+
33+
uses
34+
System.SysUtils,
35+
Winapi.Windows,
36+
VSoft.CommandLine.Options,
37+
MDProcessorCLI.Console in '..\source\MDProcessorCLI.Console.pas',
38+
MDProcessorCLI.Bootstrap in '..\source\MDProcessorCLI.Bootstrap.pas',
39+
MDProcessorCLI.Commands in '..\source\MDProcessorCLI.Commands.pas',
40+
MDProcessorCLI.Options in '..\source\MDProcessorCLI.Options.pas',
41+
MDProcessorCLI.ResourceStrings in '..\source\MDProcessorCLI.ResourceStrings.pas';
42+
43+
var
44+
ParseResult: ICommandLineParseResult;
45+
46+
procedure Pause;
47+
{$IFDEF DEBUG}
48+
var
49+
LKey: string;
50+
{$ENDIF}
51+
begin
52+
{$IFDEF DEBUG}
53+
Writeln(Format('ExitCode: %d - Press Return to exit', [ExitCode]));
54+
ReadLn(LKey);
55+
{$ENDIF}
56+
end;
57+
58+
begin
59+
60+
try
61+
// Set Console Window Title
62+
TConsole.SetTitle('MardownToHTML: MarkDown File Processor Utility');
63+
TConsole.Log(TConsole.GetTitle+sLineBreak, TConsoleLevel.Success);
64+
65+
// Initialize preferences, commands and CLI Options)
66+
BootstrapCli;
67+
68+
// Execute Parsing of Arguments
69+
ParseResult := TOptionsRegistry.Parse;
70+
71+
// In case of Errors: exit showing a Error Message and syntax expected
72+
if ParseResult.HasErrors then
73+
begin
74+
ExitCode := EXITCODE_PARSE_ERROR;
75+
if ParseResult.Command <> EmptyStr then
76+
TConsole.Log(Format(StrErrParseCommand,
77+
[ParseResult.Command, sLineBreak, ParseResult.ErrorText]),
78+
TConsoleLevel.Error);
79+
TOptionsRegistry.PrintUsage(ParseResult.Command,
80+
procedure(const AUsage: string)
81+
begin
82+
TConsole.Log(AUsage, TConsoleLevel.Info);
83+
end);
84+
Pause;
85+
Exit;
86+
end;
87+
88+
if (ParseResult.Command <> EmptyStr) then
89+
TConsole.Log(Format('%s: %s', [StrCommand, ParseResult.Command]),
90+
TConsoleLevel.Warning);
91+
92+
// If the command is not present or is "help", show the help guide
93+
if (ParseResult.Command = EmptyStr) or (ParseResult.Command = 'help') then
94+
begin
95+
if not TOptionsRegistry.PrintUsage(TOptionsForHelp.CommandName,
96+
procedure(const AUsage: string)
97+
begin
98+
TConsole.Log(AUsage, TConsoleLevel.Info);
99+
end) then
100+
begin
101+
//help command don't exists: print help
102+
ExitCode := EXITCODE_PARSE_ERROR;
103+
TOptionsRegistry.PrintUsage('',
104+
procedure(const AUsage: string)
105+
begin
106+
TConsole.Log(AUsage, TConsoleLevel.Info);
107+
end);
108+
end;
109+
Pause;
110+
Exit;
111+
end;
112+
113+
// Execute the command
114+
TCommandBroker.ExecuteCommand(ParseResult.Command);
115+
Pause;
116+
117+
ExitCode := EXITCODE_OK;
118+
except
119+
// Exception handler, printed in the Console Log
120+
on E: Exception do
121+
begin
122+
TConsole.Log(Format('%s', [E.Message]),
123+
TConsoleLevel.Error);
124+
ExitCode := EXITCODE_UNDEFINED_ERROR;
125+
Pause;
126+
end;
127+
128+
end;
129+
130+
end.
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<PropertyGroup>
3+
<ProjectGuid>{13E0E121-AAEC-43D4-9386-3CC87E063D43}</ProjectGuid>
4+
<ProjectVersion>20.3</ProjectVersion>
5+
<FrameworkType>None</FrameworkType>
6+
<Base>True</Base>
7+
<Config Condition="'$(Config)'==''">Debug</Config>
8+
<Platform Condition="'$(Platform)'==''">Win64</Platform>
9+
<TargetedPlatforms>3</TargetedPlatforms>
10+
<AppType>Console</AppType>
11+
<MainSource>MarkDownToHTML.dpr</MainSource>
12+
<ProjectName Condition="'$(ProjectName)'==''">MarkDownToHTML</ProjectName>
13+
</PropertyGroup>
14+
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
15+
<Base>true</Base>
16+
</PropertyGroup>
17+
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
18+
<Base_Win32>true</Base_Win32>
19+
<CfgParent>Base</CfgParent>
20+
<Base>true</Base>
21+
</PropertyGroup>
22+
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Base)'=='true') or '$(Base_Win64)'!=''">
23+
<Base_Win64>true</Base_Win64>
24+
<CfgParent>Base</CfgParent>
25+
<Base>true</Base>
26+
</PropertyGroup>
27+
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
28+
<Cfg_1>true</Cfg_1>
29+
<CfgParent>Base</CfgParent>
30+
<Base>true</Base>
31+
</PropertyGroup>
32+
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
33+
<Cfg_1_Win32>true</Cfg_1_Win32>
34+
<CfgParent>Cfg_1</CfgParent>
35+
<Cfg_1>true</Cfg_1>
36+
<Base>true</Base>
37+
</PropertyGroup>
38+
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win64)'!=''">
39+
<Cfg_1_Win64>true</Cfg_1_Win64>
40+
<CfgParent>Cfg_1</CfgParent>
41+
<Cfg_1>true</Cfg_1>
42+
<Base>true</Base>
43+
</PropertyGroup>
44+
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
45+
<Cfg_2>true</Cfg_2>
46+
<CfgParent>Base</CfgParent>
47+
<Base>true</Base>
48+
</PropertyGroup>
49+
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win64)'!=''">
50+
<Cfg_2_Win64>true</Cfg_2_Win64>
51+
<CfgParent>Cfg_2</CfgParent>
52+
<Cfg_2>true</Cfg_2>
53+
<Base>true</Base>
54+
</PropertyGroup>
55+
<PropertyGroup Condition="'$(Base)'!=''">
56+
<DCC_DcuOutput>..\Dcu\$(Platform)\</DCC_DcuOutput>
57+
<DCC_ExeOutput>..\Bin\$(Platform)\</DCC_ExeOutput>
58+
<DCC_E>false</DCC_E>
59+
<DCC_N>false</DCC_N>
60+
<DCC_S>false</DCC_S>
61+
<DCC_F>false</DCC_F>
62+
<DCC_K>false</DCC_K>
63+
<SanitizedProjectName>MarkDownToHTML</SanitizedProjectName>
64+
<DCC_UnitSearchPath>..\..\VSoft.CommandLineParser\Src;..\..\..\source;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
65+
<VerInfo_Locale>1033</VerInfo_Locale>
66+
<VerInfo_Keys>CompanyName=Ethea S.r.l.;FileDescription=MarkdownToHTML;FileVersion=1.3.0.0;InternalName=MarkdownToHTML;LegalCopyright=Copyright (c) Ethea S.r.l.;LegalTrademarks=;OriginalFilename=;ProgramID=;ProductName=MarkdownToHTML;ProductVersion=1.3;Comments=</VerInfo_Keys>
67+
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
68+
<VerInfo_MinorVer>3</VerInfo_MinorVer>
69+
</PropertyGroup>
70+
<PropertyGroup Condition="'$(Base_Win32)'!=''">
71+
<DCC_ConsoleTarget>true</DCC_ConsoleTarget>
72+
<Manifest_File>(None)</Manifest_File>
73+
<AppDPIAwarenessMode>none</AppDPIAwarenessMode>
74+
<Icon_MainIcon>mdfolder_multires.ico</Icon_MainIcon>
75+
</PropertyGroup>
76+
<PropertyGroup Condition="'$(Base_Win64)'!=''">
77+
<DCC_ConsoleTarget>true</DCC_ConsoleTarget>
78+
<Manifest_File>(None)</Manifest_File>
79+
<AppDPIAwarenessMode>none</AppDPIAwarenessMode>
80+
<Icon_MainIcon>mdfolder_multires.ico</Icon_MainIcon>
81+
</PropertyGroup>
82+
<PropertyGroup Condition="'$(Cfg_1)'!=''">
83+
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
84+
<DCC_DebugDCUs>true</DCC_DebugDCUs>
85+
<DCC_Optimize>false</DCC_Optimize>
86+
<DCC_IntegerOverflowCheck>true</DCC_IntegerOverflowCheck>
87+
<DCC_RangeChecking>true</DCC_RangeChecking>
88+
</PropertyGroup>
89+
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
90+
<Debugger_RunParams>processfile -in:&quot;..\..\..\..\TestFile\MarkDown Support Test.md&quot; -style:none</Debugger_RunParams>
91+
</PropertyGroup>
92+
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
93+
<Debugger_RunParams>processfile -in:&quot;..\..\..\..\TestFile\MarkDown Support Test.md&quot; -style:none</Debugger_RunParams>
94+
</PropertyGroup>
95+
<PropertyGroup Condition="'$(Cfg_2)'!=''">
96+
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
97+
</PropertyGroup>
98+
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
99+
<Debugger_RunParams>help transform</Debugger_RunParams>
100+
</PropertyGroup>
101+
<ItemGroup>
102+
<DelphiCompile Include="$(MainSource)">
103+
<MainSource>MainSource</MainSource>
104+
</DelphiCompile>
105+
<DCCReference Include="..\source\MDProcessorCLI.Console.pas"/>
106+
<DCCReference Include="..\source\MDProcessorCLI.Bootstrap.pas"/>
107+
<DCCReference Include="..\source\MDProcessorCLI.Commands.pas"/>
108+
<DCCReference Include="..\source\MDProcessorCLI.Options.pas"/>
109+
<DCCReference Include="..\source\MDProcessorCLI.ResourceStrings.pas"/>
110+
<BuildConfiguration Include="Base">
111+
<Key>Base</Key>
112+
</BuildConfiguration>
113+
<BuildConfiguration Include="Debug">
114+
<Key>Cfg_1</Key>
115+
<CfgParent>Base</CfgParent>
116+
</BuildConfiguration>
117+
<BuildConfiguration Include="Release">
118+
<Key>Cfg_2</Key>
119+
<CfgParent>Base</CfgParent>
120+
</BuildConfiguration>
121+
</ItemGroup>
122+
<ProjectExtensions>
123+
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
124+
<Borland.ProjectType>Application</Borland.ProjectType>
125+
<BorlandProject>
126+
<Delphi.Personality>
127+
<Source>
128+
<Source Name="MainSource">MarkDownToHTML.dpr</Source>
129+
</Source>
130+
<Excluded_Packages>
131+
<Excluded_Packages Name="$(BDSBIN)\bcboffice2k370.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
132+
<Excluded_Packages Name="$(BDSBIN)\bcbofficexp370.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
133+
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k370.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
134+
<Excluded_Packages Name="$(BDSBIN)\dclofficexp370.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
135+
<Excluded_Packages Name="$(BDSBIN)\dclappanalytics370.bpl">File c:\bds\studio\37.0\bin\dclappanalytics370.bpl not found</Excluded_Packages>
136+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\37.0\Bpl\DclIOCore_4370.bpl">InstantObjects 4 Design-Time Package</Excluded_Packages>
137+
</Excluded_Packages>
138+
</Delphi.Personality>
139+
<Platforms>
140+
<Platform value="Android">False</Platform>
141+
<Platform value="Android64">False</Platform>
142+
<Platform value="iOSDevice64">False</Platform>
143+
<Platform value="iOSSimARM64">False</Platform>
144+
<Platform value="Linux64">False</Platform>
145+
<Platform value="OSX64">False</Platform>
146+
<Platform value="OSXARM64">False</Platform>
147+
<Platform value="Win32">True</Platform>
148+
<Platform value="Win64">True</Platform>
149+
</Platforms>
150+
</BorlandProject>
151+
<ProjectFileVersion>12</ProjectFileVersion>
152+
</ProjectExtensions>
153+
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
154+
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
155+
</Project>
294 KB
Binary file not shown.
Binary file not shown.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
@echo Off
2+
Set CommandFile="..\Bin\Win64\MarkDownToHTML.exe"
3+
@echo Using: %CommandFile%
4+
5+
@echo *************************************************************************
6+
@echo Test simple call (shows help)
7+
@echo calling: %CommandFile%
8+
call %CommandFile%
9+
10+
@echo *************************************************************************
11+
@echo Test help command (shows generic help)
12+
@echo calling: %CommandFile% help
13+
call %CommandFile% help
14+
15+
@echo *************************************************************************
16+
@echo Test help for processfile command (shows detailed help for processfile)
17+
@echo calling: %CommandFile% help processfile
18+
call %CommandFile% help processfile
19+
20+
@echo *************************************************************************
21+
@echo Test processfile command with only input filename
22+
@echo calling: %CommandFile% processfile -in:"..\..\..\TestFile\MarkDown Support Test.md"
23+
call %CommandFile% processfile -in:"..\..\..\TestFile\MarkDown Support Test.md"
24+
25+
@echo *************************************************************************
26+
@echo Test processfile command with input and output filename
27+
@echo calling: %CommandFile% processfile -in:"..\..\..\TestFile\MarkDown Support Test.md" -out:"..\..\..\TestFile\CommonMark.html"
28+
call %CommandFile% processfile -in:"..\..\..\TestFile\MarkDown Support Test.md" -out:"..\..\..\TestFile\CommonMark.html"
29+
30+
@echo *************************************************************************
31+
@echo Test processfile command with input and output filename
32+
@echo calling: %CommandFile% processfile -in:"..\..\..\TestFile\MarkDown Support Test.md" -out:"..\..\..\TestFile\CommonMark.html"
33+
call %CommandFile% processfile -in:"..\..\..\TestFile\MarkDown Support Test.md" -out:"..\..\..\TestFile\CommonMark.html"
34+
35+
@echo *************************************************************************
36+
@echo Test processfile command with DaringFireball Dialect
37+
@echo calling: %CommandFile% processfile -dialect:DaringFireball -in:"..\..\..\TestFile\MarkDown Support Test.md" -out:"..\..\..\TestFile\DaringFireball.html"
38+
call %CommandFile% processfile -dialect:DaringFireball -in:"..\..\..\TestFile\MarkDown Support Test.md" -out:"..\..\..\TestFile\DaringFireball.html"
39+
40+
@echo *************************************************************************
41+
@echo Test processfile command with Custom StyleSheet
42+
@echo calling: %CommandFile% processfile -in:"..\..\..\TestFile\MarkDown Support Test.md" -out:"..\..\..\TestFile\UseCustomStyleSheet.html" -Style:"..\..\..\TestFile\MarkDown Style.css"
43+
call %CommandFile% processfile -in:"..\..\..\TestFile\MarkDown Support Test.md" -out:"..\..\..\TestFile\UseCustomStyleSheet.html" -Style:"..\..\..\TestFile\MarkDown Style.css"
44+
45+
@echo *************************************************************************
46+
@echo Test processfile command without StyleSheet
47+
@echo calling: %CommandFile% processfile -in:"..\..\..\TestFile\MarkDown Support Test.md" -out:"..\..\..\TestFile\NoStyleSheet.html" -Style:none
48+
call %CommandFile% processfile -in:"..\..\..\TestFile\MarkDown Support Test.md" -out:"..\..\..\TestFile\NoStyleSheet.html" -Style:none
49+
50+
@echo *************************************************************************
51+
@echo End of Test.
52+
:exit
53+
pause

0 commit comments

Comments
 (0)