Repository navigation
v3.5.0
PrettyTables v3.5.0
- Add the Word back end (
backend = :docx), which renders the table as a Word table using WriteDocx.jl. It writes a.docxfile when the keywordfilenameis set (an existing file is only replaced ifoverwrite = true) and otherwise returns theWriteDocx.Table, so that the table can be embedded in a larger document, also available withpretty_table(WriteDocx.Table, data; kwargs...)andpretty_table(WriteDocx.Document, data; kwargs...). The documents created by the back end use Calibri as the default font, which can be changed with the keyworddefault_font. The back end supports the sections, the highlighters (DocxHighlighter), the table format (DocxTableFormatandDocxTableBorders), the table style (DocxTableStyle), and the column widths (data_column_widths,minimum_data_column_widths, andmaximum_data_column_widths), as well as the backend-agnosticTableFormatandTableStyle. Footnote markers become superscript text runs and each region of a styled string becomes a text run with the attributes of its face. The functionsdocx_decorationanddocx_line_style, the macros@docx__all_horizontal_lines,@docx__all_vertical_lines,@docx__no_horizontal_lines, and@docx__no_vertical_lines, and the functionpretty_table_docx_backendare exported. - Add the keyword
line_breaksto the Typst back end. Iftrue, the line breaks in the cells are rendered as Typst line breaks. Otherwise, they are escaped as in the other back ends, whereas they were emitted as raw line break characters. - Add support for
StyledStrings.Faceas the decoration of the text back end. Every field ofTextTableStyleand the decoration ofTextHighlighterare now faces, and crayons are still accepted and converted to the equivalent faces. The keyword constructorTextHighlighter(f; kwargs...)accepts the keywords of bothFaceandCrayon. StyledStrings.jl is now a dependency, it is re-exported, andFaceandSimpleColorare exported. - Add
Highlighter, a highlighter defined by aFacethat works with every back end, and the supertypeAbstractHighlighterof all the highlighters. The keywordhighlightersaccepts any vector ofAbstractHighlighter. - Accept a
Facein every keyword ofHtmlTableStyle,LatexTableStyle,MarkdownTableStyle,TypstTableStyle, andExcelTableStyle, which is converted to the decoration of the back end at construction. The conversion functionshtml_decoration,latex_decoration,markdown_decoration,typst_decoration, andexcel_decorationare exported. - Render the styled strings of StyledStrings.jl in every back end (Julia 1.11 or newer). The regions of the string are decorated with their faces using the conversion of each back end. The HTML back end now renders them with
html_decorationinstead of the HTML writer of StyledStrings.jl. - Convert styled strings to Excel's rich text format (
XLSX.RichTextString), where each region of the string becomes a run with the font attributes of its face. Backgrounds are dropped because Excel does not support per-run fills, and a string whose regions carry no font attributes is still written as plain text. - Add the backend-agnostic table format
TableFormatand the line designLineStyle, allowing the user to configure the table lines (presence and design) once for every back end. The keywordtable_formatnow acceptsTableFormatin every back end: each set field overrides the corresponding field of the back end default format, and every field left asnothingkeeps the back end default. The conversion functionslatex_line_style,typst_line_style, andexcel_line_styleare exported. - Add the backend-agnostic table style
TableStyle, which describes the decoration of each table section with aFace. The keywordstylenow acceptsTableStylein every back end with the same sparse override semantics asTableFormat: each set field overrides the corresponding field of the back end default style. - Allow customizing each table line independently in the text back end.
TextTableFormatnow has the fieldstop_line,header_line,merged_header_cell_line,middle_line,bottom_line(accepting the new exported objectTextTableLine),left_line,center_line, andright_line(accepting aChar), which sparsely override the characters inbordersfor a single line.TextTableStylenow has line faces with the same names to style each line independently, falling back totable_borderwhen unset. The line design fields ofTableFormatare now fully supported by the text back end: eachLineStyleis mapped to Unicode box-drawing characters, the intersections between the lines are selected automatically from the crossing designs, and the line design colors are converted to the line faces of the style. - Add the border configuration to the HTML back end.
HtmlTableFormatnow has the fieldborders(the new exported objectHtmlTableBorders, whose line roles are CSSbordershorthand strings) and the same line presence fields as the other back ends, plus three HTML-only ones (horizontal_line_before_column_labels,horizontal_line_after_footnotes, andhorizontal_line_at_end) since the HTML back end places the title inside the ruled area and draws the line at the end of the table with a dedicated field. As in the text back end, the footnotes and source notes are outside the ruled area: the line at the end of the table is drawn after the last summary or data row, before them, and the vertical lines at the edges of the table are hidden in their cells. The line after the last row of the ruled area uses the bottom line style, as in the other back ends. The lines are emitted as inline styles in the table elements, so they are applied in any rendering mode instead of only whenstand_alone = true. Every line is disabled by default, keeping the default output free of border decoration. The macros@html__all_horizontal_lines,@html__all_vertical_lines,@html__no_horizontal_lines, and@html__no_vertical_linesand the conversion functionhtml_line_styleare exported, and the HTML back end now fully supports the backend-agnosticTableFormat. - Add the backend-agnostic macros
@all_horizontal_lines,@all_vertical_lines,@no_horizontal_lines, and@no_vertical_lines, which return the keyword arguments to show or suppress every line inTableFormat, mirroring the per-backend macro quadruples.TableFormatalso gained the presence fieldshorizontal_line_before_column_labels,horizontal_line_after_footnotes, andhorizontal_line_at_end, which are only honored by the HTML back end and silently ignored by the others. - Accept a
Face, aCrayon, and the keywords of both in the constructors ofHtmlHighlighter,LatexHighlighter,MarkdownHighlighter,TypstHighlighter, andExcelHighlighter, converting the face with the decoration function of the back end, exactly likeHighlighterandTextHighlighter. Every table style, includingTableStyle, also accepts aCrayonwherever it accepts aFace. - Export the native decoration types
HtmlPair,TypstPair, andLatexEnvironments, likeExcelPair. - Select the back end from a native table style (for example,
style = HtmlTableStyle()) whenbackend = :autoand the table format does not select one. Passing the style or the table format of another back end now throws anArgumentErrorwith a clear message instead of aMethodError. - The HTML back end draws no lines by default: every line presence field of
HtmlTableFormatdefaults tofalse(or:none), and the default output has no border decoration (no inline borders, noborder-collapse, and no<colgroup>elements), keeping the table appearance fully customizable with CSS. The defaultcssofHtmlTableFormatno longer contains border rules, so a stand-alone table is also rendered without borders unless lines are enabled. The underline of merged column labels moved from the defaults offirst_line_merged_column_labelandmerged_column_labelinHtmlTableStyleto the fieldhorizontal_line_at_merged_column_labelsofHtmlTableFormat, which is disabled by default like the other lines. A fully ruled table can be obtained withHtmlTableFormat(; @html__all_horizontal_lines, @html__all_vertical_lines). - The conversion of
TableFormatandTableStyleis a best effort: the Markdown back end only supportshorizontal_line_before_summary_rowsand ignores the style fields its style type does not have, and the LaTeX back end ignores the line width and color. Withbackend = :auto, aTableFormatdoes not select a back end and the text back end is used. - Precompile the most common keywords, the predefined formatters, the matrices with elements of type
Any, the vectors with missing values,pretty_table(HTML, data), and theStringoutput with a custom style. For example, the time to print the first table withfmt__printfwas reduced from about 170 ms to about 24 ms, with a title from about 42 ms to about 21 ms, and withpretty_table(HTML, data)from about 55 ms to about 24 ms. The time to load the package increased by about 2 ms. - Compile the text back end only once for all the specifications of the lines at the column labels, data rows, and data columns (
:all,:none, or a vector of indices) and for all the combinations of optional sections. For example, the time to print the first table with row labels, summary rows, and hidden column labels was reduced from about 100 ms to about 83 ms, and the compiled package is about 0.5 MB smaller. - Compile the preprocessing of the table only once for all the types of the formatters, summary rows, cell alignments, row labels, and column labels. For example, the time to print the first table with a new formatter function was reduced from about 115 ms to about 45 ms, and with symbols as column labels, from about 115 ms to about 30 ms.
- Load REPL.jl only in Julia 1.11 and 1.12, where it avoids a long precompilation time. In Julia 1.13 or newer, this change reduces the time to load the package by about 50 ms.
TextTableStyleis now a mutable structure with constant fields, reducing the time to print the first table with a custom text style from about 160 ms to about 40 ms. The equality and the hash still consider its fields.- Avoid the invalidation of the compiled code of the package when other packages define new string types or conversions to
String, which forced the text back end to be compiled again. For example, the time to print the first table after loading InlineStrings.jl (a dependency of CSV.jl) was reduced from about 700 ms to about 30 ms. - Render the escape sequences of the style of the text back end when the style is created instead of once per cell.
- Reduce the time to print the first table. Each back end now gathers its keywords in an options structure and compiles its rendering body once, so a set of keywords not seen before (for example,
line_breaks = true) costs a few milliseconds instead of 150 to 230 ms in Julia 1.12, and a new highlighter vector type or width keyword type no longer compiles the rendering body again. The keyword constructors ofTextTableStyle,TextHighlighter, andHighlighterare compiled once for every set of keywords, and the data accessors are no longer specialized on the table type where it does not pay off. - Emit the vertical lines of the HTML back end as the borders of
<col>elements and the horizontal lines as the borders of the<tr>elements instead of inline borders in every cell. Since the table borders are collapsed, the rendering is the same, but the output of a large table is about 40% smaller and it is rendered faster. The line under a merged column label stays in the cell. - Keep the back end default for every unset aspect of a
LineStylein the HTML, Typst, and Excel back ends. For example,TableFormat(; top_line = LineStyle(; color = :red))now keeps the default width of the top line instead of resetting it to the thinnest one. The conversion functionshtml_line_style,typst_line_style,excel_line_style, andlatex_line_styleaccept the keyworddefaultwith the default line design. - Cover the lines between the column label rows and under the merged column labels in
@text__all_horizontal_linesand@text__no_horizontal_lines, like the macros of the other back ends cover their backend-specific fields. - Validate the positional constructor of
LineStyleexactly like the keyword constructor. - Convert the general
Highlighterto the native highlighter of the back end once per printed table.Highlighteris now immutable and it can be shared between tasks. - The conversion from
CrayontoFaceis lossy: the attributesblink,conceal, andresetare dropped with a warning shown once per session, the attributes explicitly turned off (for example,bold = false) and the default color of the terminal are omitted because every styled segment starts after a reset,boldhas priority overfaintwhen both are set, and the colors of the 256-color palette (except the 16 system colors) are converted to 24-bit colors, which requires a terminal with 24-bit color support. - The line character fields of
TextTableFormatare placed after the other fields, andTextTableFormatandHtmlTableFormatkeep positional constructors with the fields of v3.4.8. Hence, the code that builds those objects positionally keeps working. The decoration converters of the HTML, LaTeX, Typst, and Excel styles also accept any vector, like the constructors of v3.4.8 did. - Accept any real number in the keywords
data_column_widths,minimum_data_column_widths, andmaximum_data_column_widthsof the Excel back end, which previously requiredFloat64values. - PrettyTables.jl now requires StringManipulation.jl v0.6.1.
- Breaking Change:
maximum_number_of_columns = 0now crops the table to zero data columns, printing only the continuation column, exactly likemaximum_number_of_rows = 0does for the rows. Previously, it meant "no limit", which is still the meaning of a negative value (the default). - Breaking Change: A dictionary that complies with the Tables.jl API (e.g., a dictionary of column vectors with
SymbolorStringkeys) is now printed as a table, like any other Tables.jl source, instead of a two-column table with its keys and values. The other dictionaries are still printed as keys and values. - Validate every alignment symbol, throwing an
ArgumentErrorif it is not:l,:c,:r, or:n(or their uppercase versions). Invalid symbols were silently accepted, misaligning the cells in the text back end. The uppercase symbols now work in every back end, and the text back end renders:nas left alignment. - Document the macro
@latex_cell_strand the functionprintable_cell_textof the custom text cell API, whose docstrings were written as raw strings without@docand, hence, were not registered. - Escape the plain text of every cell in the HTML back end when the renderer is
:print. A string whose type can be shown as HTML, such as a view into a styled string, was emitted without escaping, allowing the injection of HTML code. Furthermore, the views into styled strings are now rendered as styled strings in every back end. - Use the same border for each horizontal line in the HTML, LaTeX, and Typst back ends:
top_linefor the line before the first row after the title and subtitle,header_lineonly for the line after the column labels, andmiddle_linefor the lines around the row group labels. The LaTeX back end usedheader_linefor the line after the title and after the row group labels, and the HTML back end used it for the line before the column labels. - The HTML back end no longer draws the line after the last data row when
horizontal_lines_at_data_rowscontains it. As in the other back ends, this line is only drawn ifhorizontal_line_after_data_rowsistrue. - Escape the row group labels in the Markdown back end. A
|in a label added a column to the table. - Escape the stubhead label and the row number column label in the Markdown back end, as the column labels.
- Always crop the custom text cells to the column width. A custom cell in the shrinkable column crossed the column border if the maximum column width was larger than the shrunk width.
- Erase the last line of the previous table when overwriting the display with a text table that does not end with a new line. The characters of this line that were not overwritten remained in the display.
- Escape the line breaks in the text of
UrlTextCell, which is always rendered in a single line. A line break broke the table row. - Consider the continuation column when shrinking the shrinkable column of a text table. The column was not shrunk enough, and the display cropped the continuation column and the right border.
- Assume the minimum width of the columns (three characters) when limiting the number of rendered columns of a text table to the display width. The limit assumed five characters per column, omitting narrow columns that fit in the display.
- Keep at least one display line when
reserved_display_linesis equal to or larger than the display height in the text back end. The reserved lines were ignored in this case, printing a taller table than when reserving fewer lines. - Equalize the widths of the text data columns before cropping the cells to the fixed widths. The cells of the columns widened by
equal_data_column_widthsremained cropped to their fixed widths. - Treat a display width equal to 0 as unlimited when drawing the intersections of the horizontal lines in the text back end, as documented. The intersections were replaced by the line character.
- Give
fixed_data_column_widthsprecedence overmaximum_data_column_widthsin the text back end, as documented. The cells of a column with a fixed width were still cropped to its maximum width. - Handle the merged column labels when
column_label_width_based_on_first_line_onlyistruein the text back end. The merged labels after the first line widened the columns and were cropped to the width of a single column. - Widen the text table to fit the printed row group labels, distributing the additional width among the data columns without a fixed width. If no column can be widened, the label is cropped. A long label crossed the right border of the table.
- Compute the width of the row group labels in the text back end considering only the vertical lines drawn at the edges of the table, and draw the line at the right edge of the labels only if the other rows have it. The right border of the labels was shifted when the table had no vertical line at the beginning or at the end.
- Reset the style of the horizontal lines of the text back end that are cropped at the display edge. The style leaked into the rest of the output.
- Reset the cropping of the custom text cells when they fit in the column. The cropping of a line was applied to the other lines of the cell, and the one of a position was applied to the other positions of the same cell object.
- Keep the middle cropping of text tables with line breaks if the display does not limit the number of printed rows. It was always replaced by the bottom cropping when the table had to fit in the display.
- Consider the line of the omitted cell summary when fitting a text table whose data columns are omitted in the display height. It was only considered if data rows were also omitted, making the table one line taller than the display.
- Count exactly the lines drawn by the text back end when fitting the table in the display height. The table could use more lines than available, e.g., with row group labels after rows with horizontal lines, in the middle cropping, with lines at the merged column labels, or with line breaks, and it could be cropped although it fit, e.g., with a row group label at the first row or with line breaks.
- Do not draw the line before a row group label at the first row of the text back end when the column labels are hidden. It was drawn right after the top line, which now has no intersections because the label spans the entire table.
- Use the data row indices to draw the horizontal lines around the row group labels in the middle cropping of the text back end. The lines were drawn after the wrong rows.
- Fix the line after the continuation row in the middle cropping of the text back end. The line after the data rows was drawn before the data rows printed after the continuation row, and a row group label after the continuation row was preceded by two lines.
- Escape the sequences
--,---, and...in the Typst back end, which Typst converted into dashes and an ellipsis. - Escape a
.or(right after a component in the Typst back end, such as the footnote superscript or a styled region of a styled string. Typst parsed it as a field access or a function call on the component, breaking the document. - Escape the double quotes and backslashes of the
Markdown.MDcells in the Typst back end, which are emitted inside string literals. - Escape the slashes in the Typst back end, since
//and/*started a comment that broke the document, and the markups that Typst recognizes at the beginning of a cell (headings, lists, and term lists). - Keep the leading and trailing white spaces of a cell outside the style markers in the Markdown back end. Markdown does not recognize emphasis markers next to a white space, showing them literally.
- Consider the summary rows in the column widths of the Markdown back end when the table has no data rows.
- Print the header separator of the Markdown back end before the first row of the table body when the column labels are hidden. It was missing if the table began with the continuation row or the summary rows and printed after the first row group label.
- Print the omitted cell summary in the Markdown back end when the column labels are the last row of the table.
- Always escape the pipes in the Markdown back end, including in
Markdown.MDcells and whenallow_markdown_in_cellsistrue, unless they are already escaped. A pipe split the table cell. - Do not escape the Markdown characters inside code spans in the Markdown back end, which render their content verbatim, except the pipe. The code span delimiter is now longer than any sequence of backticks in the content.
- Place the footnote references after the style of the cells in the Markdown back end, as in the row numbers. Inside a code span, such as in the default style of the column labels after the first line, the references did not work.
- Keep the lower column label rows of the columns under a merged cell in the Markdown back end. The entire column label was replaced by the fill that represents the merged cell.
- Escape
|and"as\textbar{}and\textquotedbl{}in the LaTeX back end. Under the default OT1 font encoding, they were typeset as—and”. - Align the source notes with
source_note_alignmentin the LaTeX back end. They were aligned withfootnote_alignment. - Always escape the title, subtitle, row group labels, footnotes, and source notes in the HTML back end. As documented,
allow_html_in_cellsonly applies to the table cells, but it also disabled the escaping of those sections. - Place the continuation row in the table body of the HTML back end when no data row is printed. It was placed in the table head.
- Close the table header of the Typst back end after the column labels. When no data row was printed, the continuation row, the omitted cell summary, and the table footer were placed inside it.
- Keep the insertion order of the CSS properties of the same family (e.g.,
borderandborder-bottom) in the HTML back end, so that a shorthand property in the user style overrides the longhand properties set by the back end. The properties were sorted by name, placing the shorthand before its longhands. - Keep the line breaks of
Markdown.MDcells in the HTML back end, preserving the content of code blocks, and replace them with spaces in the LaTeX and Markdown back ends (or with<br>ifline_breaksistruein the Markdown back end). They were removed, joining the words of different lines. - Apply only the style of the merged cells to the merged column labels in the HTML and Typst back ends, as in the other back ends. The style of the column labels was also applied, overriding it. The default style of the merged cells is now bold in the first line of the column labels (HTML and Typst) and in the other lines (Typst), keeping the default appearance of the tables.
- Write the cell content verbatim in the HTML back end. The minification removed the line breaks and the leading spaces of each line of the content, whereas the indentation added spaces to them, corrupting, for example,
<pre>elements. - Escape the style properties in the HTML back end. A quote in a property, such as a quoted font family, closed the
styleattribute. - Escape the attribute values, such as the column label titles, as HTML attributes in the HTML back end. They were escaped as Julia strings, doubling the backslashes and showing the line breaks as
\n. - Emit the HTML, LaTeX, or Typst representation of a cell unchanged when the renderer is
:show, instead of escaping it. - Validate the length of the vectors with one column label style per column in the Typst back end and in the Excel and Word extensions, like the other back ends do. A shorter vector used to throw a
BoundsError, whereas the extra styles of a longer vector were silently ignored. - Pass the indices of the cell in the data object to every user function (formatters, highlighters, cell alignment functions, and Excel formatters). Previously, they received the 1-based position of the cell in the printed table, making
data[i, j]throw or return the wrong value for data with arbitrary axes, such asOffsetArrays, whereas the summary row functions already received the data indices. - Fix the outer lines of the Excel back end, which were drawn around the footnotes and the source notes instead of only around the content of the table.
- Fix the line before the row group labels in the Excel back end, which was drawn even if
horizontal_line_before_row_group_labelwasfalse. - Fix the width of the continuation column in the Excel back end, which used the widths configured for the first hidden data column.
Merged pull requests:
- Gate HTML StyledStrings issue test on Julia ≥1.11 (#321) (@Copilot)
- Add Word backend as package extension (#323) (@jkrumbiegel)
Closed issues:
- Multilevel tables (#175)
- hcrop_mode (#215)
- Select/reorder columns from table (#245)
- When precompiling without a terminal support reset crayon string is blank (#246)
- Question: how to save subsections of a table (#248)
- Text format: different row character for header line (#255)
- crop keyword argument in docs (#272)
- [Typst] Add support to styled strings (#286)
- tables as first-class objects (#309)
- maximum_number_of_rows = -1 doesn't seem to work correctly (#319)
- Styled Strings in Excel (#322)
- How to remove bold formatting from LaTeX column and row labels? (#324)