Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-52783

Double square brackets in wiki ToC titles when header as link

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.7.12, 2.8.10, 2.9.4, 3.0.2
    • Fix Version/s: None
    • Component/s: Wiki (2.x)
    • Labels:
      None
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE

      Description

      If a Wiki title (h1, h2 or h3) is marked as link as well, in the table of content, it gets displayed with [[double square brackets]].

      To reproduce.

      Create a wiki.
      Insert a page. E.g. "Foo"
      In source code editor view, insert a title, having it work as a link as well. E.g. <h1>[[Bar]]</h1>
      Create the page "Bar", so the link does indeed link.
      Now, in the table of content, the "Bar" entry is displayed with double square brackets (and enumeration).

      Probably one would expect the table of content to display all titles in the site equally, not distinguishing whether they link or they do not link.

      Possible remedy:

      Filter double square brackets out where the table of content links are generated.

      That's in mod/wiki/parser/markups/wikimarkup.php
      process_toc() function

      Change
      {{
      $toc .= parser_utils::h('p', $number . ". " . parser_utils::h('a', $header[1], array('href' => "#toc-$i")),
      array('class' => 'wiki-toc-section-' . $header[0] . " wiki-toc-section"));}}

      To
      {{
      $toc .= parser_utils::h('p', $number . ". " . parser_utils::h('a', str_replace(array('[[',']]'),'',$header[1]),
      array('href' => "#toc-$i")), array('class' => 'wiki-toc-section-' . $header[0] . " wiki-toc-section")); }}

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              lucaboesch Luca Bösch
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: