Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds basic tables support #41

Merged
merged 17 commits into from
Dec 26, 2024
Merged

feat: adds basic tables support #41

merged 17 commits into from
Dec 26, 2024

Conversation

devaryakjha
Copy link
Owner

@devaryakjha devaryakjha commented Dec 26, 2024

- Introduced a new `TableExample` class in `table_example.dart` to demonstrate various HTML table structures, including basic tables, tables with colspan and rowspan, and styled tables.
- Updated `examples.dart` to include the new `TableExample` in the list of examples, providing a title, description, path, and builder function for navigation.
- Added a new `TableConverter` to handle HTML table elements in the Tagflow library.
- Updated the `ROADMAP.md` to reflect the completion of various HTML elements, including articles, sections, lists, and basic table structure.
- Included the `meta` package as a dependency in `pubspec.yaml` for enhanced functionality.
- Added a new abstract class `TagflowNode` to unify the handling of nodes in the Tagflow library.
- Updated `TagflowElement` to extend `TagflowNode`, enhancing the structure for representing HTML elements.
- Refactored various converters (e.g., `ElementConverter`, `BlockquoteConverter`, `CodeConverter`, etc.) to work with the new `TagflowNode` type.
- Introduced utility extensions for `TagflowNode` to simplify attribute handling and style management.
- Added a new `TagflowTableElement` class to support table structures, including row and column management.
- Updated the `resolveStyle` method in `TagflowTheme` to accommodate the new node structure.
- Included utility functions in `utils.dart` for better code organization.
- Added a line length ignore directive to `converter.dart` to prevent linting issues.
- Updated the TODO comment in `table_element.dart` to include the author's name for better tracking of implementation tasks.
- Added a new `TagflowImgElement` class to represent image elements in the Tagflow library, encapsulating attributes like `src` and `alt`.
- Updated `ImgConverter` to work with `TagflowImgElement` instead of the generic `TagflowElement`, enhancing type safety and clarity.
- Modified `TagflowSelectableOptions` to use `TagflowImgElement` in the image selection behavior text builder.
- Removed redundant media-related extensions from `TagflowNode`, streamlining the codebase.
- Introduced a new method `hasAttribute` in the `TagflowNode` abstract class to check for the presence of a specific attribute in the node's attributes.
- Removed the redundant `hasAttribute` extension from `TagflowNodeExtensions`, streamlining the codebase and consolidating functionality within the `TagflowNode` class.
…ucture

- Changed the type of `_element` in `Tagflow` from `TagflowElement` to `TagflowNode` for better abstraction.
- Updated `TagflowElement`, `TagflowImgElement`, and `TagflowTableElement` to use `const` constructors and improved attribute handling.
- Introduced new `NodeParser` classes (`ElementParser`, `ImgParser`, `TableParser`) to handle specific HTML elements, enhancing parsing capabilities.
- Refactored the `TagflowParser` to utilize the new parsers, improving modularity and maintainability.
- Enhanced the `reparent` method across various element classes to ensure proper parent-child relationships.
- Added utility functions for attribute parsing and normalization in the new parser structure.
- Updated the `NodeParser` classes to include a `TagflowParser` parameter in the `tryParse` method for improved parsing capabilities.
- Introduced a new `_normalizeClasses` method to clean up class attribute values.
- Refactored `parseChildren` methods across various parsers to utilize the new parser structure, enhancing modularity.
- Added logging of text content in the `TextConverter` for better debugging.
- Updated tests to reflect changes in the `TagflowElement` instantiation.
- Removed logging statements from custom and built-in converters in `converter.dart` for cleaner output.
- Refactored the `getPrefix` method in `ListItemConverter` to ensure the index is only calculated when the list is ordered.
- Updated `TextConverter` to eliminate unnecessary logging of text content.
- Modified `TagflowElement`, `TagflowImgElement`, and `TagflowNode` to streamline the properties used in equality checks, enhancing performance and clarity.
…onverters

- Changed header tags in `table_example.dart` from `<h2>` to `<h3>` for better semantic structure.
- Enhanced `TableConverter` to return a styled container for tables, improving visual representation.
- Updated `TextConverter` to support table-related tags (`tr`, `td`, `th`), expanding its functionality.
- Modified `TagflowTableElement` to flatten the children list for easier access to cell elements.
- Adjusted `TableParser` to initialize spans as a mutable map for better flexibility.
- Refined `TagflowTheme` to improve styling for table headers, ensuring consistent appearance.
…amples

- Updated `table_example.dart` to improve the visual representation of table rows by adding a text color.
- Introduced a new `lookupParent` method in `converter.dart` to facilitate parent tag lookups for better style resolution.
- Enhanced `TableConverter` to utilize row-based styling and improved child conversion logic.
- Added `TableCellConverter` to support table cell-specific styling and behavior.
- Refactored `TextConverter` to integrate text style with color for table-related tags.
- Updated `TagflowTableElement` to manage rows and columns more effectively, ensuring proper child handling.
- Improved `StyleParser` to include color parsing for enhanced style management.
…ers and theme

- Enhanced `TableConverter` to apply a default border style with zero width for improved visual consistency.
- Updated `TagflowTheme` to define a default table border width, ensuring consistent styling across table elements.
- Refined table border properties in the `Table` widget to utilize effective border styles from the theme.
…in tests

- Updated the test for managing parent-child relationships to instantiate the parent element with its child directly, enhancing clarity and reducing complexity.
- Adjusted the way the child element is accessed, ensuring it reflects the new structure of the parent element.
- Enhanced the `coverage` script to include a `packageFilters` option for directories containing tests.
- Updated the `combine-coverage` script to add a `packageFilters` option for directories containing coverage reports, improving the flexibility of coverage report generation.
Copy link

codecov bot commented Dec 26, 2024

Codecov Report

Attention: Patch coverage is 71.75793% with 98 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ges/tagflow/lib/src/core/models/table_element.dart 22.22% 21 Missing ⚠️
...kages/tagflow/lib/src/core/models/img_element.dart 14.28% 18 Missing ⚠️
...ackages/tagflow/lib/src/core/utils/extensions.dart 76.08% 11 Missing ⚠️
packages/tagflow/lib/src/core/parser/parser.dart 50.00% 9 Missing ⚠️
...ages/tagflow/lib/src/core/parser/table_parser.dart 84.74% 9 Missing ⚠️
packages/tagflow/lib/src/style/theme.dart 30.76% 9 Missing ⚠️
packages/tagflow/lib/src/core/models/node.dart 71.42% 4 Missing ⚠️
packages/tagflow/lib/src/converter/converter.dart 70.00% 3 Missing ⚠️
...w/lib/src/converter/converters/list_converter.dart 0.00% 3 Missing ⚠️
.../lib/src/converter/converters/table_converter.dart 92.10% 3 Missing ⚠️
... and 6 more
Files with missing lines Coverage Δ
...src/converter/converters/blockquote_converter.dart 27.27% <ø> (ø)
...w/lib/src/converter/converters/code_converter.dart 50.00% <ø> (ø)
.../src/converter/converters/container_converter.dart 43.47% <ø> (ø)
...es/tagflow/lib/src/converter/styled_container.dart 82.85% <100.00%> (-3.51%) ⬇️
...kages/tagflow/lib/src/core/parser/base_parser.dart 100.00% <100.00%> (ø)
...es/tagflow/lib/src/core/parser/element_parser.dart 100.00% <100.00%> (ø)
...ckages/tagflow/lib/src/core/parser/img_parser.dart 100.00% <100.00%> (ø)
packages/tagflow/lib/src/style/style_parser.dart 50.36% <100.00%> (+0.36%) ⬆️
packages/tagflow/lib/src/tagflow_options.dart 78.94% <ø> (ø)
...low/lib/src/converter/converters/hr_converter.dart 25.00% <0.00%> (ø)
... and 15 more

- Introduced a new test file for ImgParser, validating its ability to identify img elements and parse their attributes correctly.
- Added tests to ensure proper handling of missing attributes, enhancing the robustness of the ImgParser implementation.
- Introduced a new test file for TableConverter, validating its support for table tags and rendering functionality.
- Added tests to ensure correct application of styles and inheritance from parent elements in table structures.
- Exported the parsers from the core parser module to enhance accessibility for table-related parsing operations.
- Removed unused imports from parser and table_parser files to streamline code.
- Introduced a new test file for TableParser, validating its ability to handle various table structures and attributes.
- Added tests for identifying table elements, parsing basic structures, handling empty cells, and preserving attributes, improving test coverage and reliability.
@devaryakjha devaryakjha merged commit e393d9a into main Dec 26, 2024
2 checks passed
@devaryakjha devaryakjha deleted the feat/tables branch December 26, 2024 12:23
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.

1 participant