tlienart / Franklin.jl

(yet another) static site generator. Simple, customisable, fast, maths with KaTeX, code evaluation, optional pre-rendering, in Julia.
https://franklinjl.org
MIT License
932 stars 108 forks source link

Tag pages don't urlencode their crosslinks #1063

Open Seelengrab opened 6 months ago

Seelengrab commented 6 months ago

If you have a directory foo/what's new in X?/ with an article including tags and want to get to that article from those tags, the link will be broken because of the '. The href needs to be url encoded, e.g. with this function (I think it's correct, but not 100% sure):

urlencode(s::String) = replace(s,
    ' ' =>  "%20",
    '!' =>  "%21",
    '"' =>  "%22",
    '#' =>  "%23",
    '\$' => "%24",
    '%' =>  "%25",
    '&' =>  "%26",
    '\'' => "%27",
    '(' =>  "%28",
    ')' =>  "%29",
    '*' =>  "%2A",
    '+' =>  "%2B",
    ',' =>  "%2C",
    '-' =>  "%2D",
    '.' =>  "%2E",
    '/' =>  "%2F",
    ':' =>  "%3A",
    ';' =>  "%3B",
    '<' =>  "%3C",
    '=' =>  "%3D",
    '>' =>  "%3E",
    '?' =>  "%3F",
    '@' =>  "%40",
    '[' =>  "%5B",
    '\\' => "%5C",
    ']' =>  "%5D",
    '{' =>  "%7B",
    '|' =>  "%7C",
    '}' =>  "%7D"
)

happy to make a PR, if you can tell me where.