madflow / flow-netbeans-markdown

Markdown file support for the NetBeans IDE
MIT License
279 stars 40 forks source link

Header with colon in title gets different syntax highlighting #93

Closed jerry1970 closed 8 years ago

jerry1970 commented 9 years ago

When I type something like this:

# Some Title

the syntax highlighting (Source tab) shows The hash sign and the following space in bold and with a background colour (the colours I selected on the Fonts & Colors tab in the Options dialog). The text Some Title is in the default text format.

When I add a colon to the title, like this:

# Some Title: Now This

then all the text on this line is marked as the header.

The preview tab shows no difference.

I know, not a biggie, I was just wondering...

stengerh commented 9 years ago

I cannot reproduce this with NetBeans 8.0.2. I'll try it with the nightly build later on.

stengerh commented 9 years ago

Sorry, I was not able to reproduce the issue on the nightly build (nbms-and-javadoc-171-on-20150722) either.

madflow commented 9 years ago

I could reproduce this with NB 8.2. I have not debugged any further yet.

bildschirmfoto von 2015-07-24 12 32 15

stengerh commented 9 years ago

Okay, I figured out what is going on. The good news is that it is not a bug. Everything works as intended. If a change is desired this should be classified as improvement or change.

The syntax highlighting shows the innermost markdown which applies to a given piece of text. You can see this if make some text bold and some part of the bold text italics as well. In the generated HTML a part of the text will be in italics and bold. The syntax highlight will however not show this combination of styles.

This feature also applies to headers. Now it looks like there is no special markdown within the headers as in the following example.

Some text

# Some Title

# Some Title: Now This

# What is Markdown?

Well, below is the generated HTML for various combinations of extensions.

With wikilinks and definition lists extensions:

<p>Some text</p>
<h1><a href="#some-title" name="some-title">Some Title</a></h1>
<h1>Some Title: Now This</h1>
<h1><a href="#what-is-markdown-" name="what-is-markdown-">What is Markdown?</a></h1>

With wikilinks extension only:

<p>Some text</p>
<h1><a href="#some-title" name="some-title">Some Title</a></h1>
<h1><a href="#some-title-now-this" name="some-title-now-this">Some Title: Now This</a></h1>
<h1><a href="#what-is-markdown-" name="what-is-markdown-">What is Markdown?</a></h1>
jerry1970 commented 9 years ago

Ah, I see, good one you found this! I am going to uncheck the wikilinks since I don't like the href on the name tags. It's linking to itself, makes no sense. In my opinion it should be <a name="...">...</a> or <a href="...">...</a>, not both, but that could be me.

Thanks for digging into this and the explanation!

stengerh commented 9 years ago

I looked a little deeper. While what I wrote above is true there was a bug involved in this after all. The header title is styled as an anchor link with the wikilinks extension. However we lack a piece of configuration to make this style configurable. Anchor links are therefore displayed like plain text. I already have a fix for this and will prepare some unit tests to prevent such oversights in the future.