Compare commits

..

5 Commits

Author SHA1 Message Date
264129b1e9
docs(TODO): Update TODO file
Remove old TODO entries
2024-06-28 16:22:36 +01:00
80aee52a61
fix(Logging): Clean up Logging
change the Sitefiles information count to actually use the count and not
the sitefiles list itself.

Change the logging of file extensions in SiteFile from Information to
Debug
2024-06-26 05:42:50 +01:00
0666436a59
feat(Pandoc): Add sitename to metadata if provided
If a sitefile is provided then that data is passed via the commandline
to pandoc, this then adds it to the YAML metadata available to filters
and templates.
2024-06-26 05:39:01 +01:00
ca84cafbdb
fix(Pandoc): Enable raw_attribute in markdown.
Enabling this makes the way I write pages more functional inside of
pandoc.

In future I may add some way of allowing users to provide pandoc
arguments.
2024-06-26 05:28:51 +01:00
5d79026135
fix(ConverterFunctions): Correct logging
Correct the logging to accurately reflect what is happening in the code.
As StringReplace now does more than just BaseUrl replacing
2024-06-26 05:25:11 +01:00
4 changed files with 10 additions and 8 deletions

View File

@ -158,7 +158,7 @@ class Program
siteFiles.Add(new SiteFile(x)); siteFiles.Add(new SiteFile(x));
Log.Debug("Found file {file}",x.FullName); Log.Debug("Found file {file}",x.FullName);
}); });
Log.Information("SiteFiles Found {count}", siteFiles, siteFiles.Count); Log.Information("SiteFiles Found {count}", siteFiles.Count);
Console.WriteLine($"Converting {siteFiles.Count} files from {settings.InputDirectory.FullName} to {settings.OutputDirectory.FullName}"); Console.WriteLine($"Converting {siteFiles.Count} files from {settings.InputDirectory.FullName} to {settings.OutputDirectory.FullName}");

View File

@ -112,7 +112,7 @@ public static class Conversions{
string tmpFile = string.Empty; string tmpFile = string.Empty;
if (StringReplaceFiletypes.Contains(file.Extension)) if (StringReplaceFiletypes.Contains(file.Extension))
{ {
Log.Information("Replacing baseurl for file {f}",file.FullName); Log.Information("calling string replace for file {f}",file.FullName);
tmpFile = Path.Join(Path.GetTempPath(),"pandoc",file.Name); tmpFile = Path.Join(Path.GetTempPath(),"pandoc",file.Name);
Directory.CreateDirectory(Path.GetDirectoryName(tmpFile)!); // NOTE: It is practially impossible that this would actually return null Directory.CreateDirectory(Path.GetDirectoryName(tmpFile)!); // NOTE: It is practially impossible that this would actually return null
File.Create(tmpFile).Close(); // TODO: Use the filestream provided by File.Create within a using block to write the text File.Create(tmpFile).Close(); // TODO: Use the filestream provided by File.Create within a using block to write the text
@ -120,7 +120,7 @@ public static class Conversions{
if (template is not null) if (template is not null)
{ {
Log.Information("Replacing baseurl in template file"); Log.Information("calling string replace for template file");
string tmpTemplateFile = Path.Join(Path.GetTempPath(),"pandoc",template.Name); string tmpTemplateFile = Path.Join(Path.GetTempPath(),"pandoc",template.Name);
Directory.CreateDirectory(Path.GetDirectoryName(tmpTemplateFile)!); // NOTE: It is practially impossible that this would actually return null Directory.CreateDirectory(Path.GetDirectoryName(tmpTemplateFile)!); // NOTE: It is practially impossible that this would actually return null
File.Create(tmpTemplateFile).Close(); // TODO: Use the filestream provided by File.Create within a using block to write the text File.Create(tmpTemplateFile).Close(); // TODO: Use the filestream provided by File.Create within a using block to write the text
@ -150,6 +150,12 @@ public static class Conversions{
Log.Warning("Pandoc template for {file} not found",file.Name); Log.Warning("Pandoc template for {file} not found",file.Name);
} }
pandocArgs += " --from markdown+raw_attribute ";
if (!string.IsNullOrEmpty(settings.SiteName))
{
// This is used in my template to add the sitename to the title element.
pandocArgs += $" --metadata=\"SiteName:{settings.SiteName}\"";
}
if (!Directory.Exists(Path.GetDirectoryName(GetNewName(file,settings,".html")))) if (!Directory.Exists(Path.GetDirectoryName(GetNewName(file,settings,".html"))))
{ {
Directory.CreateDirectory(Path.GetDirectoryName(GetNewName(file,settings,".html"))!); Directory.CreateDirectory(Path.GetDirectoryName(GetNewName(file,settings,".html"))!);

View File

@ -29,7 +29,7 @@ public partial class SiteFile
{ {
info = fileInfo; info = fileInfo;
Log.Information("{file} extension is {ext}",fileInfo.FullName, fileInfo.Extension); Log.Debug("{file} extension is {ext}",fileInfo.FullName, fileInfo.Extension);
// Using this Ensures that the ConverterFunction is Always set. // Using this Ensures that the ConverterFunction is Always set.
// ConverterFunctions ALWAYS accept just the FileInfo, and ProjectSettings passed at convert time. // ConverterFunctions ALWAYS accept just the FileInfo, and ProjectSettings passed at convert time.
ConverterFunction = Conversions.Mappings.GetValueOrDefault(info.Extension, Conversions.RawCpy); ConverterFunction = Conversions.Mappings.GetValueOrDefault(info.Extension, Conversions.RawCpy);

4
TODO
View File

@ -1,9 +1,5 @@
- UPDATE README
- Make the code such that the metadata file knows what source file an output file came from, this will allow us to delete files from source - Make the code such that the metadata file knows what source file an output file came from, this will allow us to delete files from source
and force consistency by removing them from the dst directory too. and force consistency by removing them from the dst directory too.
- Add a pre-commit or other type of hook to ensure that the Testing directory is properly cleaned and reset before commit. - Add a pre-commit or other type of hook to ensure that the Testing directory is properly cleaned and reset before commit.
- Ensure that the .gitkeep file is placed into Testing/dst - Ensure that the .gitkeep file is placed into Testing/dst
- Look into the possiblity of using a TemplateTemplate, And generating the pandoc template on the fly making it possible to switch out domian/prefix stuff