Amaury / SkrivMarkup

Interpreter of the Skriv Markup Language.
GNU Lesser General Public License v2.1
25 stars 3 forks source link

"bug" in title/links #12

Closed marmotz closed 11 years ago

marmotz commented 11 years ago

source code

=title1
==subtitle1
==subtitle2
=title2
==subtitle1
==subtitle2

generate

<h1 id="title1">title1</h1>
<h2 id="subtitle1">subtite1</h2>
<h2 id="subtitle2">subtite2</h2>
<h1 id="title2">title2</h1>
<h2 id="subtitle1">subtite1</h2>
<h2 id="subtitle2">subtite2</h2>

Id subtitle1 and subtitle2 exist 2 times.

So a link to #subtitle1 go to first h2.subtitle1 and second h2.subtitle1 will be never callable.

Amaury commented 11 years ago

Yes, same title generates the same identifier. That may change when the option for automatic titles numerotation will be developed.

marmotz commented 11 years ago

An other solution should be to modify title markup:

source:

=title
=title=
=title=anchor

generate:

<h1 id="title">title</h1>  <!--- Automatic generation based on title  text -->
<h1 id="title">title</h1>  <!--- Automatic generation based on title  text -->
<h1 id="anchor">title</h1> <!--- "Manual"  generation based on anchor text -->

What do you think about ?

Amaury commented 11 years ago

To be honest, I don't know. As I wrote, lightweight markup languages should stay lightweight.

MediaWiki and Markdown has automatic headers identifiers, and workarounds based on pure HTML code. But your proposal is interresting. I have to think about it.

marmotz commented 11 years ago

SkrivMarkup have also an automatic anchor generation based on title name. But no duplication check. And I think it's a good thing because only the user should change the anchor and only if he wants.

In my opinion, SkrivMarkup should generate a warning when it detect duplicate title anchor, but nothing else. And with a way to specify anchor, user could solve this problem (he sees thanks to warning)

Amaury commented 11 years ago

Yes, but with your proposal, it becomes impossible to write that:

= One bath = 3 showers

Because it will generates:

<h1 id="3-showers">One bath</h1>

Instead of:

<h1>One bath = 3 showers</h1>

So, the idea is great, but maybe we should find another syntax.

marmotz commented 11 years ago

links are like that:

[[name|http://url]]

So, if you want "name1|name2" it's "impossible" to write:

[[[name1|name2|http://url]]]

Fortunately, you have introduce escaping method (http://markup.skriv.org/language/syntax#escaping):

[[[name1\|name2|http://url]]]

So you should use:

= One bath \= 3 showers
Amaury commented 11 years ago

Yep, why not. OK, I'll do it.

marmotz commented 11 years ago

Cool :) \o/

marmotz commented 11 years ago

Any news about this modification ?

Amaury commented 11 years ago

I have a lot of work... I'll try to do it (and syntax highlight, and titles auto-numbering) this week.

marmotz commented 11 years ago

Do you want I try to work on this part ?

Amaury commented 11 years ago

If you want. I've never refused one of your pull requests ;-)

marmotz commented 11 years ago

done :)