[GH-ISSUE #240] problem with TOML format for allowed elements #205

Closed
opened 2026-03-03 01:24:40 +03:00 by kerem · 6 comments
Owner

Originally created by @gmc444-b on GitHub (Dec 16, 2019).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/240

I have a project with a .markdownlintrc file in YAML format, and I'd like to support some inline HTML markup in it. I tried adding a section for "MD033" as follows, and I get the error below. I've tried several variations, based on YAML documentation, but haven't got this working.

Searching for examples that set this option only brings up JSON variants.

What am I doing wrong? Could a working example for this type of construct be supplied in the documentation?

[MD033]
allowed_elements = ['code', 'p']

and the error:

/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:636
      throw error;
      ^

TypeError: (params.config.allowed_elements || []).map is not a function
    at Object.MD033 [as function] (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/md033.js:22:8)
    at forRule (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:454:20)
    at Array.forEach (<anonymous>)
    at lintContent (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:500:14)
    at lintContentWrapper (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:525:12)
    at lintFile (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:530:5)
    at lintNextItem (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:596:9)
    at lintInput (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:612:10)
    at Function.markdownlintSync [as sync] (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:634:3)
    at lintAndPrint (/home/usr/lib/noe_modules/markdownlint-cli/markdownlint.js:255:35)
Originally created by @gmc444-b on GitHub (Dec 16, 2019). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/240 I have a project with a `.markdownlintrc` file in YAML format, and I'd like to support some inline HTML markup in it. I tried adding a section for "MD033" as follows, and I get the error below. I've tried several variations, based on YAML documentation, but haven't got this working. Searching for examples that set this option only brings up JSON variants. What am I doing wrong? Could a working example for this type of construct be supplied in the documentation? ``` [MD033] allowed_elements = ['code', 'p'] ``` and the error: ``` /home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:636 throw error; ^ TypeError: (params.config.allowed_elements || []).map is not a function at Object.MD033 [as function] (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/md033.js:22:8) at forRule (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:454:20) at Array.forEach (<anonymous>) at lintContent (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:500:14) at lintContentWrapper (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:525:12) at lintFile (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:530:5) at lintNextItem (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:596:9) at lintInput (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:612:10) at Function.markdownlintSync [as sync] (/home/usr/lib/noe_modules/markdownlint-cli/node_modules/markdownlint/lib/markdownlint.js:634:3) at lintAndPrint (/home/usr/lib/noe_modules/markdownlint-cli/markdownlint.js:255:35) ```
kerem 2026-03-03 01:24:40 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Dec 16, 2019):

Please include the example?

<!-- gh-comment-id:566208797 --> @DavidAnson commented on GitHub (Dec 16, 2019): Please include the example?
Author
Owner

@gmc444-b commented on GitHub (Dec 16, 2019):

Sorry, I submitted before doing so. I've updated the issue with the example and the error.

<!-- gh-comment-id:566211468 --> @gmc444-b commented on GitHub (Dec 16, 2019): Sorry, I submitted before doing so. I've updated the issue with the example and the error.
Author
Owner

@DavidAnson commented on GitHub (Dec 16, 2019):

I think that formatting is not correct. Here is an example for MD033 that uses JSON from the test cases: https://github.com/DavidAnson/markdownlint/blob/master/test/inline_html-allowed_elements.json

I ran that through one of the online converters to produce the following YAML output:

default: true
MD033:
    allowed_elements: [h1, h3, HR, p]

Try that?

<!-- gh-comment-id:566244332 --> @DavidAnson commented on GitHub (Dec 16, 2019): I think that formatting is not correct. Here is an example for MD033 that uses JSON from the test cases: https://github.com/DavidAnson/markdownlint/blob/master/test/inline_html-allowed_elements.json I ran that through one of the online converters to produce the following YAML output: ```yaml default: true MD033: allowed_elements: [h1, h3, HR, p] ``` Try that?
Author
Owner

@gmc444-b commented on GitHub (Dec 16, 2019):

A bit more information, I was mistaken about the file being in YAML format, it's actually TOML. Below is the JSON version that does work for me:

{
    "MD013": {
        "code_blocks": false,
        "headers": false,
        "line_length": 99,
        "tables": false
    },

    "MD024": {
        "siblings_only": true
    },

    "MD026": {
        "punctuation": ".,;:!"
    },

    "MD033": {
        "allowed_elements": ["code", "p"]
    }
}

This site provides a converter that provides this output:

[MD013]
code_blocks = false
headers = false
line_length = 99
tables = false

[MD024]
siblings_only = true

[MD026]
punctuation = ".,;:!"

[MD033]
allowed_elements = [ "code", "p" ]

An example input:

# Example

<p align="center"><code>text</code></p>

Together, these produce the error I described above.

<!-- gh-comment-id:566256574 --> @gmc444-b commented on GitHub (Dec 16, 2019): A bit more information, I was mistaken about the file being in YAML format, it's actually TOML. Below is the JSON version that does work for me: ``` { "MD013": { "code_blocks": false, "headers": false, "line_length": 99, "tables": false }, "MD024": { "siblings_only": true }, "MD026": { "punctuation": ".,;:!" }, "MD033": { "allowed_elements": ["code", "p"] } } ``` [This site](https://esakat.github.io/toml2jsonConverter/) provides a converter that provides this output: ``` [MD013] code_blocks = false headers = false line_length = 99 tables = false [MD024] siblings_only = true [MD026] punctuation = ".,;:!" [MD033] allowed_elements = [ "code", "p" ] ``` An example input: ``` # Example <p align="center"><code>text</code></p> ``` Together, these produce the error I described above.
Author
Owner

@DavidAnson commented on GitHub (Dec 16, 2019):

The CLI does not support TOML-formatted config files. Per the documentation in that project repository, only JSON and YAML formatting is supported.

https://github.com/igorshubovych/markdownlint-cli

TOML is rare enough that it’s not included by default, and the CLI does not expose a way to provide a custom parser to allow it like the library does.

<!-- gh-comment-id:566264324 --> @DavidAnson commented on GitHub (Dec 16, 2019): The CLI does not support TOML-formatted config files. Per the documentation in that project repository, only JSON and YAML formatting is supported. https://github.com/igorshubovych/markdownlint-cli TOML is rare enough that it’s not included by default, and the CLI does not expose a way to provide a custom parser to allow it like the library does.
Author
Owner

@gmc444-b commented on GitHub (Dec 16, 2019):

It turns out TOML looks like INI format, which is supported, and the following format works:

[MD033]
allowed_elements[] = "code"
allowed_elements[] = "p"

Thank you for your help, @DavidAnson .

<!-- gh-comment-id:566267146 --> @gmc444-b commented on GitHub (Dec 16, 2019): It turns out TOML looks like INI format, which is supported, and the following format works: ``` [MD033] allowed_elements[] = "code" allowed_elements[] = "p" ``` Thank you for your help, @DavidAnson .
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#205
No description provided.