Merge branch 'dev' of /home/macgirvin/roadhouse into dev

This commit is contained in:
nobody 2021-03-03 20:34:39 -08:00
commit fc303c8e1d
3 changed files with 323 additions and 21 deletions

297
doc/en/bbcode.mc Normal file
View file

@ -0,0 +1,297 @@
BBcode Reference
================
[h3]Text Decoration[/h3]
[table]
[tr]
[th]BBcode syntax[/th][th]Rendered text[/th]
[/tr]
[tr]
[td][nobb][b]bold[/b][/nobb][/td][td]<strong>bold</strong>[/td]
[/tr]
[tr]
[td][nobb][i]italic[/i][/nobb][/td][td]<em>italic</em>[/td]
[/tr]
[tr]
[td][nobb][u]underlined[/u][/nobb][/td][td]<u>underlined</u>[/td]
[/tr]
[tr]
[td][nobb][s]strike[/s][/nobb][/td][td]<strike>strike</strike>[/td]
[/tr]
[tr]
[td][nobb]super[sup]script[/sup][/nobb][/td][td]super<sup>script</sup>[/td]
[/tr]
[tr]
[td][nobb]sub[sub]script[/sub][/nobb][/td][td]sub<sub>script</sub>[/td]
[/tr]
[tr]
[td][nobb][color=red]red[/color][/nobb][/td][td]<span style="color: red;">red</span>[/td]
[/tr]
[tr]
[td][nobb][hl]highlighted[/hl][/nobb][/td][td]<span style="background-color: yellow;">highlighted</span>[/td]
[/tr]
[tr]
[td][nobb][font=courier]some text[/font][/nobb][/td][td]<span style="font-family: courier;">some text</span>[/td]
[/tr]
[tr]
[td][nobb][quote]quote[/quote][/nobb][/td][td]<blockquote>quote</blockquote>[/td]
[/tr]
[tr]
[td][nobb][quote=Author]Author? Me? No, no, no...[/quote][/nobb][/td]
[td]<strong class="author">Author wrote:</strong><blockquote>Author? Me? No, no, no...</blockquote>[/td]
[/tr]
[tr]
[td][nobb][size=small]small text[/size]&nbsp;
[size=xx-large]xx-large text[/size]&nbsp;
[size=20]20px exactly[/size]&nbsp'
[/nobb]
Size options include: [b]xx-small, small, medium, large, xx-large[/b][/td]
[td]<span style="font-size: small;">small text</span><br><span style="font-size: xx-large;">xx-large text</span><br><span style="font-size: 20px;">20px exactly</span>[/td]
[/tr]
[tr]
[td][nobb]Add a horizontal bar
[hr]
Like this[/nobb][/td]
[td]Add a horizontal bar<br><hr><br>Like this[/td]
[/tr]
[tr]
[td][nobb]This is
[center]centered[/center]
text[/nobb][/td]
[td]
This is<br><div style="text-align:center;">centered</div><br>text
[/td]
[/tr]
[/table]
<h3>Code blocks</h3>
Code can be rendered generically in a block or inline format (depending on if there are new line characters in the text), or you can specify a supported language for enhanced syntax highlighting. Syntax highlighting requires a suitable rendering addon. Supported languages depend on the addon but [i]may[/i] include include <strong>php, css, mysql, sql, abap, diff, html, perl, ruby, vbscript, avrc, dtd, java, xml, cpp, python, javascript, js, json, sh </strong>.
If a rendering addon is not installed or an unsupported language is specified, the output for syntax highlighted code blocks is the same as the block format code tag.
[table]
[tr]
[th]BBcode syntax[/th][th]Output[/th]
[/tr]
[tr]
[td][nobb][code]function bbcode() { }[/code][/nobb][/td][td]<code>function bbcode() { }</code>[/td]
[/tr]
[tr]
[td][nobb][code=php]
function bbcode() {
$variable = true;
if ( $variable ) {
echo "true";
}
}
[/code][/nobb][/td]
[td]<code>
function bbcode() {
$variable = true;
if ( $variable ) {
echo "true";
}
}
</code>[/td]
[/tr]
[tr]
[td][nobb][nobb]This is how [i]you[/i] can
[u]show[/u] how to use
[hl]BBcode[/hl] syntax[/nobb][/nobb][/td]
[td][nobb]This is how [i]you[/i] can [u]show[/u] how to use [hl]BBcode[/hl] syntax[/nobb][/td]
[/tr][/table]
[h3]Lists[/h3]
[table]
[tr]
[th]BBcode syntax[/th][th]Rendered list[/th]
[/tr]
[tr]
[td][nobb]
[ul]\
[*] First list element
[*] Second list element
[/ul][/nobb][/td]
[td]<ul class="listbullet" style="list-style-type: circle;"><li> First list element</li><li> Second list element<br></li></ul>[/td]
[/tr]
[tr]
[td][nobb]
[ol]\
[*] First list element
[*] Second list element
[/ol][/nobb][/td]
[td]<ul class="listdecimal" style="list-style-type: decimal;"><li> First list element</li><li> Second list element<br></li></ul>[/td]
[/tr]
[tr]
[td][nobb]
[list=A]\
[*] First list element
[*] Second list element
[/list][/nobb]
The list type options are 1, i, I, a, A.[/td]
[td]<ul class="listupperalpha" style="list-style-type: upper-alpha;"><li> First list element</li><li> Second list element</li></ul>[/td]
[/tr]
[/table]
[h3]Tables[/h3]
[table]
[tr]
[th]BBcode syntax[/th][th]Rendered table[/th]
[/tr]
[tr]
[td][nobb][table border=0]\
[tr][th]Header 1[/th][th]Header 2[/th][/tr]\
[tr][td]Content[/td][td]Content[/td][/tr]\
[tr][td]Content[/td][td]Content[/td][/tr]\
[/table][/nobb]
[/td]
[td]<table class="table"><tbody><tr><th>Header 1</th><th>Header 2</th></tr>
<tr><td>Content</td><td>Content</td></tr><tr><td>Content</td><td>Content</td></tr></tbody></table>
[/td]
[/tr]
[tr]
[td][nobb][table border=1]\
[tr][th]Header 1[/th][th]Header 2[/th][/tr]\
[tr][td]Content[/td][td]Content[/td][/tr]\
[tr][td]Content[/td][td]Content[/td][/tr]\
[/table][/nobb][/td]
[td]<table class="table table-bordered"><tbody><tr><th>Header 1</th><th>Header 2</th></tr>
<tr><td>Content</td><td>Content</td></tr><tr><td>Content</td><td>Content</td></tr></tbody></table>
[/td]
[/tr]
[tr]
[td][nobb][table]\
[tr][th]Header 1[/th][th]Header 2[/th][/tr]\
[tr][td]Content[/td][td]Content[/td][/tr]\
[tr][td]Content[/td][td]Content[/td][/tr]\
[/table][/nobb][/td]
[td]<table class="table"><tbody><tr><th>Header 1</th><th>Header 2</th></tr>
<tr><td>Content</td><td>Content</td></tr><tr><td>Content</td><td>Content</td></tr></tbody></table>
[/td]
[/tr]
[/table]
<h3>Links and Embedded Content</h3>
[table]
[tbody]
[tr][th]BBcode syntax[/th][th]Output[/th][/tr]
[tr][td][nobb][video]video URL[/video]<br>
[video poster="image.jpg"]video URL[/video]<br>
[audio]audio URL[/audio]<br>[/nobb][/td]
[td][/td][/tr]
[tr][td][nobb][url=https://zotlabs.com]Zotlabs[/url][/nobb][/td]
[td]<a href="https://zotlabs.com" target="_blank">Zotlabs</a>[/td]
[/tr]
[tr]
[td][nobb]An image
[img]https://example.org/image.jpg[/img]
in some text [/nobb][/td]
[td]An image<br><img src="[baseurl]/images/default_profile_photos/rainbow_man/300.jpg" style="height: 75px; width:75px;" alt="Image/photo"><br>in some text[/td]
[/tr]
[tr]
[td][nobb]An image with alt text
[img alt="photo description"]https://example.org/image.jpg[/img][/nobb][/td]
[td]An image with alt text<br><img src="[baseurl]/images/default_profile_photos/rainbow_man/300.jpg" style="width:75px; width:75px;" title="photo description" alt="photo description">[/td]
[/tr]
[/tbody]
[/table]
<h3>$Projectname specific codes</h3>
[table]
[tbody]
[tr][th]BBcode syntax[/th][th]Output[/th][/tr]
[tr][td][nobb]Magic-auth version of [url] tag
[zrl=https://macgirvin.com]Identity-aware link[/zrl][/nobb][/td]
[td][/td][/tr]
[tr]
[td]Magic-auth version of [img] tag
[nobb][zmg]https://hubzilla.org/some/photo.jpg[/zmg][/nobb]
[/td][td]Image is only viewable by those authenticated and with permission.[/td]
[/tr]
[tr]
[td]Observer-dependent output:
[nobb][observer=1]Text to display if observer IS authenticated[/observer][/nobb]
[/td][td][/td]
[/tr]
[tr]
[td]
[nobb][observer=0]Text to display if observer IS NOT authenticated[/observer][/nobb][/td]
[td][/td]
[/tr]
[tr]
[td][nobb][observer.language=en]Text to display if observer language is English[/observer][/nobb][/td]
[td][/td]
[/tr]
[tr]
[td][nobb][observer.language!=de]Text to display if observer language is not German[/observer][/nobb][/td]
[td][/td]
[/tr]
[tr]
[td][nobb][observer.url][/nobb][/td]
[td]channel URL of observer[/td]
[/tr]
[tr]
[td][nobb][observer.baseurl][/nobb][/td]
[td]website of observer[/td]
[/tr]
[tr]
[td][nobb][observer.name][/nobb][/td]
[td]name of observer[/td]
[/tr]
[tr]
[td][nobb][observer.webname][/nobb][/td]
[td]short name in the url of the observer[/td]
[/tr]
[tr]
[td][nobb][observer.address][/nobb][/td]
[td]address (fediverse-id) of observer[/td]
[/tr]
[tr]
[td][nobb][observer.photo][/nobb][/td]
[td]profile photo of observer[/td]
[/tr]
[tr]
[td][nobb]What is a spoiler?
[spoiler]Text you want to hide.[/spoiler][/nobb][/td]
[td]
What is a spoiler? <div onclick="openClose('opendiv-1131603764'); return false;" class="fakelink">Click to open/close</div><blockquote id="opendiv-1131603764" style="display: none;">Text you want to hide.</blockquote>[/td]
[/tr]
[tr]
[td][nobb][rpost=title]Text to post[/rpost][/nobb]
The observer will be returned to their home hub to enter a post with the specified title and body. Both are optional[/td]
[td]<a href="[baseurl]/rpost?f=&amp;title=title&amp;body=Text+to+post" target="_blank">[baseurl]/rpost?f=&amp;title=title&amp;body=Text+to+post</a>[/td]
[/tr]
[tr]
[td]Generate QR code
This requires the <strong>qrator</strong> addon.
[nobb][qr]text to post[/qr][/nobb][/td]
[td][/td]
[/tr]
[tr]
[td]This requires a suitable map addon such as <strong>openstreetmap</strong>.
[nobb][map][/nobb][/td]
[td]Generate an inline map using the current browser coordinates of the poster, if browser location is enabled[/td]
[/tr]
[tr]
[td]This requires a suitable map addon such as <strong>openstreetmap</strong>.
[nobb][map=latitude,longitude][/nobb][/td]
[td]Generate a map using global coordinates.[/td][/tr]
[tr]
[td]This requires a suitable map addon such as <strong>openstreetmap</strong>.
[nobb][map]Place Name[/map][/nobb][/td]
[td]
Generate a map for a given named location. The first matching location is returned. For instance "Sydney" will usually return Sydney, Australia and not Sydney, Nova Scotia, Canada unless the more precise location is specified. It is highly recommended to use the post preview utility to ensure you have the correct location before submitting the post.
[/td]
[/tr]
[tr]
[td][nobb][&amp;&ZeroWidthSpace;copy;][/nobb][/td]
[td] &copy; [/td]
[/tr]
[/tbody][/table]

View file

@ -22,6 +22,8 @@ To avoid surprises, please use preview when attempting something complex. To pre
Markdown is very susceptible to "false positives" which may add markup instructions unintentionally when using punctuation characters in unusual or uncommon ways. This can happen (for instance) if you include computer code in a post without identifying it as a block of code. If a markdown sequence is not rendered correctly, try adding space around the triggering punctuation and ensure that all computer code is placed in code blocks.
Markdown has two methods for creating code blocks. One of them is to wrap the code block with 3 backticks (```) alone on a line before and after the code. The second is to indent the text 4 spaces or one tab width. This second form causes a lot of false positives in otherwise normal text and for that reason is not supported here.
HTML must be heavily filtered on multi-user web applications to avoid/prevent a type of bad behaviour called "Cross-site scripting". You may not use Javascript at all, and there are a number of restrictions placed on rich-media elements such as audio/video tags and cross-domain content such as iframes. We use bbcode internally for many of these constructs - which will become apparent if you include a video or other rich media link. You may wish to do the same.
Also be aware that all line breaks in your posts are preserved and this may affect the display of HTML lists and tables. When using HTML to create such elements, you may be tempted to make them look "neat" by placing each table or list element on its own line. Don't do this, due to the preserved line breaks. Each list or table row should butt up against the one before it without including a blank line in between them.

View file

@ -1174,6 +1174,7 @@ function bb_fixtable_lf($match) {
// empty space.
$x = preg_replace("/\]\s+\[/",'][',$match[1]);
$x = str_replace("\\\n","\n",$x);
return '[table]' . $x . '[/table]';
}
@ -1484,7 +1485,7 @@ function bbcode($Text, $options = []) {
$Text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx','md_topheader', $Text);
$Text = preg_replace_callback('#^(\#{1,6})\s+([^\#]+?)\s*\#*$#m','md_header', $Text);
$Text = preg_replace_callback('#(^|\n)([`~]{3,})(?: *\.?([a-zA-Z0-9\-.]+))?\n+([\s\S]+?)\n+\2(\n|$)#','md_codeblock',$Text);
$Text = preg_replace('#^(?:\0(.*?)\0\n)?( {4}|\t)(.*?)$#m','<pre><code>$3</code></pre>',$Text);
// $Text = preg_replace('#^(?:\0(.*?)\0\n)?( {4}|\t)(.*?)$#m','<pre><code>$3</code></pre>',$Text);
$Text = preg_replace('#(?<!\\\)`([^\n]+?)`#','<pre><code>$1</code></pre>', $Text);
$Text = preg_replace('#<\/code><\/pre>\n<pre><code(>| .*?>)#','<br>',$Text);
@ -1735,10 +1736,7 @@ function bbcode($Text, $options = []) {
// Check for list text
$Text = preg_replace("/<br>\[\*\/\]/ism",'[*/]',$Text);
$Text = preg_replace("/<br>\[\*\]/ism",'[*/]',$Text);
$Text = str_replace("[*/]", "<li>", $Text);
$Text = preg_replace("/<br>\[\*\]/ism","[*]",$Text);
$Text = str_replace("[*]", "<li>", $Text);
// handle nested lists
@ -1779,28 +1777,33 @@ function bbcode($Text, $options = []) {
$Text = preg_replace_callback("/\[checklist\](.*?)\[\/checklist\]/ism", 'bb_checklist', $Text);
}
$loop = 0;
while (strpos($Text,'[/table]') !== false && strpos($Text,"[table") !== false && ++$loop < 20) {
$Text = preg_replace("/\[table\](.*?)\[\/table\]/ism", '<table class="table">$1</table>', $Text);
$Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/ism", '<table class="table table-responsive table-bordered" >$1</table>', $Text);
$Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/ism", '<table class="table table-responsive" >$1</table>', $Text);
}
if (strpos($Text,'[th]') !== false) {
$Text = preg_replace("/\[th\](.*?)\[\/th\]/sm", '<th>$1</th>', $Text);
$Text = preg_replace("/\[th\](.*?)\[\/th\]/ism", '<th>$1</th>', $Text);
}
if (strpos($Text,'[td]') !== false) {
$Text = preg_replace("/\[td\](.*?)\[\/td\]/sm", '<td>$1</td>', $Text);
$Text = preg_replace("/\[td\](.*?)\[\/td\]/ism", '<td>$1</td>', $Text);
}
if (strpos($Text,'[tr]') !== false) {
$Text = preg_replace("/\[tr\](.*?)\[\/tr\]/sm", '<tr>$1</tr>', $Text);
$Text = preg_replace("/\[tr\](.*?)\[\/tr\]/ism", '<tr>$1</tr>', $Text);
}
if (strpos($Text,'[/table]') !== false) {
$Text = preg_replace("/\[table\](.*?)\[\/table\]/sm", '<table>$1</table>', $Text);
$Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/sm", '<table class="table table-responsive table-bordered" >$1</table>', $Text);
$Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/sm", '<table class="table table-responsive" >$1</table>', $Text);
if (strpos($Text,'[tbody]') !== false) {
$Text = preg_replace("/\[tbody\](.*?)\[\/tbody\]/ism", '<tbody>$1</tbody>', $Text);
}
$Text = str_replace('</tr><br><tr>', "</tr>\n<tr>", $Text);
$Text = str_replace('[hr]', '<hr>', $Text);
$Text = str_replace('[hr/]', '<hr>', $Text);
// This is actually executed in prepare_body()
$Text = str_replace('[nosmile]', '', $Text);
$Text = str_replace('[nosmile/]', '', $Text);
// Check for font change text
if (strpos($Text,'[/font]') !== false) {
@ -1813,25 +1816,25 @@ function bbcode($Text, $options = []) {
// Check for [spoiler] text
$endlessloop = 0;
while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler]") !== false) and (++$endlessloop < 20)) {
while ((strpos($Text, "[/spoiler]")!== false) && (strpos($Text, "[spoiler]") !== false) && (++$endlessloop < 20)) {
$Text = preg_replace_callback("/\[spoiler\](.*?)\[\/spoiler\]/ism", 'bb_spoilertag', $Text);
}
// Check for [spoiler=Author] text
$endlessloop = 0;
while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler=") !== false) and (++$endlessloop < 20)) {
while ((strpos($Text, "[/spoiler]")!== false) && (strpos($Text, "[spoiler=") !== false) && (++$endlessloop < 20)) {
$Text = preg_replace_callback("/\[spoiler=(.*?)\](.*?)\[\/spoiler\]/ism", 'bb_spoilertag', $Text);
}
// Check for [open] text
$endlessloop = 0;
while ((strpos($Text, "[/open]")!== false) and (strpos($Text, "[open]") !== false) and (++$endlessloop < 20)) {
while ((strpos($Text, "[/open]")!== false) && (strpos($Text, "[open]") !== false) && (++$endlessloop < 20)) {
$Text = preg_replace_callback("/\[open\](.*?)\[\/open\]/ism", 'bb_opentag', $Text);
}
// Check for [open=Title] text
$endlessloop = 0;
while ((strpos($Text, "[/open]")!== false) and (strpos($Text, "[open=") !== false) and (++$endlessloop < 20)) {
while ((strpos($Text, "[/open]")!== false) && (strpos($Text, "[open=") !== false) && (++$endlessloop < 20)) {
$Text = preg_replace_callback("/\[open=(.*?)\](.*?)\[\/open\]/ism", 'bb_opentag', $Text);
}
@ -1843,7 +1846,7 @@ function bbcode($Text, $options = []) {
// Check for [quote] text
// handle nested quotes
$endlessloop = 0;
while ((strpos($Text, "[/quote]") !== false) and (strpos($Text, "[quote]") !== false) and (++$endlessloop < 20))
while ((strpos($Text, "[/quote]") !== false) && (strpos($Text, "[quote]") !== false) && (++$endlessloop < 20))
$Text = preg_replace("/\[quote\](.*?)\[\/quote\]/ism", "$QuoteLayout", $Text);
// Check for [quote=Author] text
@ -1852,7 +1855,7 @@ function bbcode($Text, $options = []) {
// handle nested quotes
$endlessloop = 0;
while ((strpos($Text, "[/quote]")!== false) and (strpos($Text, "[quote=") !== false) and (++$endlessloop < 20))
while ((strpos($Text, "[/quote]")!== false) && (strpos($Text, "[quote=") !== false) && (++$endlessloop < 20))
$Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
"<span class=".'"bb-quote"'.">" . $t_wrote . "</span><blockquote>$2</blockquote>",
$Text);