Mort has a .recipe command (pkg/logic/recipe/) that extracts recipes from URLs using the generic Readability algorithm. A dedicated recipe site extractor would produce more reliable, structured results for popular recipe sites.
Most recipe sites use JSON-LD structured data (application/ld+json with @type: Recipe) which is far more reliable than parsing the visual HTML.
Proposed API
packagerecipetypeRecipestruct{NamestringDescriptionstringAuthorstringPrepTimestringCookTimestringTotalTimestringYieldstring// servingsIngredients[]stringInstructions[]stringImageURLstringRatingfloat64CaloriesstringSourceURLstring}typeConfigstruct{}varDefaultConfig=Config{}// ExtractRecipe extracts structured recipe data from any URL.// Uses JSON-LD structured data when available, falls back to DOM parsing.func(cConfig)ExtractRecipe(ctxcontext.Context,bextractor.Browser,urlstring)(*Recipe,error)
Approach
Open the page
Look for <script type="application/ld+json"> containing @type: Recipe
If found, parse the JSON-LD directly (most reliable)
If not, fall back to common recipe page patterns (ingredient lists, instruction steps)
Benefits
Works across all major recipe sites (Allrecipes, Food Network, Bon Appetit, etc.)
JSON-LD parsing is far more reliable than visual scraping
Mort's recipe command gets structured data (ingredients list, cook times) instead of raw article text
Handles JavaScript-rendered recipe pages that Readability can't parse
## Description
Mort has a `.recipe` command (`pkg/logic/recipe/`) that extracts recipes from URLs using the generic Readability algorithm. A dedicated recipe site extractor would produce more reliable, structured results for popular recipe sites.
Most recipe sites use JSON-LD structured data (`application/ld+json` with `@type: Recipe`) which is far more reliable than parsing the visual HTML.
## Proposed API
```go
package recipe
type Recipe struct {
Name string
Description string
Author string
PrepTime string
CookTime string
TotalTime string
Yield string // servings
Ingredients []string
Instructions []string
ImageURL string
Rating float64
Calories string
SourceURL string
}
type Config struct{}
var DefaultConfig = Config{}
// ExtractRecipe extracts structured recipe data from any URL.
// Uses JSON-LD structured data when available, falls back to DOM parsing.
func (c Config) ExtractRecipe(ctx context.Context, b extractor.Browser, url string) (*Recipe, error)
```
## Approach
1. Open the page
2. Look for `<script type="application/ld+json">` containing `@type: Recipe`
3. If found, parse the JSON-LD directly (most reliable)
4. If not, fall back to common recipe page patterns (ingredient lists, instruction steps)
## Benefits
- Works across all major recipe sites (Allrecipes, Food Network, Bon Appetit, etc.)
- JSON-LD parsing is far more reliable than visual scraping
- Mort's recipe command gets structured data (ingredients list, cook times) instead of raw article text
- Handles JavaScript-rendered recipe pages that Readability can't parse
Implemented in PR #48. Added sites/recipe package with ExtractRecipe() that parses JSON-LD structured data (@type: Recipe) with DOM fallback. Handles @graph containers, HowToStep objects, ISO 8601 durations, and flexible author/yield/image formats. Works across all major recipe sites.
Implemented in PR #48. Added `sites/recipe` package with `ExtractRecipe()` that parses JSON-LD structured data (`@type: Recipe`) with DOM fallback. Handles `@graph` containers, `HowToStep` objects, ISO 8601 durations, and flexible author/yield/image formats. Works across all major recipe sites.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Description
Mort has a
.recipecommand (pkg/logic/recipe/) that extracts recipes from URLs using the generic Readability algorithm. A dedicated recipe site extractor would produce more reliable, structured results for popular recipe sites.Most recipe sites use JSON-LD structured data (
application/ld+jsonwith@type: Recipe) which is far more reliable than parsing the visual HTML.Proposed API
Approach
<script type="application/ld+json">containing@type: RecipeBenefits
Implemented in PR #48. Added
sites/recipepackage withExtractRecipe()that parses JSON-LD structured data (@type: Recipe) with DOM fallback. Handles@graphcontainers,HowToStepobjects, ISO 8601 durations, and flexible author/yield/image formats. Works across all major recipe sites.