Skip to content

Commit

Permalink
fix(daisy#35): updated treatment of bidirectionnal text
Browse files Browse the repository at this point in the history
Refactored the conversion of bidirectionnal text:
- Treating bdo element as inline other inline tag
- Checking for w:bidi or w:rtl informations in text runner properties to add bdo elements

Also:
- Changed default plugin settings for more optimal default notes positionning in result
- Starting to remove document name and path in exception report
  • Loading branch information
NPavie committed Dec 14, 2023
1 parent 5bb7dc0 commit c4afb5b
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 281 deletions.
12 changes: 6 additions & 6 deletions Common/DaisyConverterLib/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,14 @@ public ConversionResult Convert(DocumentParameters document, bool applyPostProce
}
catch (Exception e)
{
string message = "An error occured while converting " + document.InputPath + " to dtbook XML :\r\n" + e.Message;
string message = "An error occured while converting a single docx to dtbook XML";
while (e.InnerException != null)
{
message += "\r\n - " + e.InnerException.Message;
e = e.InnerException;
}

Exception fault = new Exception("An error occured while converting " + document.InputPath + " to dtbook XML :\r\n" + e.Message, e);
Exception fault = new Exception("Conversion of single docx to dtbook XML: task crashed", e);
this.EventsHandler.OnConversionError(
fault
);
Expand All @@ -349,7 +349,7 @@ public ConversionResult Convert(DocumentParameters document, bool applyPostProce
e = e.InnerException;
}

Exception fault = new Exception("An error occured while converting " + document.InputPath + " to dtbook XML :\r\n" + e.Message, e);
Exception fault = new Exception("Conversion of single docx to dtbook XML: task ended in fault", e);
this.EventsHandler.OnConversionError(
fault
);
Expand Down Expand Up @@ -383,7 +383,7 @@ public ConversionResult Convert(DocumentParameters document, bool applyPostProce
catch (Exception e)
{
CurrentStatus = ConversionStatus.Error;
Exception fault = new Exception("Error while converting with DAISY Pipeline 2:\r\n" + e.Message, e);
Exception fault = new Exception("Error while converting with DAISY Pipeline 2", e);
this.EventsHandler.onPostProcessingError(
fault
);
Expand Down Expand Up @@ -466,7 +466,7 @@ public ConversionResult Convert(List<DocumentParameters> documentLists, bool app
}
catch (Exception e)
{
Exception fault = new Exception("Error while converting " + document.InputPath + " to dtbook XML:\r\n" + e.Message, e);
Exception fault = new Exception("Conversion of list of docx to dtbook XML: task crashed", e);
// TODO try to see if exception is raised by cancellation
this.EventsHandler.OnConversionError(fault);
throw fault;
Expand All @@ -475,7 +475,7 @@ public ConversionResult Convert(List<DocumentParameters> documentLists, bool app

if (conversionTask.IsFaulted)
{
Exception fault = new Exception("Error while converting " + document.InputPath + " to dtbook XML:\r\n" + conversionTask.Exception.Message, conversionTask.Exception);
Exception fault = new Exception("Conversion of list of docx to dtbook XML: task ended in fault", conversionTask.Exception);
this.EventsHandler.OnConversionError(
fault
);
Expand Down
34 changes: 17 additions & 17 deletions Common/DaisyConverterLib/ConverterSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,32 +143,32 @@ public enum Enum
private string resampleValue = "96";
private string characterStyle = "False";
private string pagenumStyle = "Custom";
private string footnotesLevel = "0"; // 0 mean current paragraphe, < 0 means parent level going upward, > 1 means absolute dtbook level
private string footnotesPosition = "page"; // Should be inline, end, or page
private string footnotesNumbering = "number"; // should be number, none, or word (to reuse word
private string footnotesLevel = "0"; // 0 mean current paragraphe level, < 0 means parent level going upward, > 1 means absolute dtbook level
private string footnotesPosition = "end"; // Should be inline, end, or page
private string footnotesNumbering = "none"; // should be number, none, or word
private string footnotesStartValue = "1"; // number to be used
private string footnotesNumberingPrefix = ""; // prefix to be added before the numbering
private string footnotesNumberingSuffix = " "; // suffix to be added between the number and the text (default to a space to reproduce the plugin original behaviour)
private string footnotesNumberingSuffix = ""; // suffix to be added between the number and the text
private string azureSpeechRegion = ""; // region defined in the Azure console for the speech service
private string azureSpeechKey = ""; // one of the two keys provided to connect to to Azure speech synthesis service
private string ttsConfigFile = ""; // A tts config file to use for speech synthesis with pipeline 2
private string SettingsXml
{
get =>
$"<Settings>" +
$"<PageNumbers value=\"{pagenumStyle}\" />" +
$"<CharacterStyles value=\"{characterStyle}\" />" +
$"<ImageSizes value=\"{imgoption}\" samplingvalue=\"{resampleValue}\" />" +
$"<Footnotes level=\"{footnotesLevel}\" " +
$"position=\"{footnotesPosition}\" " +
$"numbering=\"{footnotesNumbering}\" " +
$"startValue=\"{footnotesStartValue}\" " +
$"numberPrefix=\"{footnotesNumberingPrefix}\" " +
$"numberSuffix=\"{footnotesNumberingSuffix}\" />" +
$"<Azure region=\"{azureSpeechRegion}\" " +
$"key=\"{azureSpeechKey}\" />" +
$"<TTSConfig file=\"{ttsConfigFile}\" />" +
$"</Settings>";
$"\r\n\t<PageNumbers value=\"{pagenumStyle}\" />" +
$"\r\n\t<CharacterStyles value=\"{characterStyle}\" />" +
$"\r\n\t<ImageSizes value=\"{imgoption}\" samplingvalue=\"{resampleValue}\" />" +
$"\r\n\t<Footnotes level=\"{footnotesLevel}\" " +
$"\r\n\t\tposition=\"{footnotesPosition}\" " +
$"\r\n\t\tnumbering=\"{footnotesNumbering}\" " +
$"\r\n\t\tstartValue=\"{footnotesStartValue}\" " +
$"\r\n\t\tnumberPrefix=\"{footnotesNumberingPrefix}\" " +
$"\r\n\t\tnumberSuffix=\"{footnotesNumberingSuffix}\" />" +
$"\r\n\t<Azure region=\"{azureSpeechRegion}\" " +
$"\r\n\t\tkey=\"{azureSpeechKey}\" />" +
$"\r\n\t<TTSConfig file=\"{ttsConfigFile}\" />" +
$"\r\n</Settings>";

}

Expand Down
2 changes: 2 additions & 0 deletions Common/DaisyConverterLib/DaisyConverterLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,11 @@
</EmbeddedResource>
<EmbeddedResource Include="resources\xslts\Common2.xsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="resources\xslts\Common3.xsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="resources\xslts\OOML2MML.xsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
Loading

0 comments on commit c4afb5b

Please sign in to comment.