aboutsummaryrefslogtreecommitdiff
path: root/doc/todo/Don__39__t_change_text_like___91____91__this__93____93___in_code_blocks.mdwn
blob: daf5d9e99f150e758cfb51ca49f08b14d00041f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    diff --git a/IkiWiki/Plugin/link.pm b/IkiWiki/Plugin/link.pm
    index 1ba28eafd..61a397bf8 100644
    --- a/IkiWiki/Plugin/link.pm
    +++ b/IkiWiki/Plugin/link.pm
    @@ -107,7 +107,13 @@ sub linkify (@) {
        my $page=$params{page};
        my $destpage=$params{destpage};
     
    -	$params{content} =~ s{(\\?)$link_regexp}{
    +    my $content;
    +    for my $line ( split /\n/, $params{content} ) {
    +        if ( $line =~ /^(?:\t|    )/ ) {
    +            $content .= $line . "\n";
    +            next;
    +        }
    +        $line =~ s{(\\?)$link_regexp}{
                 defined $2
                     ? ( $1
                         ? "[[$2|$3".(defined $4 ? "#$4" : "")."]]"
    @@ -122,8 +128,10 @@ sub linkify (@) {
                             : htmllink($page, $destpage, linkpage($3),
                                 anchor => $4))
                 }eg;
    +        $content .= $line . "\n";
    +    }
     
    -	return $params{content};
    +	return $content;
     }
     
     sub scan (@) {

Related to [[bugs/wiki links still processed inside code blocks]] and [[forum/How_to_format___91____91__foobar__93____93___in_code_blocks__63__]].

[[!tag patch]]

> It looks as though this patch would break linkification in any syntactic construct that
> uses indentation but isn't a code block, for instance a list:
>
>     * This is a list
>         * So is this
>             * And \[[this is a link|http://example.com]]
>
> rendered as:
>
> * This is a list
>     * So is this
>         * And [[this is a link|http://example.com]]
>
> It's also assuming that Markdown is the only language available (trying to use Markdown
> rules), and even in Markdown it doesn't support Github-style fenced code blocks if enabled.
>
> This is not something that can be done correctly by just patching the link plugin.
> I'm not sure whether it's something that can be done correctly at all, unfortunately.
>
> [[!tag reviewed]] --[[smcv]]