Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Set content of html blocks #7

Hi @vsch
I'm now trying to replace links in html snippets, too. When I use html.setChars and then format it back to markdown, the newline that separates the block from the next and indentation is lost. For example the initial markdown is:

line 1

  <img src="i.jpg">

line 2

Then I change HtmlBlock nodes trivially by setting the same content like this:

HtmlBlock b = …
b.setChars(b.getChars)

or

HtmlBlock b = …
b.setContent(b.getChars, Arrays.asList(b.getChars))

(I also tried some other variants) When then formatting the ast back to markdown, the html block is not separated by newline as before. Also the indentation is lost.

line1 

<img src="i.jpg">
line 2

Is this expected? Or am I using the api not correctly maybe? Or are in markdown terms both variants equivalent?

Thanks in advance!
Kind regards
Eike

  • solved #4
  • replies 7
  • views 8.3K
  • likes 0
#2

@eikek, the missing blank line is a bug. Thank you for catching it. #146

The removal of indentation is by design because the indentation is not significant and during formatting it is reduced to minimum necessary.

I am fixing the bug now.

#3

@vsch thank you for the very quick reply. I just experimented a little more and found that the missing line is also happening with the example you showed me in my last question. For example with this document:

- [link](link.txt)

next line

when replacing links, the next line belongs to the list item. Is this maybe the same bug?

Thank again!

#4

@eikek, yes the cause is the same. You can get around it for now by setting the Parser.BLANK_LINES_IN_AST option. Which is how the Formatter was tested. However this causes extra blank lines in Markdown to be preserved.

The fix will not require blank lines in the AST and will not preserve extra blank lines.

#5

@vsch thank you very much! Yes, this setting indeed fixes my problem.

eikek accepted post #4 as the answer
#6
eikek unaccepted post #4
#7
eikek accepted post #4 as the answer
#8