Commit e7702b22 authored by SamJanis's avatar SamJanis

Fixed markdown formatting. Fixed double-border edit bug. Updated permission-fetching functions

__Fixed markdown formatting__
When multiple lines of consecutive formatting marks were written, parsed
formatting alternated between being parsed and original plaintext.
In `func.php` additionaly word boundaries were added, including line breaks and
spaces.

__Fixed double border edit bug__
A bug occured when editing an existing post. Usually the edited post would be
inserted _inside_ the existing one, resulting in a post inside a post, or a
"double-border" effect.

__Copied _getpostpermissions() to _getuserpermissions()__

index_php_getpostpermissions() is now index_php_getuserpermissions().

The difference between the two functions is _getuserpermissions() describes
what the currently signed in user (or visitor) can do, while
_getpostpermissions() describes what permissions the given post has to its
parent(s).

index_php_getpostpermissions() returns:
- accountid (for current post)
- parentid (postid of parent)
- parentaccountid,
- parentreplypermissions
- parentapprovepermissions
- istrustedmember (group member of parent or any direct ancestor)
- istrustedcontact (of parent post author only)
- isrecipient (of parent post)
- preapproved (according to parent post permissions)
- approvalstrusted
- approvalshidden
- canreply

index_php_getuserpermissions() returns all post-specific author details and
permissions (viewpermissions, editpermissions, etc.), as well as:
- istrustedmember (of post, or any parent/direct ancestor)
- istrustedcontact (of post author)
- isrecipient (of post)
- canview
- canedit
- canreply
- preapproved
- canmoderate (for this post. On pages/groups use parent post)
parent 950a136b
......@@ -148,53 +148,43 @@ function func_php_markdowntohtml_process_block($string)
$replace = "\${1}<h2>\${2}</h2>";
$parsedstring = preg_replace($match, $replace, $parsedstring);
/* Find HR tags (The first uses consecutive marks, the folowwing two use three marks with spaces between them) */
$match = '/(\n*)?\s*?[\-*_]{3,}\s*?\n?(\n*)?/';
/* Find HR tags by looking for consecutive marks on a single line,
* with or without spaces between them. */
$match = '/(^|\n+)\s*?[\-_*]\s?[^\n]?[\-_*][^\n]?\s?[^\n][\-_*]*\s*?(\n|$){1,2}/';
$replace = "\${1}<hr>\${2}";
$parsedstring = preg_replace($match, $replace, $parsedstring);
$match = '/(\n*)?\s*?\*\s?[^\n]\*[^\n]\s?[^\n]\*\s*?\n?(\n*)?/';
$replace = "\${1}<hr>\${2}";
$parsedstring = preg_replace($match, $replace, $parsedstring);
$match = '/(\n*)?\s*?\-\s?[^\n]\-[^\n]\s?[^\n]\-\s*?\n?(\n*)?/';
$replace = "\${1}<hr>\${2}";
$parsedstring = preg_replace($match, $replace, $parsedstring);
$match = '/(\n*)?\s*?\_\s?[^\n]\_[^\n]\s?[^\n]\_\s*?\n?(\n*)?/';
$replace = "\${1}<hr>\${2}";
$parsedstring = preg_replace($match, $replace, $parsedstring);
/* Specifying punctuation marks isn't optimal but works for most cases. */
$punctmarks = '[.,-_+!?<>\/\\"\'\(\)\[\]\{\}\s\n]';
/* Specifying punctuation marks isn't optimal but works for most cases,
* also, it shoudn't contain certain characters used by markdown itself. */
$punctmarks = '[\.,+!?$&#@|:;<>`\/\\"\'\(\)\[\]\{\}]';
/* NOTE: strong, em, and strikeout can NOT contain line breaks.
* (At least in this simplified version of markdown, anyway.) */
/* Look for strong (before emphasis) */
$match = '/(^|\s|'.$punctmarks.')\*\*(((?!\n).)+?)\*\*(\s|'.$punctmarks.'|$)/';
$match = '/(^|\s|'.$punctmarks.')?\*\*(((?!\n).)+?)\*\*(\s|'.$punctmarks.'|$)?/';
$replace = '${1}<strong>${2}</strong>${4}';
$parsedstring = preg_replace($match, $replace, $parsedstring);
$match = '/(^|\s|'.$punctmarks.')\_\_(((?!\n).)+?)\_\_(\s|'.$punctmarks.'|$)/';
$match = '/(^|\s|'.$punctmarks.')?[^a-zA-Z0-9]\_\_(((?!\n).)+?)\_\_[^a-zA-Z0-9](\s|'.$punctmarks.'|$)?/';
$replace = '${1}<strong>${2}</strong>${4}';
$parsedstring = preg_replace($match, $replace, $parsedstring);
/* Look for emphasis */
$match = '/(^|\s|'.$punctmarks.')\*(((?!\n).)+?)\*(\s|'.$punctmarks.'|$)/';
$match = '/(^|\s|'.$punctmarks.')?\*(((?!\n).)+?)\*(\s|'.$punctmarks.'|$)?/';
$replace = '${1}<em>${2}</em>${4}';
$parsedstring = preg_replace($match, $replace, $parsedstring);
$match = '/(^|\s|'.$punctmarks.')\_(((?!\n).)+?)\_(\s|'.$punctmarks.'|$)/';
$match = '/(^|\s|'.$punctmarks.')?[^a-zA-Z0-9]\_(((?!\n).)+?)\_[^a-zA-Z0-9](\s|'.$punctmarks.'|$)?/';
$replace = '${1}<em>${2}</em>${4}';
$parsedstring = preg_replace($match, $replace, $parsedstring);
/* Look for strike */
$match = '/(^|\s|'.$punctmarks.')\~\~(((?!\n).)+?)\~\~(\s|'.$punctmarks.'|$)/';
$match = '/(^|\s|'.$punctmarks.')?\~\~(((?!\n).)+?)\~\~(\s|'.$punctmarks.'|$)/';
$replace = '${1}<strike>${2}</strike>${4}';
$parsedstring = preg_replace($match, $replace, $parsedstring);
/* Look for inline code */
$match = '/(^|\s|'.$punctmarks.')`(((?!\n).)+?)`(\s|'.$punctmarks.'|$)/';
$match = '/(^|\s|'.$punctmarks.')?`(((?!\n).)+?)`(\s|'.$punctmarks.'|$)/';
$replace = '${1}<code>${2}</code>${4}';
$parsedstring = preg_replace($match, $replace, $parsedstring);
......
This diff is collapsed.
......@@ -272,7 +272,7 @@ div {
}
.popuplist img {
vertical-align:text-bottom;
vertical-align:baseline;
}
.popuplist li {
......@@ -680,6 +680,24 @@ form#signupform input#signupsubmit:focus + #signupsubmithint
to { opacity:0; }
}
/* Sign in form focusing animation */
#userpanel:target {
-webkit-animation:userpanel-background-fade 1.5s ease-in-out;
animation:userpanel-background-fade 1.5s ease-in-out;
}
@-webkit-keyframes userpanel-background-fade {
from { background-color:#fc9; }
to { background-color:#ded; }
}
@keyframes userpanel-background-fade {
0% { background-color:#ded; }
50% { background-color:#fc9; }
100% { background-color:#ded; }
}
/* Sign up form focusing animation */
#rightpanel:target {
-webkit-animation:rightpanel-background-fade 3.0s ease-in-out;
animation:rightpanel-background-fade 3.0s ease-in-out;
......@@ -1893,6 +1911,7 @@ span#popupeditorpermissions:hover > #popupeditorpermissionspopup {
.memberlinktitle {
background:none;
color:inherit;
}
.memberlinkdetails {
......@@ -2207,6 +2226,30 @@ span#popupeditorpermissions:hover > #popupeditorpermissionspopup {
position:relative;
}
.fadetext {
color:#9ac;
}
a.fadetext,
.fadetext > a {
color:#9ac;
text-decoration:none;
}
a.fadetext:hover,
.fadetext > a:hover {
color:#396;
}
a.ctalink {
text-decoration:none;
border-bottom:dotted 1px #ace;
}
.bottomdash {
border-bottom:dashed 1px #9ac;
}
.tooltiptext {
position:absolute;
display:none;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment