Added some alternative tags

This commit is contained in:
Kirill Polyakov
2026-02-05 23:37:29 +03:00
parent 565b2ec494
commit 56b8e41875
5 changed files with 22 additions and 36 deletions

View File

@ -84,7 +84,9 @@ bool CMDWriter::WriteText(std::wstring wsText, const std::vector<NSCSS::CNode>&
if (!bPreformatted && !InCode())
ReplaceSpaces(wsText);
ApplyAlternativeTags(pCompiledStyle);
WriteString(wsText);
ApplyAlternativeTags(pCompiledStyle, true);
if (L'\n' == wsText.back())
m_arStates.top().m_bNeedBreakLine = false;
@ -252,4 +254,21 @@ void CMDWriter::RollBackState()
if (m_arStates.size() > 1)
m_arStates.pop();
}
void CMDWriter::ApplyAlternativeTags(const NSCSS::CCompiledStyle* pCompiledStyle, bool bIsCloseTag)
{
if (nullptr == pCompiledStyle || !m_oMDParametrs.m_bUseAlternativeHTMLTags)
return;
if (pCompiledStyle->m_oText.Underline())
GetCurrentDocument()->WriteString(bIsCloseTag ? L"</u>" : L"<u>");
if (L"top" == pCompiledStyle->m_oDisplay.GetVAlign().ToWString())
GetCurrentDocument()->WriteString(bIsCloseTag ? L"</sup>" : L"<sup>");
else if (L"bottom" == pCompiledStyle->m_oDisplay.GetVAlign().ToWString())
GetCurrentDocument()->WriteString(bIsCloseTag ? L"</sub>" : L"<sub>");
if (L"FFFF00" == pCompiledStyle->m_oBackground.GetColor().ToHEX())
GetCurrentDocument()->WriteString(bIsCloseTag ? L"</mark>" : L"<mark>");
}
}

View File

@ -81,6 +81,8 @@ public:
private:
void SaveState();
void RollBackState();
void ApplyAlternativeTags(const NSCSS::CCompiledStyle* pCompiledStyle, bool bIsCloseTag = false);
};
}