Skip to content

MarkdownIt.__init__ differs from JS #111

@hukkin

Description

@hukkin

It seems to me there is a fairly big difference in how the Python port handles MarkdownIt.__init__ parameters compared to the JS implementation, that isn't documented in port.yaml. Two major differences that I see:

  1. A setting mapping in JS init is options. In Python implementation the mapping is a similar structure that JS passes to .configure(), that is it is the "preset" structure that contains options and components.
  2. When passed in options, Javascript always merges the options with a set of preset values. In Python, passing in a settings dict will skip using any preset values at all.

As a result, in Javascript I can do the following to get "default" presets and make a change in one setting:

var md = markdownit({ html: false });

In Python the same would be more like:

from markdown_it import presets conf = presets.default.make() conf["options"]["html"] = False md = MarkdownIt(conf)

Is this difference in the API intended? If yes, should we document it in port.yaml? If no, maybe we should redesign the init function before v1.0.0?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions