refactor: remove legacy parser system and migrate to unified engine
- Remove internal/parser package and all legacy ID generation logic - Update enhancer and auto_enhancer to use unified engine functions - Migrate utility functions (FindViableChildren, HasEditableContent) to engine - Create stub enhancer implementation that uses unified engine architecture - Ensure all enhancement workflows now go through single unified system - Remove parser dependencies and consolidate content processing logic This completes the cleanup phase - all components now use unified engine instead of fragmented ID generation systems.
This commit is contained in:
@@ -7,20 +7,18 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/insertr/insertr/internal/parser"
|
||||
"github.com/insertr/insertr/internal/engine"
|
||||
"golang.org/x/net/html"
|
||||
)
|
||||
|
||||
// AutoEnhancer handles automatic enhancement of HTML files
|
||||
type AutoEnhancer struct {
|
||||
parser *parser.Parser
|
||||
// Remove parser dependency - auto enhancement is now self-contained
|
||||
}
|
||||
|
||||
// NewAutoEnhancer creates a new AutoEnhancer instance
|
||||
func NewAutoEnhancer() *AutoEnhancer {
|
||||
return &AutoEnhancer{
|
||||
parser: parser.New(),
|
||||
}
|
||||
return &AutoEnhancer{}
|
||||
}
|
||||
|
||||
// AutoEnhanceResult contains statistics about auto-enhancement
|
||||
@@ -133,7 +131,7 @@ func (ae *AutoEnhancer) enhanceNode(node *html.Node, result *EnhancementResult,
|
||||
|
||||
// Check if this is a container that should use expansion
|
||||
if ae.isGoodContainer(node) {
|
||||
viableChildren := parser.FindViableChildren(node)
|
||||
viableChildren := engine.FindViableChildren(node)
|
||||
if len(viableChildren) >= 2 || (aggressive && len(viableChildren) >= 1) {
|
||||
// Add insertr class to container for expansion
|
||||
ae.addInsertrClass(node)
|
||||
@@ -232,9 +230,9 @@ func (ae *AutoEnhancer) isGoodIndividualElement(node *html.Node) bool {
|
||||
return ae.hasEditableContent(node)
|
||||
}
|
||||
|
||||
// hasEditableContent uses the parser's enhanced detection logic
|
||||
// hasEditableContent uses the engine's enhanced detection logic
|
||||
func (ae *AutoEnhancer) hasEditableContent(node *html.Node) bool {
|
||||
return parser.HasEditableContent(node)
|
||||
return engine.HasEditableContent(node)
|
||||
}
|
||||
|
||||
// hasInsertrClass checks if a node already has the insertr class
|
||||
|
||||
Reference in New Issue
Block a user