Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

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

Merged

Conversation

SilverRainZ
Copy link
Contributor

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.

@nedbat
Copy link

nedbat commented Apr 3, 2022

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.

@SilverRainZ
Copy link
Contributor Author

@nedbat I created a fork which including this fix.

For the nested list, I will dig it recently.

@paigeadelethompson
Copy link

@SilverRainZ why did you create a fork?

@SilverRainZ
Copy link
Contributor Author

@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 #59

@vktry-k-it
Copy link

vktry-k-it commented Mar 28, 2023

😭😭😭😭 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)

@SilverRainZ
Copy link
Contributor Author

@vktry-k-it
Copy link

vktry-k-it commented Mar 28, 2023

@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)

@SilverRainZ
Copy link
Contributor Author

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

@vktry-k-it
Copy link

vktry-k-it commented Mar 28, 2023

@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!

@SilverRainZ
Copy link
Contributor Author

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

@clayrisser clayrisser merged commit 23ad107 into clayrisser:master May 29, 2023
@clayrisser
Copy link
Owner

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants