Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console] Add markdown format to Table#59657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:7.3fromiMi-digital:markdown-table
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionssrc/Symfony/Component/Console/CHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ CHANGELOG
* Deprecate not declaring the parameter type in callable commands defined through `setCode` method
* Add support for help definition via `AsCommand` attribute
* Deprecate methods `Command::getDefaultName()` and `Command::getDefaultDescription()` in favor of the `#[AsCommand]` attribute
* Add support for Markdown format in `Table`

7.2
---
Expand Down
14 changes: 12 additions & 2 deletionssrc/Symfony/Component/Console/Helper/Table.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -417,7 +417,7 @@ public function render(): void
continue;
}

if ($isHeader && !$isHeaderSeparatorRendered) {
if ($isHeader && !$isHeaderSeparatorRendered && $this->style->displayOutsideBorder()) {
$this->renderRowSeparator(
self::SEPARATOR_TOP,
$hasTitle ? $this->headerTitle : null,
Expand DownExpand Up@@ -449,7 +449,10 @@ public function render(): void
}
}
}
$this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat());

if ($this->getStyle()->displayOutsideBorder()) {
$this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat());
}

$this->cleanup();
$this->rendered = true;
Expand DownExpand Up@@ -868,6 +871,12 @@ private function cleanup(): void
*/
private static function initStyles(): array
{
$markdown = new TableStyle();
$markdown
->setDefaultCrossingChar('|')
->setDisplayOutsideBorder(false)
;

$borderless = new TableStyle();
$borderless
->setHorizontalBorderChars('=')
Expand DownExpand Up@@ -905,6 +914,7 @@ private static function initStyles(): array

return [
'default' => new TableStyle(),
'markdown' => $markdown,
'borderless' => $borderless,
'compact' => $compact,
'symfony-style-guide' => $styleGuide,
Expand Down
13 changes: 13 additions & 0 deletionssrc/Symfony/Component/Console/Helper/TableStyle.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,6 +46,7 @@ class TableStyle
private string $cellRowFormat = '%s';
private string $cellRowContentFormat = ' %s ';
private string $borderFormat = '%s';
private bool $displayOutsideBorder = true;
private int $padType = \STR_PAD_RIGHT;

/**
Expand DownExpand Up@@ -359,4 +360,16 @@ public function setFooterTitleFormat(string $format): static

return $this;
}

public function setDisplayOutsideBorder($displayOutSideBorder): static
{
$this->displayOutsideBorder = $displayOutSideBorder;

return $this;
}

public function displayOutsideBorder(): bool
{
return $this->displayOutsideBorder;
}
}
14 changes: 14 additions & 0 deletionssrc/Symfony/Component/Console/Tests/Helper/TableTest.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -112,6 +112,20 @@ public static function renderProvider()
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
+---------------+--------------------------+------------------+

TABLE,
],
[
['ISBN', 'Title', 'Author'],
$books,
'markdown',
<<<'TABLE'
| ISBN | Title | Author |
|---------------|--------------------------|------------------|
| 99921-58-10-7 | Divine Comedy | Dante Alighieri |
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
| 80-902734-1-6 | And Then There Were None | Agatha Christie |

TABLE,
],
[
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp