Skip to content

Conversation

@MaestroError
Copy link
Collaborator

This pull request adds support for rendering Notion page properties as markdown tables, both in the backend data structures and in the Blade templates. It introduces a new PropertiesTable service to handle property formatting, updates the core page object to expose a renderPropertiesTable() method, and ensures that markdown output and Blade views include property tables when available. Comprehensive tests are added to validate property handling and rendering.

Backend: Property Table Generation

  • Added the new PropertiesTable service (src/Services/PropertiesTable.php) to convert Notion page properties into markdown tables, supporting various property types and formatting logic.
  • Implemented the renderPropertiesTable() method in the Page object to generate markdown tables using the new service.

Data Structure Updates

  • Updated data assembly in ContentBuilder and MdNotion to include properties_table and hasPropertiesTable fields for both current and child pages, enabling templates to conditionally render property tables. [1] [2] [3]

Blade Template Enhancements

  • Modified page-md.blade.php and full-md.blade.php to display the properties table if available for both current and child pages. [1] [2] [3]

Testing

  • Added a new test suite for property handling in PropertiesTest.php, covering detection, rendering, and access of properties.
  • Updated BladeTemplateTest.php to account for the new properties table fields, ensuring template rendering works as expected. [1] [2] [3] [4]

Example and Usage

  • Provided a new example script (examples/properties-fetch-example.php) and corresponding markdown output (examples/properties-example.md) to demonstrate fetching and rendering page properties as markdown. [1] [2]

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds comprehensive support for rendering Notion page properties as markdown tables. The implementation includes a new PropertiesTable service for converting property data to markdown, updates to the Page object to expose property rendering functionality, and modifications to Blade templates and data structures to include property tables in the generated markdown output.

Key Changes

  • Introduced PropertiesTable service with support for 15+ Notion property types including title, rich_text, URL, email, date, number, checkbox, select, multi_select, status, people, files, relations, rollups, and formulas
  • Added renderPropertiesTable() method to the Page object for generating markdown property tables
  • Updated data assembly in ContentBuilder and MdNotion to include properties_table and hasPropertiesTable fields
  • Enhanced Blade templates to conditionally render property tables for current and child pages

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Services/PropertiesTable.php New service class that converts Notion page properties into markdown tables with comprehensive property type support
src/Objects/Page.php Added renderPropertiesTable() method to generate property tables using the PropertiesTable service
src/MdNotion.php Updated buildFullMarkdownData() to include properties_table and hasPropertiesTable fields in page data
src/ContentBuilder.php Updated data assembly to include property table fields for current and child pages
resources/views/page-md.blade.php Added conditional rendering of properties table for current and child pages
resources/views/full-md.blade.php Added conditional rendering of properties table for current page
tests/Services/PropertiesTableTest.php Comprehensive test suite covering all supported property types with 28 test cases
tests/Objects/PropertiesTest.php Tests for Page object property methods including detection, rendering, and accessors
tests/BladeTemplateTest.php Updated existing tests to include new properties_table fields in test data
examples/properties-fetch-example.php Example script demonstrating how to fetch and render page properties
examples/properties-example.md Sample markdown output showing rendered property table

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

continue;
}

$markdown .= "| {$name} | {$value} |\n";
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Property names and values containing pipe characters (|) will break the markdown table formatting. These characters should be escaped (e.g., using backslash \|) before being inserted into the table to prevent table structure corruption.

For example, if a property name is "A | B" or a value contains "|", the resulting markdown table will be malformed.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

And this feedback: #9 (comment)

continue;
}

$markdown .= "| {$name} | {$value} |\n";
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Property values containing newline characters (\n or \r) will break the markdown table formatting. Multi-line values should either be escaped (e.g., replaced with <br> or spaces) or truncated to maintain valid markdown table structure.

For example, if a rich_text or other property value contains line breaks, it will create invalid markdown table rows.

Suggested change
$markdown .= "| {$name} | {$value} |\n";
// Replace newlines in name and value to avoid breaking markdown table
$safeName = str_replace(["\n", "\r"], ' ', $name);
$safeValue = str_replace(["\n", "\r"], ' ', $value);
$markdown .= "| {$safeName} | {$safeValue} |\n";

Copilot uses AI. Check for mistakes.
MaestroError and others added 2 commits November 13, 2025 19:07
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Nov 13, 2025

@MaestroError I've opened a new pull request, #10, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits November 13, 2025 15:18
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
Escape pipe characters and newlines in markdown table cells
@MaestroError MaestroError merged commit ecdd157 into main Nov 13, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants