cooklang / cooklang-import

A command line tool to import recipes into Cooklang format
MIT License
33 stars 12 forks source link

Import schema.org microdata recipe format #28

Open dubadub opened 1 month ago

dubadub commented 1 month ago

We already support similar import in schema.org JSON-LD format, but some web-sites export recipe data only in microdata format. We can get inspiration from a fellow project https://github.com/julianpoy/RecipeClipper/blob/master/src/utils/microdata.js.

Example recipe:

<div itemscope itemtype="https://schema.org/Recipe">
  <span itemprop="name">Mom's World Famous Banana Bread</span>
  By <span itemprop="author">John Smith</span>,
  <meta itemprop="datePublished" content="2009-05-08">May 8, 2009
  <img itemprop="image" src="bananabread.jpg"
       alt="Banana bread on a plate" />

  <span itemprop="description">This classic banana bread recipe comes
  from my mom -- the walnuts add a nice texture and flavor to the banana
  bread.</span>

  Prep Time: <meta itemprop="prepTime" content="PT15M">15 minutes
  Cook time: <meta itemprop="cookTime" content="PT1H">1 hour
  Yield: <span itemprop="recipeYield">1 loaf</span>
  Tags: <link itemprop="suitableForDiet" href="https://schema.org/LowFatDiet" />Low fat

  <div itemprop="nutrition"
    itemscope itemtype="https://schema.org/NutritionInformation">
    Nutrition facts:
    <span itemprop="calories">240 calories</span>,
    <span itemprop="fatContent">9 grams fat</span>
  </div>

  Ingredients:
  - <span itemprop="recipeIngredient">3 or 4 ripe bananas, smashed</span>
  - <span itemprop="recipeIngredient">1 egg</span>
  - <span itemprop="recipeIngredient">3/4 cup of sugar</span>
  ...

  Instructions:
  <span itemprop="recipeInstructions">
  Preheat the oven to 350 degrees. Mix in the ingredients in a bowl. Add
  the flour last. Pour the mixture into a loaf pan and bake for one hour.
  </span>

  140 comments:
  <div itemprop="interactionStatistic" itemscope itemtype="https://schema.org/InteractionCounter">
    <meta itemprop="interactionType" content="https://schema.org/CommentAction" />
    <meta itemprop="userInteractionCount" content="140" />
  </div>
  From Janel, May 5 -- thank you, great recipe!
  ...
</div>
singhvibhanshu commented 1 month ago

Can I work on this issue?

dubadub commented 1 month ago

Of course! I'll assign this to you. Thanks!

singhvibhanshu commented 1 month ago

Hey @dubadub! Thank You for assigning me the issue. But, I am an absolute beginner here and I tried to understand your issue and tried my best to understand and solve the issue but didn't get it. Sorry for the inconvenience. You can unassign me this. Again sorry for the inconvenience.

dubadub commented 1 month ago

No problem @singhvibhanshu , thanks for giving a try!