forked from aaronpk/mediawiki-mf2-dfn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.php
58 lines (35 loc) · 2.84 KB
/
sample.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
ob_start();
?>
T1: '''<dfn>[https://github.com/photo Trovebox]</dfn>''' (formerly [http://theopenphotoproject.org OpenPhoto]) is a photo application [[project]] that lets you store your photos on Dropbox, Amazon S3 or in your garage, and serve them from URLs on your own domain. It's also an online service to "organize and share [[photos]] and [[videos]] with clients and colleagues".
T2: <dfn>Lorem ipsum</dfn> This test does not have bold formatting around the dfn.
T3: <dfn>Lorem ipsum</dfn> This test does not have bold formatting around the dfn. It is also multiple sentences long.
T4: '''<dfn>Lorem ipsum</dfn>''' This test ends the first sentence with a question mark?
T5: '''<dfn>Lorem ipsum</dfn>''' This test ends the first sentence with a question mark? It is also multiple sentences long.
T6: '''<dfn>Lorem ipsum</dfn>''' This test ends the first sentence with an exclamation mark!
T7: '''<dfn>Lorem ipsum</dfn>''' This test ends the first sentence with an exclamation mark! It is also multiple sentences long.
T8: '''<dfn>[http://example.com Lorem ipsum]</dfn>''' This test includes a link in the dfn.
T9: '''<dfn>[http://example.com Lorem ipsum]</dfn>''' This test includes a link in the dfn. It is also multiple sentences long.
T10: '''<dfn>[http://example.com Lorem ipsum]</dfn>''' This test includes a link in the dfn and a [http://example.com link] in the text.
T11: '''<dfn>[http://example.com Lorem ipsum]</dfn>''' This test includes a link in the dfn and a [http://example.com link] in the text. It is also multiple sentences long.
T12: '''<dfn>[http://example.com Lorem ipsum]</dfn>''' This test includes a link in the dfn and a [http://example.com/path/to/test.html more complicated link] in the text.
T13: '''<dfn>[http://example.com Lorem ipsum]</dfn>''' This test includes a link in the dfn and a [http://example.com/path/to/test.html more complicated link] in the text. It is also multiple sentences long.
T14: '''<dfn>post</dfn>''' can refer to either: <ul><li> A discreet piece of content (perhaps a <a href="/note" title="note">note</a> or and <a href="/article" title="article">article</a>) — see also <a href="/posts" title="posts">posts</a>
</li><li> The act of creating the aforementioned content
<ul><li> Also used elsewhere, e.g "posted a comment", "posted a photo"
</li></ul>
</li></ul>
T15: {{stub}}
'''<dfn>Loqi</dfn>''' is a friendly and useful bot present in the #indiewebcamp [[IRC]] channel and other channels.
== Commands and Queries ==
<?php
$text = ob_get_clean();
if ( preg_match_all('/(.*)<dfn>(.+)<\/dfn>(.+?[\.!\?])(?=\s|$)/', $text, $matches, PREG_SET_ORDER) )
{
foreach ( $matches as $match )
{
$text = str_replace($match[0], '<span class="p-summary">'.$match[1].'<dfn class="u-iww-thing-defined h-iww-dfn">'.$match[2].'</dfn>'.$match[3].'</span>', $text);
}
}
echo $text;
echo '<pre>', print_r($matches), '</pre>';