Skip to content

Commit

Permalink
fix(nb): do not wrap linebreak/indent into the code block (#56)
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>

---------

Signed-off-by: Jinzhe Zeng <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] authored Apr 6, 2024
1 parent 45a0ced commit 32c37b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dargs/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,11 @@ def print_html(self, _level=0, _last_one=True):
else:
buff.append(r"""<code class="dargs-code">""")
buff.append(
json.dumps(self.data, indent=2).replace("\n", f"{linebreak}{indent}")
json.dumps(self.data, indent=2)
.replace(" ", "&nbsp;")
.replace(
"\n", f"""</code>{linebreak}{indent}<code class="dargs-code">"""
)
)
if not _last_one:
buff.append(",")
Expand Down
1 change: 1 addition & 0 deletions dargs/sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def _test_argument() -> Argument:
doc=doc_test,
sub_fields=[
Argument("test_argument", dtype=str, doc=doc_test, default="test"),
Argument("test_list", dtype=List[int], optional=True),
],
sub_variants=[
Variant(
Expand Down
5 changes: 5 additions & 0 deletions docs/nb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"jstr = \"\"\"\n",
"{\n",
" \"test_argument\": \"test1\",\n",
" \"test_list\": [\n",
" 1,\n",
" 2,\n",
" 3\n",
" ],\n",
" \"test_variant\": \"test_variant_argument\",\n",
" \"test_repeat\": [\n",
" {\"test_repeat_item\": false},\n",
Expand Down

0 comments on commit 32c37b9

Please sign in to comment.