py-pdf / fpdf2

Simple PDF generation for Python
https://py-pdf.github.io/fpdf2/
GNU Lesser General Public License v3.0
1.05k stars 240 forks source link

Provide support for unordered lists in cell() & multi_cell() when markdown=True #654

Open Lucas-C opened 1 year ago

Lucas-C commented 1 year ago

Sample code that would be supported after implementing this feature:

from fpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.set_font("helvetica", size=40)
pdf.multi_cell(w=0, markdown=True, txt="""An unordered list:
* apple
* banana
* orange
""")
pdf.output("issue_654.pdf")

Regarding the specifics, CommonMark should be the reference. There is a handy online editor for testing it.

Note that we already support <ul> item list in write_html(), and should strive for conistency there:

from fpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.write_html("""An unordered list:<ul>
  <li>apple</li>
  <li>banana</li>
  <li>orange</li>
</ul>""")
pdf.output("write_html_ul_example.pdf")

By implementing this feature you, as a benevolent FLOSS developper, will provide access to the large community of fpdf2 users to a useful functionality. As a contributor you will get review feedbacks from the maintainer & other contributors, and learn about the lifecycle & structure of a Python library on the way. You will also be added to the contributors list & map.

This issue can count as part of hacktoberfest

Arnavkamat commented 1 year ago

I would like to contribute to this. I am a beginner in Open source. Please let me know the necessary things.

Lucas-C commented 1 year ago

I would like to contribute to this. I am a beginner in Open source. Please let me know the necessary things.

Great! And welcome @Arnavkamat 😊

The first step would be to read the Development guidelines, install the necesseray tools on your computer and run the unit tests suite.

Then you can use the TDD approach and start by adding new unit tests covering this new feature.

Also: No such thing as a stupid question: feel free to ask anything there if things are unclear!

shivamshrey commented 1 year ago

@Lucas-C Need some help with package installation. https://github.com/PyFPDF/fpdf2/discussions/682