Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/ENGINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Filee chooses engines automatically. Settings → *Engines* shows their status,
| PDFsharp | built in (library) | images → PDF (CMYK pictures stay CMYK), merge, split, page ranges, page organising, lossless rotate and crop-box edits, pages per sheet (N-up), spreadsheet print-studio assembly, **compression** (smaller PDFs, see below), PDFs without their metadata |
| PDFium | built in (library) | PDF → images (multi-page TIFF/GIF supported); CMYK pages → CMYK JPG/TIFF through Ghostscript when it is installed |
| Unhwp | built in (library) | HWP/HWPX → TXT, Markdown, HTML (pictures in a `<name>_files` folder next to the Markdown, embedded in the HTML) |
| Text & Markdown (Markdig) | built in (library) | **Markdown → HTML, TXT**; **TXT, LOG, PY, PAC, BAT, CMD, COMMAND, LUA, CSS, PS1, SQL, AHK, INI, RSC, C, H, CPP, CC, CXX, HPP, HH, HXX, CS, DART, HQL → UTF-8 TXT**, preserving source text without running scripts (and → PDF / DOCX through the HWPX writer, rhwp or LibreOffice) |
| Text & Markdown (Markdig) | built in (library) | **Markdown → HTML, TXT**; **TXT, LOG, PY, PAC, BAT, CMD, COMMAND, LUA, CSS, PS1, SQL, AHK, INI, RSC, C, H, CPP, CC, CXX, HPP, HH, HXX, CS, DART, HQL, DBML → UTF-8 TXT**, preserving source text without running scripts (and → PDF / DOCX through the HWPX writer, rhwp or LibreOffice) |
| Spreadsheets (ExcelDataReader for XLS) | built in (library) | **XLSX, XLS, ODS, CSV, TSV → XLSX, ODS, CSV, TSV** (one CSV / TSV per sheet) |
| Office Open XML | built in | **DOCM / DOTX / DOTM ↔ DOCX, XLSM / XLTX ↔ XLSX, PPTM / POTX / POTM / PPSX ↔ PPTX** (macros removed for macro-free types) |
| Fonts | built in | **TTF, OTF, WOFF, WOFF2, EOT ↔ each other**; **FON (NE monochrome FNT v2/v3, supported single-byte charsets) → TTF, OTF, WOFF, WOFF2, EOT only**; CFF (PostScript) outlines become TrueType for TTF and EOT |
Expand Down
7 changes: 4 additions & 3 deletions src/Filee.Core/Formats/FormatRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ public static class FormatRegistry
new("sda", "SDA", FormatCategory.Presentation, ["sda", "sdd"], Writable: false),

// Plain text / markup
// Text logs, source code, proxy scripts, style sheets and settings files are read as plain text, never executed or
// compiled (issues #273, #284, #254, #388, #368, #607, #536, #630, #661, #660, #864, #828, #980, #997).
// Text logs, source code, database schemas (DBML), proxy scripts, style sheets and settings files are read as plain
// text, never executed, compiled or translated (issues #273, #284, #254, #388, #368, #607, #536, #630, #661, #660,
// #864, #828, #980, #997, #854).
new("txt", "TXT", FormatCategory.Text,
["txt", "log", "py", "pac", "bat", "cmd", "command", "lua", "css", "ps1", "sql", "ahk", "ini", "rsc",
"c", "h", "cpp", "cc", "cxx", "hpp", "hh", "hxx", "cs", "dart", "hql"]),
"c", "h", "cpp", "cc", "cxx", "hpp", "hh", "hxx", "cs", "dart", "hql", "dbml"]),
new("md", "Markdown", FormatCategory.Text, ["md", "markdown"]),
new("html", "HTML", FormatCategory.Text, ["html", "htm", "xhtml"]),
// A web page saved with its pictures in one MIME file (Chrome, Edge, Word); read as the page it holds.
Expand Down
2 changes: 1 addition & 1 deletion src/Filee.Core/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static bool IsFlipKeyAllowed(string key, IEnumerable<TriggerGesture> gest
public sealed class AppSettings
{
/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>
public const int CurrentSchemaVersion = 64;
public const int CurrentSchemaVersion = 65;

public int SchemaVersion { get; set; } = CurrentSchemaVersion;

Expand Down
4 changes: 4 additions & 0 deletions src/Filee.Core/Settings/UserDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,10 @@ public static bool ApplyToLibrary(int from, List<Preset> presets, List<ToolbarPr
presets.InsertRange(annotate < 0 ? presets.Count : annotate + 1, BuiltInData.BackgroundPresets());
changed = true;
}
// v65: DBML database schemas (#854) learn the text donut; custom claims stay put. (Schema 65 may be renumbered if
// another change takes it first.)
if (from < 65)
changed |= LearnExtensions(profiles, out _, ["dbml"]);
return changed;
}

Expand Down
25 changes: 22 additions & 3 deletions tests/Filee.Core.Tests/ScriptTextTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Lua, PowerShell, AutoHotkey and batch scripts, SQL and HiveQL, INI files, RouterOS exports, CSS style sheets and C,
// C++, C# and Dart source files are plain text (issues #388, #368, #442, #607, #536, #630, #661, #660, #864, #828, #980,
// #997): recognised, and learnt by existing text donuts.
// Lua, PowerShell, AutoHotkey and batch scripts, SQL and HiveQL, DBML database schemas, INI files, RouterOS exports, CSS
// style sheets and C, C++, C# and Dart source files are plain text (issues #388, #368, #442, #607, #536, #630, #661, #660,
// #864, #828, #980, #997, #854): recognised, and learnt by existing text donuts.

using Filee.Core.Formats;
using Filee.Core.Presets;
Expand Down Expand Up @@ -31,6 +31,7 @@ public class ScriptTextTests
[InlineData("MyBot.cs")]
[InlineData("main.dart")]
[InlineData("daily_report.HQL")]
[InlineData("shop.dbml")]
public void Scripts_and_style_sheets_are_text(string name) => Assert.Equal("txt", FormatRegistry.Detect(name)?.Id);

[Fact]
Expand Down Expand Up @@ -118,4 +119,22 @@ public void Version_60_donuts_learn_dart_hql_and_kra_without_taking_custom_claim
Assert.Contains("kra", profiles.Single(p => p.Id == "images").Extensions);
Assert.False(SettingsMigrations.ApplyToLibrary(60, presets, profiles));
}

[Fact]
public void Version_64_text_donuts_learn_dbml_without_taking_custom_claims()
{
var presets = BuiltInData.CreatePresets();
var profiles = BuiltInData.CreateProfiles();
var text = profiles.Single(p => p.Id == "text").Extensions;
text.Remove("dbml");

Assert.True(SettingsMigrations.ApplyToLibrary(64, presets, profiles));
Assert.Contains("dbml", text);
Assert.False(SettingsMigrations.ApplyToLibrary(64, presets, profiles));

text.Remove("dbml");
profiles.Insert(0, new ToolbarProfile { Id = "my-schemas", Name = "Schemas", Extensions = ["dbml"] });
Assert.False(SettingsMigrations.ApplyToLibrary(64, presets, profiles));
Assert.DoesNotContain("dbml", text); // the user's own donut has it
}
}
27 changes: 26 additions & 1 deletion tests/Filee.Engines.Tests/ScriptTextTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Lua scripts and CSS style sheets (issues #388, #368) become a PDF of their text, never run.
// Lua scripts, CSS style sheets and DBML database schemas (issues #388, #368, #854) become a PDF of their text, never run
// or translated.

using Filee.Core.Conversion;
using Filee.Core.Presets;
Expand All @@ -11,6 +12,7 @@ public class ScriptTextTests(EngineFixture fx) : IClassFixture<EngineFixture>
[Theory]
[InlineData("site.css", "body { color: #1d9e75; }")]
[InlineData("init.lua", "local greeting = \"hello\" print(greeting)")]
[InlineData("shop.dbml", "Table customers { id integer [primary key] }")]
public async Task The_code_becomes_a_pdf_of_its_text(string name, string code)
{
var available = fx.Converters.Where(c => fx.Catalog.StatusOf(c).IsAvailable).Select(c => c.Id).ToHashSet();
Expand All @@ -24,4 +26,27 @@ public async Task The_code_becomes_a_pdf_of_its_text(string name, string code)
var text = PdfDocumentReader.PlainText(PdfDocumentReader.ReadText(Assert.Single(job.Outputs)));
Assert.Contains(code.Split(' ')[1], text);
}

[Fact]
public async Task A_dbml_schema_becomes_text_as_it_was_written()
{
// #854: the schema is read as text; nothing turns it into SQL.
const string schema = """
Table customers {
id integer [primary key]
}

Ref: orders.customer_id > customers.id
""";
var path = Path.Combine(fx.NewFolder(), "shop.dbml");
await File.WriteAllTextAsync(path, schema, TestContext.Current.CancellationToken);

var job = await fx.ConvertAsync([path], new Preset { TargetFormat = "txt" });

Assert.True(job.State == JobState.Completed, string.Join("; ", job.Files.Select(f => $"{f.ErrorKey} {f.ErrorDetail}")));
var output = Assert.Single(job.Outputs);
Assert.Equal("shop.txt", Path.GetFileName(output));
var text = await File.ReadAllTextAsync(output, TestContext.Current.CancellationToken);
Assert.Equal(schema.ReplaceLineEndings(), text.ReplaceLineEndings().TrimEnd());
}
}
Loading