1. Bitbucket
  2. Public Issue Tracker
  3. master
  4. Issues

Issues

Issue #7647 open

Level 1 headers inside code blocks should not be processed (BB-8822)

Kamil Slowikowski
created an issue

Expected behavior

The Creole <<toc / 1>> tag is supposed to show the level 1 headers from all other Wiki files in the same folder.

Observed behavior

Level 1 headers inside code blocks in markdown files are processed, but they should not be.

http://daringfireball.net/projects/markdown/syntax#precode

  • "Regular Markdown syntax is not processed within code blocks. E.g., asterisks are just literal asterisks within a code block. This means it’s also easy to use Markdown to write about Markdown’s own syntax."

For example, if one of my wiki markdown files contains this text:

```bash
#!/bin/bash
# myscript.sh

echo "Hi there :)"
```

then the table of contents in a second file produced by using the Creole tag <<toc / 1>> will contain a listing called "myscript.sh" when it should not.

I assume this problem arises because a simple regular expression is used to find all level 1 headers. A more sophisticated parsing approach should be used instead to avoid processing level 1 headers inside code blocks.

Comments (5)

  1. Daniel Kraus

    We indent the affected lines with tabs as a workaround. For instance, the example above becomes:

    ```bash
        #!/bin/bash
        # myscript.sh
    
    echo "Hi there :)"
    ``` 
    

    Not ideal, but IMHO better than a messed up TOC.

  2. Log in to comment