Knagis/CommonMark.NET

Not fully converting to html (headers, lists, line breaks etc)

Closed this issue · 2 comments

I'm not sure if I am doing something wrong but the tool only seems to wrap new lines in paragraph tags, but no other obvious HTML conversions.

As a minimum I'd expect the MD headers to be converted to their HTML equivalent, for example

#Header1 converts to

Header1


###Header3 converts to

Header3

I'd also expect basic list conversion.

I'm not criticising here, just checking that I am using everything properly and the level of HTML conversion is as minimal as it seems.

This is my code

var result = CommonMarkConverter.Convert(h1Section);

where h1Section is MD format text that looks like this

#Section 1
This is a sample section, it has two sub-sections

##SubSection 1.1
This is sub-section 1.1

##SubSection 1.2
This is sub-section 1.2

This is the HTML that I'm getting

<p>#Section 1
This is a sample section, it has two sub-sections</p>
<p>##SubSection 1.1
This is sub-section 1.1</p>
<p>##SubSection 1.2
This is sub-section 1.2</p>

I expected something more like this

<h1>Section 1<\h1>
<p>This is a sample section, it has two sub-sections<\p>
<br>
<h2>SubSection 1.1<\h2>
<p>This is sub-section 1.1<\p>
<br>
<h2>SubSection 1.2<\h2>
<p>This is sub-section 1.2<\p>

If I am not mistaken, CommonMark requires space after the hash sign for headers.

---- Martin Kearn wrote ----

I'm not sure if I am doing something wrong but the tool only seems to wrap new lines in paragraph tags, but no other obvious HTML conversions.

As a minimum I'd expect the MD headers to be converted to their HTML equivalent, for example

#Header1 converts to

Header1


###Header3 converts to

Header3

I'd also expect basic list conversion.

I'm not criticising here, just checking that I am using everything properly and the level of HTML conversion is as minimal as it seems.

This is my code

var result = CommonMarkConverter.Convert(h1Section);

where h1Section is MD format text that looks like this

#Section 1 This is a sample section, it has two sub-sections ##SubSection 1.1 This is sub-section 1.1 ##SubSection 1.2 This is sub-section 1.2

This is the HTML that I'm getting

#Section 1 This is a sample section, it has two sub-sections

##SubSection 1.1 This is sub-section 1.1

##SubSection 1.2 This is sub-section 1.2

I expected something more like this

Section 1<\h1>

This is a sample section, it has two sub-sections<\p>

SubSection 1.1<\h2>

This is sub-section 1.1<\p>

SubSection 1.2<\h2>

This is sub-section 1.2<\p>


Reply to this email directly or view it on GitHub.

Ha, yes that is it... I was using GitHub MD which does not require this, but as you rightly say the CommonMark standard does.

Working now thanks - have closed.