List of commits:
Subject Hash Author Date (UTC)
Added a custom Markdown parser 67b9687fb858ba1018d58edd276836a0411acd1e Catalin(ux) M. BOIE 2020-07-31 05:39:49
Add an index variable to rg_template_table f310f34a6c9a2a029d479d14d86e8ea2393ee3dd Catalin(ux) M. BOIE 2020-07-31 05:39:29
Mostly cosmetic in Source page cac471307a58104fbfa7838b34a7e2ffd2e05260 Catalin(ux) M. BOIE 2020-07-31 05:38:48
Do not log bots connections ef9cdff6a0cbd559f1833e46a66cbbbe726d3d99 Catalin(ux) M. BOIE 2020-07-31 05:38:13
Comparison update b67344452d66b2ed8ef53f65470d53f8b40fe59e Catalin(ux) M. BOIE 2020-07-31 05:37:38
Minor fix for a variable type mismatch a0680065333729b91558e77a6df4403ce8f5b1a5 Catalin(ux) M. BOIE 2020-07-31 05:37:20
Minor git fixes a21b35cd0f87b844fe5ce4b8b2e14fab2506296e Catalin(ux) M. BOIE 2020-07-31 05:36:43
Docker updates d3e9cd4e358cac2d4018dcf7dc681288445a679f Catalin(ux) M. BOIE 2020-07-31 05:36:08
Admin report improvements b527baab12e2e08998672559b0f33fc6df15e74c Catalin(ux) M. BOIE 2020-07-31 05:35:25
Cosmetic 30c879d625b094a33bd9a2165c67a8a11e802f42 Catalin(ux) M. BOIE 2020-07-31 05:34:19
Builder, worker and web updates for artifacts c82a7143a24ec987e0d98bb58327ef15bc602d0d Catalin(ux) M. BOIE 2020-07-31 05:30:44
Prevent bots to create accounts 3eacd8103e9a039f3f8585a59c27fdff6fd66ca4 Catalin(ux) M. BOIE 2020-07-08 05:25:37
css: Force the footer to the bottom using flex f89dddc9fa6b2c131448996cc51349e00224eea6 Catalin(ux) M. BOIE 2020-07-04 04:15:03
docs: css tweaks d270a286b160bb5de39ade5d99a58fe26e03b2d5 Catalin(ux) M. BOIE 2020-06-30 17:21:02
Improved admin report 9fa82cc2878886c2195cdd3f334dd532b3ea6a22 Catalin(ux) M. BOIE 2020-06-28 10:19:24
First version of artifacts ad6b6c75aab8d485ea45c1d851f23d83587d6931 Catalin(ux) M. BOIE 2020-06-27 13:11:17
Allow adding bugs for public repos + small fixes e67955ce3360c8c003a718e01844b3d8effa74a6 Catalin(ux) M. BOIE 2020-06-25 16:05:54
History updates 4c4aef444bbd1149f2c02b6da620f184aae1eed6 Catalin(ux) M. BOIE 2020-06-16 05:53:14
Allow cron to execute sub-tasks in parallel - we missed stats f65c76714cf349a53f584c8e65d9e89c24a4fa69 Catalin(ux) M. BOIE 2020-06-12 06:50:40
bug: search: fixed the override of some global variables 82e251ea883e50b8d1476530e0268fd5770fbf41 Catalin(ux) M. BOIE 2020-06-10 21:29:03
Commit 67b9687fb858ba1018d58edd276836a0411acd1e - Added a custom Markdown parser
Author: Catalin(ux) M. BOIE
Author date (UTC): 2020-07-31 05:39
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2020-07-31 05:39
Parent(s): f310f34a6c9a2a029d479d14d86e8ea2393ee3dd
Signer:
Signing key:
Signing status: N
Tree: 07505326b2b6a2ee43916ec545f0090c856f36db
File Lines added Lines deleted
inc/format.inc.php 156 0
File inc/format.inc.php added (mode: 100644) (index 0000000..3580575)
1 <?php
2
3 // This will deal with text formating (Markdown etc.)
4
5 // TODO: we need to escape some URLs and some values
6 function rg_format_markdown($a)
7 {
8 $k = array();
9 $v = array();
10
11 // 2 spaces at the end of the line
12 $k[] = '/ {2}$/mu';
13 $v[] = '<br />';
14
15 // blockquote
16 $k[] = '/^>\s(.*)$/mu';
17 $v[] = '<blockquote><p>\1</p></blockquote>';
18
19 // strikethrough
20 $k[] = '/~~(.*?)~~/uD';
21 $v[] = '<strike>\1</strike>';
22
23 // hr
24 $k[] = '/^---$/mu';
25 $v[] = '<hr />';
26
27 // bold
28 $k[] = '/\*\*(.*?)\*\*/uD';
29 $v[] = '<strong>\1</strong>';
30 $k[] = '/__(.*?)__/uD';
31 $v[] = '<strong>\1</strong>';
32
33 // italic
34 $k[] = '/\*(.*?)\*/uD';
35 $v[] = '<em>\1</em>';
36 $k[] = '/_(.*?)_/uD';
37 $v[] = '<em>\1</em>';
38
39 // image
40 $k[] = '/!\[(.*?)\]\((.*?)\s"(.*?)"\)/uD';
41 $v[] = '<img alt="\1" title="\3" src="\2" />';
42
43 // link
44 $k[] = '/\[(.*?)\]\((.*?)\)/uD';
45 $v[] = '<a href="\2" target="_blank">\1</a>';
46 $k[] = '#(http[s]://.*?)\s#uD';
47 $v[] = '<a href="\1" target="_blank">\1</a>';
48
49 // Headers
50 $k[] = '/^######\s(.*)/mu';
51 $v[] = '<h6>\1</h6>';
52 $k[] = '/^#####\s(.*)/mu';
53 $v[] = '<h5>\1</h5>';
54 $k[] = '/^####\s(.*)/mu';
55 $v[] = '<h4>\1</h4>';
56 $k[] = '/^###\s(.*)/mu';
57 $v[] = '<h3>\1</h3>';
58 $k[] = '/^##\s(.*)/mu';
59 $v[] = '<h2>\1</h2>';
60 $k[] = '/^#\s(.*)/mu';
61 $v[] = '<h1>\1</h1>';
62
63 // Syntax highlighting (not there yet)
64 $k[] = '/`(.*?)`/mu';
65 $v[] = '<code>\1</code>';
66 $k[] = '/```(.*?)```/uD';
67 $v[] = '<code>\1</code>';
68
69 $a = preg_replace($k, $v, $a);
70
71 // tables
72 $ret = array(); $j = 0;
73 $table_started = FALSE;
74 $f = explode("\n", $a); unset($a);
75 foreach ($f as $i => $line) {
76 rg_log('DEBUG: line=' . $line);
77
78 if (preg_match('/^=+$/u', $line) === 1) {
79 rg_log('Found a h1 with = sign');
80 if (($j > 0) && (strlen($line) == strlen($ret[$j - 1]))) {
81 $ret[$j - 1] = '<h1>' . $ret[$j - 1] . '</h1>';
82 continue;
83 }
84 }
85
86 if (preg_match('/^-+$/u', $line) === 1) {
87 rg_log('Found a h2 with - sign');
88 if (($j > 0) && (strlen($line) == strlen($ret[$j - 1]))) {
89 $ret[$j - 1] = '<h2>' . $ret[$j - 1] . '</h2>';
90 continue;
91 }
92 }
93
94 // table line
95 $cont = FALSE;
96 while (1) {
97 $r = preg_split($p = '/\s*\|\s*/u', $line);
98 if (($r === FALSE) || !isset($r[1]))
99 break;
100
101 rg_log_ml('DEBUG: found a table row: ' . print_r($r, TRUE));
102 if ($table_started !== TRUE) {
103 rg_log('DEBUG: But table was not started.');
104 if ($j == 0) {
105 rg_log('DEBUG: this is first line; ship');
106 break;
107 }
108 rg_log('DEBUG: Check previous line [' . $ret[$j - 1] . '] to contain \s|\s');
109 $r2 = preg_split($p = '/\s*\|\s*/u', $ret[$j - 1]);
110 if (($r2 === FALSE) || !isset($r2[1]))
111 break;
112
113 rg_log_ml('DEBUG: header match: ' . print_r($r2, TRUE));
114 rg_log(' DEBUG: Found a table in the previous line!');
115 $ret[$j - 1] = '<table>' . "\n";
116 $ret[$j++] = '<tr><th>'
117 . implode('</th><th>', $r2)
118 . '</th></tr>';
119 $table_started = TRUE;
120 $cont = TRUE;
121 break;
122 }
123
124 $ret[$j++] = '<tr><td>' . implode('</td><td>', $r)
125 . '</td></tr>';
126 $cont = TRUE;
127 break;
128 }
129 if ($cont)
130 continue;
131
132 if ($table_started) {
133 rg_log('DEBUG: we have a normal line but table is in progress; stop table');
134 $ret[$j++] = '</table>';
135 $table_started = FALSE;
136 }
137
138 $ret[$j++] = $line;
139 }
140 if ($table_started) {
141 rg_log('DEBUG: we have a normal line but table is in progress; stop table');
142 $ret[$j++] = '</table>';
143 $table_started = FALSE;
144 }
145
146 $a = implode("\n", $ret); unset($ret);
147
148 $k = array();
149 $v = array();
150
151 $k[] = '/' . "\n\n" . '(.*)' . '(' . "\n\n" . '|$)/u';
152 $v[] = "\n\n" . '<p>\1</p>' . '\2';
153
154 return preg_replace($k, $v, $a);
155 }
156
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main