Merge branch 'master' of https://github.com/vhanla/OpenLiveWriter into vhanla-master

This commit is contained in:
Jon Galloway 2017-03-12 21:48:31 -07:00
commit 5ff1f1b1f2
2 changed files with 33 additions and 0 deletions

View File

@ -908,6 +908,21 @@ namespace OpenLiveWriter.CoreServices
return (float)Convert.ToDouble(cssUnits.Substring(0, i), CultureInfo.InvariantCulture) * 0.283464567f;
}
// CSS3 RELATIVE SIZE TO ROOT HTML
i = cssUnits.IndexOf("REM", StringComparison.OrdinalIgnoreCase);
if (i > 0)
{
float rootMultiplier = (float)Convert.ToDouble(cssUnits.Substring(0, i), CultureInfo.InstalledUICulture);
IHTMLElement rootElement = element;
while (rootElement.parentElement != null) // until it encounters {mshtml.HTMLHtmlElementClass} which is the root HTML node
{
rootElement = rootElement.parentElement;
}
// the 'rem' unit is relative to the computed value of the font-size attribute of the root element.
return rootMultiplier * CSSUnitStringToPointSize(CSSUnitStringFontSize, rootElement, LastChanceFontPointSize, vertical);
}
// RELATIVE SIZE
i = cssUnits.IndexOf("EM", StringComparison.OrdinalIgnoreCase);
if (i > 0)

View File

@ -13,6 +13,7 @@ using OpenLiveWriter.BlogClient.Detection;
using OpenLiveWriter.CoreServices;
using OpenLiveWriter.CoreServices.Settings;
using OpenLiveWriter.PostEditor;
using System.Text.RegularExpressions;
namespace OpenLiveWriter.PostEditor.PostHtmlEditing
{
@ -109,6 +110,23 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing
templateHtml = templateHtml.Replace(origPath, newUri);
}
/*Parse meta tags in order to set CSS3 compatibility*/
Regex metatag = new Regex(@"<(?i:meta)(\s)+(?i:http-equiv)(\s)*=""(?:X-UA-Compatible)""(\s)+(?i:content)(\s)*=""(?i:IE=edge)""(\s)*/>");
Match match = metatag.Match(templateHtml);
if (!match.Success)
{
// prepend the metatag to make css3 compatible at least on edge (Windows 8+)
int i = templateHtml.IndexOf("<HEAD>", StringComparison.OrdinalIgnoreCase);
if (i > 0)
{
templateHtml = ( templateHtml.Substring(0, i + 6)
+ "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />"
+ templateHtml.Substring(i + 6) );
}
}
return templateHtml;
}
else