edwh-editorjs 2.0.0b2__tar.gz → 2.0.0b3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,12 @@
2
2
 
3
3
  <!--next-version-placeholder-->
4
4
 
5
+ ## v2.0.0-beta.3 (2024-11-06)
6
+
7
+ ### Fix
8
+
9
+ * Various fixes with nested lists ([`52a7773`](https://github.com/educationwarehouse/edwh-editorjs/commit/52a7773470dce3eee6a2d17d46b594551ed043a5))
10
+
5
11
  ## v2.0.0-beta.2 (2024-11-06)
6
12
 
7
13
  ### Feature
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: edwh-editorjs
3
- Version: 2.0.0b2
3
+ Version: 2.0.0b3
4
4
  Summary: EditorJS.py
5
5
  Project-URL: Homepage, https://github.com/educationwarehouse/edwh-EditorJS
6
6
  Author-email: SKevo <skevo.cw@gmail.com>, Robin van der Noord <robin.vdn@educationwarehouse.nl>
@@ -0,0 +1 @@
1
+ __version__ = "2.0.0-beta.3"
@@ -171,7 +171,7 @@ class ListBlock(EditorJSBlock):
171
171
  markdown_items = []
172
172
  for index, item in enumerate(subitems):
173
173
  prefix = f"{index + 1}." if style == "ordered" else "-"
174
- line = f"{' ' * depth}{prefix} {item['content']}"
174
+ line = f"{'\t' * depth}{prefix} {item['content']}"
175
175
  markdown_items.append(line)
176
176
 
177
177
  # Recurse if there are nested items
@@ -1,4 +1,5 @@
1
1
  import json
2
+ import textwrap
2
3
  import typing as t
3
4
 
4
5
  import markdown2
@@ -16,9 +17,8 @@ EDITORJS_VERSION = "2.30.6"
16
17
  class EditorJS:
17
18
  # internal representation is mdast, because we can convert to other types
18
19
  _mdast: MDRootNode
19
- _md = markdown2.Markdown(extras=["task_list"]) # todo: striketrough, table, ...
20
20
 
21
- def __init__(self, _mdast: str | dict):
21
+ def __init__(self, _mdast: str | dict, extras: list = ("task_list", "fenced-code-blocks")):
22
22
  if not isinstance(_mdast, str | dict):
23
23
  raise TypeError("Only `str` or `dict` is supported!")
24
24
 
@@ -26,6 +26,8 @@ class EditorJS:
26
26
  MDRootNode, json.loads(_mdast) if isinstance(_mdast, str) else _mdast
27
27
  )
28
28
 
29
+ self._md = markdown2.Markdown(extras=extras) # todo: striketrough, table, ?
30
+
29
31
  @classmethod
30
32
  def from_json(cls, data: str | dict) -> Self:
31
33
  """
@@ -48,6 +50,7 @@ class EditorJS:
48
50
  """
49
51
  Load from markdown string
50
52
  """
53
+
51
54
  return cls(mdast.md_to_json(data))
52
55
 
53
56
  @classmethod
@@ -78,7 +81,11 @@ class EditorJS:
78
81
  """
79
82
  Export Markdown string
80
83
  """
81
- return mdast.json_to_md(self.to_mdast())
84
+ md = mdast.json_to_md(self.to_mdast())
85
+ # idk why this happens:
86
+ md = md.replace(r"\[ ]", "[ ]")
87
+ md = md.replace(r"\[x]", "[x]")
88
+ return md
82
89
 
83
90
  def to_mdast(self) -> str:
84
91
  """
@@ -16,8 +16,8 @@ EXAMPLE_MD = textwrap.dedent("""
16
16
 
17
17
  1. another
18
18
  2. list (ordered)
19
- 2.1. with
20
- 2.2. nesting
19
+ 1. with
20
+ 2. nesting
21
21
  3. *and styling*
22
22
 
23
23
  ***
@@ -1 +0,0 @@
1
- __version__ = "2.0.0-beta.2"
File without changes