Debian Codegraph @

third_party/python/markdown_it_py/markdown_it/port.yaml

raw
1 - package: markdown-it/markdown-it
2 version: 13.0.1
3 commit: e843acc9edad115cbf8cf85e676443f01658be08
4 date: May 3, 2022
5 notes:
6 - Rename variables that use python built-in names, e.g.
7 - `max` -> `maximum`
8 - `len` -> `length`
9 - `str` -> `string`
10 - |
11 Convert JS `for` loops to `while` loops
12 this is generally the main difference between the codes,
13 because in python you can't do e.g. `for {i=1;i<x;i++} {}`
14 - |
15 `env` is a common Python dictionary, and so does not have attribute access to keys,
16 as with JavaScript dictionaries.
17 `options` have attribute access only to core markdownit configuration options
18 - |
19 `Token.attrs` is a dictionary, instead of a list of lists.
20 Upstream the list format is only used to guarantee order: https://github.com/markdown-it/markdown-it/issues/142,
21 but in Python 3.7+ order of dictionaries is guaranteed.
22 One should anyhow use the `attrGet`, `attrSet`, `attrPush` and `attrJoin` methods
23 to manipulate `Token.attrs`, which have an identical signature to those upstream.
24 - Use python version of `charCodeAt`
25 - |
26 Use `str` units instead of `int`s to represent Unicode codepoints.
27 This provides a significant performance boost
28 - |
29 In markdown_it/rules_block/reference.py,
30 record line range in state.env["references"] and add state.env["duplicate_refs"]
31 This is to allow renderers to report on issues regarding references
32 - |
33 The `MarkdownIt.__init__` signature is slightly different for updating options,
34 since you must always specify the config first, e.g.
35 use `MarkdownIt("commonmark", {"html": False})` instead of `MarkdownIt({"html": False})`
36 - The default configuration preset for `MarkdownIt` is "commonmark" not "default"
37 - Allow custom renderer to be passed to `MarkdownIt`
38 - |
39 change render method signatures
40 `func(tokens, idx, options, env, slf)` to
41 `func(self, tokens, idx, options, env)`
42 - |
43 Extensions add render methods by format
44 `MarkdownIt.add_render_rule(name, function, fmt="html")`,
45 rather than `MarkdownIt.renderer.rules[name] = function`
46 and renderers should declare a class property `__output__ = "html"`.
47 This allows for extensibility to more than just HTML renderers
48 - inline tokens in tables are assigned a map (this is helpful for propagation to children)