Skip to content

Commit 49682cb

Browse files
committed
Initial Commit
0 parents  commit 49682cb

File tree

6 files changed

+641
-0
lines changed

6 files changed

+641
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nbproject/*

filter.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
class filter_gistembed extends moodle_text_filter {
4+
5+
public function filter($text, array $options = array()) {
6+
$cnt = preg_match_all('/https?:\/\/gist\.github\.com\/(.*?)\/([a-f0-9]*)/', $text, $matches);
7+
if ($cnt) {
8+
for ($i=0; $i<$cnt; ++$i) {
9+
$script = '<script src="https://gist.github.com/' . $matches[1][$i] . '/' . $matches[2][$i] . '.js"></script>';
10+
$text = str_replace($matches[0][$i], $script, $text);
11+
}
12+
}
13+
return $text;
14+
}
15+
16+
}
17+

lang/en/filter_gistembed.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$string['filtername'] = 'Gist Embed';

0 commit comments

Comments
 (0)