Skip to content

Commit

Permalink
Added spacebefore/after handling in markdown (instead of using defaul…
Browse files Browse the repository at this point in the history
…t setting)
  • Loading branch information
weissm committed Jan 5, 2025
1 parent 76a5f5e commit e5ae251
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions OneMore/Commands/File/Markdown/MarkdownConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,30 @@ public void RewriteHeadings()
{
RewriteHeadings(outline.Descendants(ns + "OE"));
}

// added header spacing specific to markdown
var quickstyles = page.Root.Elements(ns + "QuickStyleDef");
foreach (var quickstyle in quickstyles)
{
var name = quickstyle.Attribute("name").Value;
if (name.Equals("h1") || name.Equals("h2"))
{
replaceAtributes(quickstyle, spaceBefore: 0.8, spaceAfter: 0.5);
}
else
if (name.Equals("h3") || name.Equals("h4"))
{
replaceAtributes(quickstyle, spaceBefore: 0.3, spaceAfter: 0.3);
}
}
void replaceAtributes(XElement quickstyle, double spaceBefore, double spaceAfter)
{
quickstyle.Attributes().Where(a => a.Name == "spaceBefore").Remove();
quickstyle.SetAttributeValue("spaceBefore", spaceBefore.ToString("####0.00", CultureInfo.InvariantCulture));
quickstyle.Attributes().Where(a => a.Name == "spaceAfter").Remove();
quickstyle.SetAttributeValue("spaceAfter", spaceAfter.ToString("####0.00", CultureInfo.InvariantCulture));
}

}


Expand Down

0 comments on commit e5ae251

Please sign in to comment.