Skip to content

Only center alignment of markdown table #104

@arthur-thuy

Description

@arthur-thuy

Describe the bug
The align parameter in functions such as new_paragraph has no effect on tables.

To Reproduce

All three tables printed below are center-aligned. This is not the desired behavior.

import subprocess

from mdutils.mdutils import MdUtils
from mdutils import Html
import pandas as pd

mdFile = MdUtils(file_name="Example_Markdown", title="Markdown File Example")

mdFile.new_header(level=1, title="Overview")  # style is set 'atx' format by default.

d = {"col1": [1, 2], "col2": [3, 4]}
df = pd.DataFrame(data=d)
mdFile.new_paragraph(df.to_markdown(index=False))
mdFile.new_paragraph()
mdFile.new_paragraph(df.to_markdown(index=False), align="center")
mdFile.new_paragraph()
mdFile.new_paragraph(df.to_markdown(index=False), align="left")
mdFile.create_md_file()
subprocess.run(
    "pandoc Example_Markdown.md -o Example_Markdown.pdf",
    shell=True,
    check=False,
)

Expected behavior
I expect left alignment with align="left". I'm not sure what the behavior for the default parameter "" should be.

Screenshots
/

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • Version: mdutils 1.6.0

Additional context
/

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions