Skip to content

Fix spacing issues when converting <strong>, <u>, <del>, <em> tags to markdown #657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,8 @@ static void wrapTextNodes(@NotNull HtmlNodeConverterContext context, @NotNull No
} else {
// if we already have space or nothing before us
addSpaceBefore = !(out.getPendingEOL() == 0 || out.isPendingSpace() || out.offsetWithPending() == 0 || out.getPendingEOL() > 0);

if(". , : ; ! ? ) ] @ # $ % ^ & \" \' /".indexOf(text.charAt(0)) != -1) addSpaceBefore = true;
}

if (!text.isEmpty() && "\u00A0 \t\n".indexOf(text.charAt(text.length() - 1)) != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ private void processDel(Element element, HtmlNodeConverterContext context, HtmlM
if (!myHtmlConverterOptions.preCodePreserveEmphasis && out.isPreFormatted()) {
context.wrapTextNodes(element, "", false);
} else {
context.wrapTextNodes(element, myHtmlConverterOptions.extInlineDel.isTextOnly() ? "" : "~~", element.nextElementSibling() != null);
context.wrapTextNodes(element, myHtmlConverterOptions.extInlineDel.isTextOnly() ? "" : "~~", element.nextSibling() != null || element.previousSibling() != null);
}
});
}
Expand Down Expand Up @@ -626,7 +626,7 @@ private void processEmphasis(Element element, HtmlNodeConverterContext context,
if (!myHtmlConverterOptions.preCodePreserveEmphasis && out.isPreFormatted()) {
context.wrapTextNodes(element, "", false);
} else {
context.wrapTextNodes(element, myHtmlConverterOptions.extInlineEmphasis.isTextOnly() ? "" : "*", element.nextElementSibling() != null);
context.wrapTextNodes(element, myHtmlConverterOptions.extInlineEmphasis.isTextOnly() ? "" : "*", element.nextSibling() != null || element.previousSibling() != null);
}
});
}
Expand Down Expand Up @@ -748,7 +748,7 @@ private void processIns(Element element, HtmlNodeConverterContext context, HtmlM
if (!myHtmlConverterOptions.preCodePreserveEmphasis && out.isPreFormatted()) {
context.wrapTextNodes(element, "", false);
} else {
context.wrapTextNodes(element, myHtmlConverterOptions.extInlineIns.isTextOnly() ? "" : "++", element.nextElementSibling() != null);
context.wrapTextNodes(element, myHtmlConverterOptions.extInlineIns.isTextOnly() ? "" : "++", element.nextSibling() != null || element.previousSibling() != null);
}
});
}
Expand All @@ -758,7 +758,7 @@ private void processStrong(Element element, HtmlNodeConverterContext context, Ht
if (!myHtmlConverterOptions.preCodePreserveEmphasis && out.isPreFormatted()) {
context.wrapTextNodes(element, "", false);
} else {
context.wrapTextNodes(element, myHtmlConverterOptions.extInlineStrong.isTextOnly() ? "" : "**", element.nextElementSibling() != null);
context.wrapTextNodes(element, myHtmlConverterOptions.extInlineStrong.isTextOnly() ? "" : "**", element.nextSibling() != null || element.previousSibling() != null);
}
});
}
Expand Down