From 6b3aa81c11e33477ddd382992c3c15cebbbfb2d4 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Sat, 9 Dec 2017 02:36:27 +0530 Subject: [PATCH] FIX: Remove other whitespaces except the line intents --- lib/html_to_markdown.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/html_to_markdown.rb b/lib/html_to_markdown.rb index a27814b4e70..99563379aea 100644 --- a/lib/html_to_markdown.rb +++ b/lib/html_to_markdown.rb @@ -210,7 +210,9 @@ class HtmlToMarkdown def visit_text(node) node.content = node.content.gsub(/\A[[:space:]]+/, "") if node.previous_element.nil? && EMPHASIS.include?(node.parent.name) - @stack[-1].markdown << node.text + indent = node.text[/^\s+/] || "" + text = node.text.gsub(/^\s+/, "").gsub(/\s{2,}/, " ") + @stack[-1].markdown << [indent, text].join("") end def format_block