sphinx-markdown-builder icon indicating copy to clipboard operation
sphinx-markdown-builder copied to clipboard

Fix table and list item: paragraph in these nodes do not need newline

Open SilverRainZ opened this issue 4 years ago • 4 comments

A paragraph maybe child of a table entry or list item, we should not add newline in these cases. See commit message and comments of code.

Table

rST source:

.. list-table::
   :header-rows: 1

   * - Type
     - Variant
   * - ``any``
     - ``Stream``
   * - ``comparable``
     - ``Comparable``

Generated markdown:

| Type

 | Variant

 |
| ------------------- | ---------------------------------------------------------------- |  |  |
| `any`

                 | `Stream`

                                                           |
| `comparable`

          | `Comparable`

                                                       |

After this patch:

| Type | Variant |
| ------------------- | ---------------------------------------------------------------- |  |  |
| `any`                 | `Stream`                                                           |
| `comparable`          | `Comparable`                                                       |

List

rST source:

1. Use ``FromSlice`` to construct a stream of int slice.
2. Use ``Filter`` to filter the zero values.
3. Use ``ToSlice`` convered filtered stream to slice, evaluation is done here.

Generated markdown:

1. Use `FromSlice` to construct a stream of int slice.


2. Use `Filter` to filter the zero values.


3. Use `ToSlice` convered filtered stream to slice, evaluation is done here.

After this patch:

1. Use `FromSlice` to construct a stream of int slice.
2. Use `Filter` to filter the zero values.
3. Use `ToSlice` convered filtered stream to slice, evaluation is done here.

SilverRainZ avatar Dec 21 '21 03:12 SilverRainZ

This fixes lists, but there's still a problem with nested lists. This .rst:

Nested Lists
------------

- Item 1

- Item 2

  - Sub1

  - Sub2

- Item 3

becomes this Markdown:

# Nested Lists


* Item 1
* Item 2
    * Sub1
    * Sub2


* Item 3

which spaces the entire list.

nedbat avatar Apr 03 '22 13:04 nedbat

@nedbat I created a fork which including this fix.

For the nested list, I will dig it recently.

SilverRainZ avatar Apr 04 '22 10:04 SilverRainZ

@SilverRainZ why did you create a fork?

paigeadelethompson avatar Aug 05 '22 08:08 paigeadelethompson

@SilverRainZ why did you create a fork?

Because I don't own this repository and the maintainer hasn't replied to me for a year, see https://github.com/clayrisser/sphinx-markdown-builder/issues/59

SilverRainZ avatar Aug 05 '22 08:08 SilverRainZ

😭😭😭😭 Thank you @SilverRainZ for your contribution. Will the real repository owner please stand up, please stand up, please stand up. Eminem - The Real Slim Shady (Official Video - Clean Version)

vktry-k-it avatar Mar 28 '23 14:03 vktry-k-it

@vktry-k-it you can try my fork: https://github.com/sphinx-notes/markdown-builder

SilverRainZ avatar Mar 28 '23 14:03 SilverRainZ

@SilverRainZ

@vktry-k-it you can try my fork: https://github.com/sphinx-notes/markdown-builder

Had to delete and add the comment back again, i actually was an idiot 😂

Many thanks. I've tried 0.5.6, however i'm still getting mumbo-jumbo output, and additionally very verbose console output.

> python3 -m pipenv run mddocgen                                                                                                                                               
                                                                                                                                                                               
mddocgen create:  /Users/you-d-wish/Repositories/i-am-not-an-idiot/.tox/mddocgen                                                                         
mddocgen installdeps: sphinx >= 4.3.2, < 5, sphinxnotes-markdown-builder >= 0.5.6, < 1                                                                                         
mddocgen installed: alabaster==0.7.13,Babel==2.12.1,certifi==2022.12.7,charset-normalizer==3.1.0,docutils==0.17.1,html2text==2020.1.16,idna==3.4,imagesize==1.4.1,importlib-met
adata==6.1.0,Jinja2==3.1.2,MarkupSafe==2.1.2,packaging==23.0,pydash==6.0.2,Pygments==2.14.0,requests==2.28.2,snowballstemmer==2.2.0,Sphinx==4.5.0,sphinxcontrib-applehelp==1.0.
4,sphinxcontrib-devhelp==1.0.2,sphinxcontrib-htmlhelp==2.0.1,sphinxcontrib-jsmath==1.0.1,sphinxcontrib-qthelp==1.0.3,sphinxcontrib-serializinghtml==1.1.5,sphinxnotes-markdown-
builder==0.5.6,unify==0.5,untokenize==0.1.1,urllib3==1.26.15,yapf==0.32.0,zipp==3.15.0                                                                                         
mddocgen run-test-pre: PYTHONHASHSEED='2546643104'                                                                                                                             
mddocgen run-test: commands[0] | sphinx-build -d /Users/you-d-wish/Repositories/i-am-not-an-idiot/build/docs/_tree/_ docs /Users/you-d-wish/Repositories/i-am-not-an-idiot --color -W -bmarkdown -treadme                                                                                                       
Running Sphinx v4.5.0                                                                                                                                                          
loading pickled environment... done                                                                                                                                            
building [mo]: targets for 0 po files that are out of date                                                                                                                     
building [markdown]: targets for 0 source files that are out of date                                                                                                           
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] SBOM             
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
>>>> VISIT TITLE <title>Getting Started</title>   

I've used the Sphinx examples for testing.

Should i open an issue for that on your end, or we good?

I'm just going to avoid writing tables, it's just for the markdowns of the repository (README, etc.) anyway. There must be more than tables to markdown. There Must Be More to Life Than This (Freddie Mercury with Michael Jackson)

vktry-k-it avatar Mar 28 '23 14:03 vktry-k-it

@vktry-k-it The output is debug log, it is fine and should not influence the markdown output.

SilverRainZ avatar Mar 28 '23 14:03 SilverRainZ

@vktry-k-it The output is debug log, it is fine and should not influence the markdown output.

I know, it's just too verbose for my taste if it's the defaults. Like i said, main point is: it isn't working. Thanks anyway!

vktry-k-it avatar Mar 28 '23 15:03 vktry-k-it

@vktry-k-it get it, you can report the bug at sphinxnotes's side, I will try to debug.

SilverRainZ avatar Mar 29 '23 01:03 SilverRainZ

Thank you!

clayrisser avatar May 29 '23 21:05 clayrisser