Mercurial > prosody-modules
comparison mod_ogp/test.lua @ 4254:a4e182d7ff0a
mod_ogp: Improve parsing patterns
author | Seve Ferrer <seve@delape.net> |
---|---|
date | Wed, 18 Nov 2020 11:16:11 +0100 |
parents | |
children | 38da10e4b593 |
comparison
equal
deleted
inserted
replaced
4253:32b4901a9d8d | 4254:a4e182d7ff0a |
---|---|
1 local html = [[ | |
2 <meta property="og:title" content="Example 1"> | |
3 <meta property=og:title content="Example 2"> | |
4 <meta property="og:title" content="Example 3" > | |
5 <meta property="og:title" content="Example 4" /> | |
6 <meta property="og:title" content="Example 5"/> | |
7 <meta property=og:title content=Example 6/> | |
8 <meta property="og:title" content= "Example 7" /> | |
9 <meta property="og:title" itemprop="image primaryImageOfPage" content="Example 8" /> | |
10 <meta content="Example 9" property="og:title" > | |
11 <meta content="Example 10" property="og:title"> | |
12 <meta content="Example 11" property="og:title"/> | |
13 <meta content="Example 12" property="og:title" /> | |
14 <meta content="Example 13" property=og:title > | |
15 <meta content=Example 14 property=og:title > | |
16 <meta content= "Example 15" property="og:title" /> | |
17 <meta content="Example 16" itemprop="image primaryImageOfPage" property="og:title" /> | |
18 ]] | |
19 | |
20 | |
21 local ogp_pattern = [[<meta property=["']?(og:.-)["']? content=%s*["']?(.-)["']?%s-/?>]] | |
22 local ogp_pattern2 = [[<meta content=%s*["']?(.-)["']? property=["']?(og:.-)["']?%s-/?>]] | |
23 | |
24 for property, content in html:gmatch(ogp_pattern) do | |
25 print("Pattern 1|", property, content, "|Pattern 1") | |
26 end | |
27 print('-------------------------------------------------------------') | |
28 for content, property in html:gmatch(ogp_pattern2) do | |
29 print("Pattern 2|", property, content, "|Pattern 2") | |
30 end |