diff --git a/doc/BBCode.md b/doc/BBCode.md index d22f7afa5..aeb5e06c9 100644 --- a/doc/BBCode.md +++ b/doc/BBCode.md @@ -1,208 +1,611 @@ Friendica BBCode tags reference ======================== -* [Home](help) +* [Creating posts](help/Text_editor) -Inline ------ +## Inline + -
[u]underlined[/u]: underlined +
BBCode | +Result | +
---|---|
[b]bold[/b] | +bold | +
[i]italic[/i] | +italic | +
[u]underlined[/u] | +underlined | +
[s]strike[/s] | +|
[o]overline[/o] | +overline | +
[color=red]red[/color] | +red | +
[url=http://www.friendica.com]Friendica[/url] | +Friendica | +
[img]http://friendica.com/sites/default/files/friendika-32.png[/img] | ++ |
[img=64x32]http://friendica.com/sites/default/files/friendika-32.png[/img] + Note: provided height is simply discarded. |
+ + |
[size=xx-small]small text[/size] | +small text | +
[size=xx-large]big text[/size] | +big text | +
[size=20]exact size[/size] (size can be any number, in pixel) | +exact size | +
[font=serif]Serif font[/font] | +Serif font | +
[s]strike[/s]:
[color=red]red[/color]: red +
BBCode | +Result | +
---|---|
[url]http://friendica.com[/url] | +http://friendica.com | +
[url=http://friendica.com]Friendica[/url] | +Friendica | +
[bookmark]http://friendica.com[/bookmark] +#^[url]http://friendica.com[/url] |
+ + |
[bookmark=http://friendica.com]Bookmark[/bookmark] +#^[url=http://friendica.com]Bookmark[/url] +#[url=http://friendica.com]^[/url][url=http://friendica.com]Bookmark[/url] |
+ + |
[url=/posts/f16d77b0630f0134740c0cc47a0ea02a]Diaspora post with GUID[/url] | +Diaspora post with GUID | +
#Friendica | +#Friendica | +
@Mention | +@Mention | +
acct:account@friendica.host.com (WebFinger) | +acct:account@friendica.host.com | +
[mail]user@mail.example.com[/mail] | +user@mail.example.com | +
[mail=user@mail.example.com]Send an email to User[/mail] | +Send an email to User | +
[url=http://www.friendica.com]Friendica[/url]: Friendica +## Blocks -
[img]http://friendica.com/sites/default/files/friendika-32.png[/img]: +
BBCode | +Result | +
---|---|
[p]A paragraph of text[/p] | +A paragraph of text |
+
Inline [code]code[/code] in a paragraph | +Inline |
+
[code]Multi line code[/code] |
+ Multi
+line
+code |
+
[code=php]function text_highlight($s,$lang)[/code] | +
|
+
[quote]quote[/quote] | +quote |
+
[quote=Author]Author? Me? No, no, no...[/quote] | +Author wrote:Author? Me? No, no, no... |
+
[center]Centered text[/center] | +Centered text |
+
You should not read any further if you want to be surprised.[spoiler]There is a happy end.[/spoiler] | +
+
+ You should not read any further if you want to be surprised.
+ + Click to open/close + +
+ |
+
[spoiler=Author]Spoiler quote[/spoiler] | +
+
+ Author wrote:
+ + Click to open/close + +
+ |
+
[hr] (horizontal line) | +
[size=xx-small]small text[/size]: small text +### Titles -
[size=xx-large]big text[/size]: big text +
BBCode | +Result | +
---|---|
[h1]Title 1[/h1] | +Title 1 |
+
[h2]Title 2[/h2] | +Title 2 |
+
[h3]Title 3[/h3] | +Title 3 |
+
[h4]Title 4[/h4] | +Title 4 |
+
[h5]Title 5[/h5] | +Title 5 |
+
[h6]Title 6[/h6] | +Title 6 |
+
[size=20]exact size[/size] (size can be any number, in pixel): exact size +### Tables +
BBCode | +Result | +|||||||||
---|---|---|---|---|---|---|---|---|---|---|
[table] + [tr] + [th]Header 1[/th] + [th]Header 2[/th] + [th]Header 2[/th] + [/tr] + [tr] + [td]Cell 1[/td] + [td]Cell 2[/td] + [td]Cell 3[/td] + [/tr] + [tr] + [td]Cell 4[/td] + [td]Cell 5[/td] + [td]Cell 6[/td] + [/tr] +[/table] |
+
+
|
+|||||||||
[table border=0] | +
+
|
+|||||||||
[table border=1] | +
+
|
+
BBCode | +Result | +
---|---|
[ul] + [li] First list element + [li] Second list element +[/ul] +[list] + [*] First list element + [*] Second list element +[/list] |
+
+
|
+
[ol] + [*] First list element + [*] Second list element +[/ol] +[list=1] + [*] First list element + [*] Second list element +[/list] |
+
+
|
+
[list=] + [*] First list element + [*] Second list element +[/list] |
+
+
|
+
[list=i] + [*] First list element + [*] Second list element +[/list] |
+
+
|
+
[list=I] + [*] First list element + [*] Second list element +[/list] |
+
+
|
+
[list=a] + [*] First list element + [*] Second list element +[/list] |
+
+
|
+
[list=A] + [*] First list element + [*] Second list element +[/list] |
+
+
|
+
[code]code[/code]- -
code
-
-- -
[code=php]function text_highlight($s,$lang)[/code]- -
- function text_highlight($s,$lang)
-
-- -
[quote]quote[/quote]- -
quote- -
- -
[quote=Author]Author? Me? No, no, no...[/quote]- -Author wrote:
Author? Me? No, no, no...- -
- -
[center]centered text[/center]- -
- -
You should not read any further if you want to be surprised.[spoiler]There is a happy end.[/spoiler]- -You should not read any further if you want to be surprised.
- -**Table** -
[table border=1] - [tr] - [th]Tables now[/th] - [/tr] - [tr] - [td]Have headers[/td] - [/tr] -[/table]- -
Tables now |
---|
Have headers |
- -**List** - -
[list] - [*] First list element - [*] Second list element -[/list]-
[ol] - [*] First list element - [*] Second list element -[/ol]-
[list=1]: decimal - -
[list=i]: lover case roman - -
[list=I]: upper case roman - -
[list=a]: lover case alphabetic - -
[list=A]: upper case alphabetic - - - - -Embed ------- +## Embed You can embed video, audio and more in a message. -
[video]url[/video]-
[audio]url[/audio]+
BBCode | +Result | +
---|---|
[video]url[/video] | +Where *url* can be an url to youtube, vimeo, soundcloud, or other sites wich supports oembed or opengraph specifications. | +
[video]Video file url[/video] +[audio]Audio file url[/audio] | +Full URL to an ogg/ogv/oga/ogm/webm/mp4/mp3 file. An HTML5 player will be used to show it. | +
[youtube]Youtube URL[/youtube] | +Youtube video OEmbed display. May not embed an actual player. | +
[youtube]Youtube video ID[/youtube] | +Youtube player iframe embed. | +
[vimeo]Vimeo URL[/vimeo] | +Vimeo video OEmbed display. May not embed an actual player. | +
[vimeo]Vimeo video ID[/vimeo] | +Vimeo player iframe embed. | +
[iframe]URL[/iframe] | +General embed, iframe size is limited by the theme size for video players. | +
[url]*url*[/url] | +If *url* supports oembed or opengraph specifications the embedded object will be shown (eg, documents from scribd). +Page title with a link to *url* will be shown. | +
[url]*url*[/url]+This require "openstreetmap" addon version 1.3 or newer. If the addon isn't activated, +the raw coordinates are shown instead. -If *url* supports oembed or opengraph specifications the embedded object will be shown (eg, documents from scribd). -Page title with a link to *url* will be shown. +
BBCode | +Result | +
---|---|
[map]address[/map] | +Embeds a map centered on this address. | +
[map=lat,long] | +Embeds a map centered on those coordinates. | +
[map] | +Embeds a map centered on the post's location. | +
[map]address[/map]-
[map=lat,long]+If you want to spread your post to several third party networks you can have the problem that these networks have a length limitation like on Twitter. -You can embed maps from coordinates or addresses. -This require "openstreetmap" addon version 1.3 or newer. - ------------------------------------------------------------ - -Abstract for longer posts -------------------------- - -If you want to spread your post to several third party networks you can have the problem that these networks have (for example) a length limitation. -(Like on Twitter) - -Friendica is using a semi intelligent mechanism to generate a fitting abstract. -But it can be interesting to define an own abstract that will only be displayed on the external network. -This is done with the [abstract]-element. -Example: - -
[abstract]Totally interesting! A must-see! Please click the link![/abstract] -I want to tell you a really boring story that you really never wanted -to hear.- -Twitter would display the text "Totally interesting! A must-see! Please click the link!". -On Friendica you would only see the text after "I want to tell you a really ..." +Friendica is using a semi intelligent mechanism to generate a fitting abstract. +But it can be interesting to define a custom abstract that will only be displayed on the external network. +This is done with the [abstract]-element. +
BBCode | +Result | +
---|---|
[abstract]Totally interesting! A must-see! Please click the link![/abstract] +I want to tell you a really boring story that you really never wanted to hear. |
+ Twitter would display the text "Totally interesting! A must-see! Please click the link!". +On Friendica you would only see the text after "I want to tell you a really ..." | +
-[abstract]Hi friends Here are my newest pictures![abstract] -[abstract=twit]Hi my dear Twitter followers. Do you want to see my new -pictures?[abstract] -[abstract=apdn]Helly my dear followers on ADN. I made sone new pictures -that I wanted to share with you.[abstract] -Today I was in the woods and took some real cool pictures ... -- -For Twitter and App.net the system will use the defined abstracts. -For other networks (e.g. when you are using the "statusnet" connector that is used to post to GNU Social) the general abstract element will be used. +
BBCode | +Result | +
---|---|
+[abstract]Hi friends Here are my newest pictures![/abstract] +[abstract=twit]Hi my dear Twitter followers. Do you want to see my new +pictures?[/abstract] +[abstract=apdn]Helly my dear followers on ADN. I made sone new pictures +that I wanted to share with you.[/abstract] +Today I was in the woods and took some real cool pictures ... |
+ For Twitter and App.net the system will use the defined abstracts. +For other networks (e.g. when you are using the "statusnet" connector that is used to post to GNU Social) the general abstract element will be used. |
+
-[abstract]These days I had a strange encounter ...[abstract] -[abstract=goog]Helly my dear Google+ followers. You have to read my -newest blog post![abstract] -[abstract=face]Hello my Facebook friends. These days happened something -really cool.[abstract] -While taking pictures in the woods I had a really strange encounter ...+
BBCode | +Result | +
---|---|
+[abstract]These days I had a strange encounter...[/abstract] +[abstract=goog]Helly my dear Google+ followers. You have to read my newest blog post![/abstract] +[abstract=face]Hello my Facebook friends. These days happened something really cool.[/abstract] +While taking pictures in the woods I had a really strange encounter... |
+ Google and Facebook will show the respective abstracts while the other networks will show the default one. + Meanwhile, Friendica won't show any of the abstracts. |
+
BBCode | +Result | +
---|---|
If you need to put literal bbcode in a message, [noparse], [nobb] or [pre] are used to escape bbcode: +
|
+ [b]bold[/b] | +
[nosmile] is used to disable smilies on a post by post basis + + [nosmile] ;-) :-O + |
+ ;-) :-O | +
Custom inline styles + +[style=text-shadow: 0 0 4px #CC0000;]You can change all the CSS properties of this block.[/style] |
+ You can change all the CSS properties of this block. | +
Custom class block + +[class=custom]If the class exists, this block will have the custom class style applied.[/class] |
+ <span class="custom">If the class exists, |
+
[noparse][b]bold[/b][/noparse]: [b]bold[/b] diff --git a/include/bbcode.php b/include/bbcode.php index ed2325364..ebafc353a 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -146,7 +146,7 @@ function cleancss($input) { if (($char >= "a") and ($char <= "z")) $cleaned .= $char; - if (!(strpos(" #;:0123456789-_", $char) === false)) + if (!(strpos(" #;:0123456789-_.%", $char) === false)) $cleaned .= $char; } @@ -892,8 +892,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal // we may need to restrict this further if it picks up too many strays // link acct:user@host to a webfinger profile redirector - $Text = preg_replace('/acct:(.*?)@(.*?)([ ,])/', 'acct:' . "$1@$2$3" . '',$Text); + $Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', 'acct:$1@$2',$Text); // Perform MAIL Search $Text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '$1', $Text); diff --git a/include/text.php b/include/text.php index 5c9202c58..83eab1927 100644 --- a/include/text.php +++ b/include/text.php @@ -769,71 +769,75 @@ function activity_match($haystack,$needle) { }} -if(! function_exists('get_tags')) { /** - * Pull out all #hashtags and @person tags from $s; + * @brief Pull out all #hashtags and @person tags from $string. + * * We also get @person@domain.com - which would make * the regex quite complicated as tags can also * end a sentence. So we'll run through our results * and strip the period from any tags which end with one. * Returns array of tags found, or empty array. * - * @param string $s - * @return array + * @param string $string Post content + * @return array List of tag and person names */ -function get_tags($s) { +function get_tags($string) { $ret = array(); // Convert hashtag links to hashtags - $s = preg_replace("/#\[url\=([^\[\]]*)\](.*?)\[\/url\]/ism", "#$2", $s); + $string = preg_replace('/#\[url\=([^\[\]]*)\](.*?)\[\/url\]/ism', '#$2', $string); // ignore anything in a code block - $s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s); + $string = preg_replace('/\[code\](.*?)\[\/code\]/sm', '', $string); // Force line feeds at bbtags - $s = str_replace(array("[", "]"), array("\n[", "]\n"), $s); + $string = str_replace(array('[', ']'), array("\n[", "]\n"), $string); // ignore anything in a bbtag - $s = preg_replace('/\[(.*?)\]/sm','',$s); + $string = preg_replace('/\[(.*?)\]/sm', '', $string); // Match full names against @tags including the space between first and last // We will look these up afterward to see if they are full names or not recognisable. - if(preg_match_all('/(@[^ \x0D\x0A,:?]+ [^ \x0D\x0A@,:?]+)([ \x0D\x0A@,:?]|$)/',$s,$match)) { - foreach($match[1] as $mtch) { - if(strstr($mtch,"]")) { + if (preg_match_all('/(@[^ \x0D\x0A,:?]+ [^ \x0D\x0A@,:?]+)([ \x0D\x0A@,:?]|$)/', $string, $matches)) { + foreach ($matches[1] as $match) { + if (strstr($match, ']')) { // we might be inside a bbcode color tag - leave it alone continue; } - if(substr($mtch,-1,1) === '.') - $ret[] = substr($mtch,0,-1); - else - $ret[] = $mtch; + if (substr($match, -1, 1) === '.') { + $ret[] = substr($match, 0, -1); + } else { + $ret[] = $match; + } } } // Otherwise pull out single word tags. These can be @nickname, @first_last // and #hash tags. - if(preg_match_all('/([!#@][^ \x0D\x0A,;:?]+)([ \x0D\x0A,;:?]|$)/',$s,$match)) { - foreach($match[1] as $mtch) { - if(strstr($mtch,"]")) { + if (preg_match_all('/([!#@][^\^ \x0D\x0A,;:?]+)([ \x0D\x0A,;:?]|$)/', $string, $matches)) { + foreach($matches[1] as $match) { + if (strstr($match, ']')) { // we might be inside a bbcode color tag - leave it alone continue; } - if(substr($mtch,-1,1) === '.') - $mtch = substr($mtch,0,-1); + if (substr($match, -1, 1) === '.') { + $match = substr($match,0,-1); + } // ignore strictly numeric tags like #1 - if((strpos($mtch,'#') === 0) && ctype_digit(substr($mtch,1))) + if ((strpos($match, '#') === 0) && ctype_digit(substr($match, 1))) { continue; + } // try not to catch url fragments - if(strpos($s,$mtch) && preg_match('/[a-zA-z0-9\/]/',substr($s,strpos($s,$mtch)-1,1))) + if (strpos($string, $match) && preg_match('/[a-zA-z0-9\/]/', substr($string, strpos($string, $match) - 1, 1))) { continue; - $ret[] = $mtch; + } + $ret[] = $match; } } return $ret; -}} +} // diff --git a/view/global.css b/view/global.css index 1bc2f11d6..bcf7174ea 100644 --- a/view/global.css +++ b/view/global.css @@ -27,6 +27,10 @@ a.btn, a.btn:hover { background-color: #2d2d2d; } +.overline { + text-decoration: overline; +} + /* List of social Networks */ img.connector, img.connector-disabled { height: 40px; diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index 2be7d5cb4..e284310b8 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -38,6 +38,18 @@ body a { color: $link_color; text-decoration: none; } +/* Anchors incorrectly display with a fixed top menu. This global rule offsets all + * anchors so that accessing them with a # link will actually scroll the associated + * content in the visible part of the page. + * + * anchor.top should be the opposite of body.padding-top + */ +body a[name]:not([href]) { + display: block; + position: relative; + top: -110px; + visibility: hidden; +} body a:hover, body a:focus, body a:active, body a.active, body .btn-link:hover{ /*color: #59d6e4;*/