textile / php-textile

Textile markup language parser for PHP
https://textile-lang.com
Other
216 stars 44 forks source link

Different relative prefixes for images and links #169

Closed maximelouet closed 5 years ago

maximelouet commented 8 years ago

Hello, while trying for more than 30 minutes to understand why my relative anchor link was pointing to my image directory, I searched the source code and found that the relativeImagePrefix was applied also for relative links (with the relURL function). I was really surprised : it's an image prefix, but it's also used for relative URLs. So, in order to create an anchor link (pointing to an element with a specific id on the same page), I either need to specify the full URL, or to disable my relativeImagePrefix.

Maybe we could rename relativeImagePrefix to relativePrefix (and have the setRelativePrefix($prefix) method) ? But this would lead to a big backward incompatibility. Or we could add a different attribute relativeLinkPrefix (with its corresponding method setRelativeLinkPrefix($prefix)) and use this for links only ?

A solution for my specific problem would be to treat URLs starting with a # as absolute ones (in the relURL function). This way, the original URL would be returned instead of the one with the prefix.

Thank you for your answer.

gocom commented 6 years ago

Yeah, the naming of the method is a bit... wrong. If I had to guess it was probably originally used to images and then it somehow ended up to be used on the links too and just stuck.

Best option for this is probably creating a separate method and a matching property; if set, overrides the link prefix, leaving the current image prefix to images.