diff --git a/inc/functions.php b/inc/functions.php
index a6677d3a..b2d01da4 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -2266,8 +2266,27 @@ function markup(&$body, $track_cites = false, $op = false) {
if ($config['strip_superfluous_returns'])
$body = preg_replace('/\s+$/', '', $body);
-
- $body = preg_replace("/\n/", '
', $body);
+
+ if ($config['markup_paragraphs']) {
+ $paragraphs = explode("\n", $body);
+ $bodyNew = "";
+
+ foreach ($paragraphs as $paragraph) {
+ if (strlen(trim($paragraph)) > 0) {
+ $paragraphDirection = is_rtl($paragraph) ? "rtl" : "ltr";
+ }
+ else {
+ $paragraphDirection = "empty";
+ }
+
+ $bodyNew .= "
" . $paragraph . "
";
+ }
+
+ $body = $bodyNew;
+ }
+ else {
+ $body = preg_replace("/\n/", '
', $body);
+ }
if ($config['markup_repair_tidy']) {
$tidy = new tidy();
@@ -2324,6 +2343,40 @@ function ordutf8($string, &$offset) {
return $code;
}
+function uniord($u) {
+ $k = mb_convert_encoding($u, 'UCS-2LE', 'UTF-8');
+ $k1 = ord(substr($k, 0, 1));
+ $k2 = ord(substr($k, 1, 1));
+ return $k2 * 256 + $k1;
+}
+
+function is_rtl($str) {
+ if(mb_detect_encoding($str) !== 'UTF-8') {
+ $str = mb_convert_encoding($str, mb_detect_encoding($str),'UTF-8');
+ }
+
+ preg_match_all('/[^\n\s]+/', $str, $matches);
+ preg_match_all('/.|\n\s/u', $str, $matches);
+ $chars = $matches[0];
+ $arabic_count = 0;
+ $latin_count = 0;
+ $total_count = 0;
+
+ foreach ($chars as $char) {
+ $pos = uniord($char);
+
+ if ($pos >= 1536 && $pos <= 1791) {
+ $arabic_count++;
+ }
+ else if ($pos > 123 && $pos < 123) {
+ $latin_count++;
+ }
+ $total_count++;
+ }
+
+ return (($arabic_count/$total_count) > 0.5);
+}
+
function strip_combining_chars($str) {
$chars = preg_split('//u', $str, -1, PREG_SPLIT_NO_EMPTY);
$str = '';
diff --git a/inc/instance-config.php b/inc/instance-config.php
index 56783e33..46478d20 100644
--- a/inc/instance-config.php
+++ b/inc/instance-config.php
@@ -140,6 +140,7 @@
$config['additional_javascript'][] = 'js/auto-scroll.js';
$config['additional_javascript'][] = 'js/twemoji/twemoji.js';
$config['additional_javascript'][] = 'js/file-selector.js';
+ $config['additional_javascript'][] = 'js/board-directory.js';
// Oekaki (now depends on config.oekaki so can be in all scripts)
$config['additional_javascript'][] = 'js/jquery-ui.custom.min.js';
$config['additional_javascript'][] = 'js/wPaint/8ch.js';
@@ -160,6 +161,9 @@
$config['markup'][] = array("/__(.+?)__/", "\$1");
$config['markup'][] = array("/###([^\s']+)###/", "###\$1###");
+ $config['markup_paragraphs'] = true;
+ $config['markup_rtl'] = true;
+
$config['boards'] = array(array('' => '/', '' => '/boards.html', '' => '/faq.html', '' => '/random.php', '' => '/create.php', '' => '/bans.html', '' => '/search.php', '' => '/mod.php', '' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'news+', 'boards'), array('operate', 'meta'), array(''=>'https://twitter.com/infinitechan'));
//$config['boards'] = array(array('' => '/', '' => '/boards.html', '' => '/faq.html', '' => '/random.php', '' => '/create.php', '' => '/search.php', '' => '/mod.php', '' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'meta', 'int'), array('v', 'a', 'tg', 'fit', 'pol', 'tech', 'mu', 'co', 'sp', 'boards'), array(''=>'https://twitter.com/infinitechan'));
diff --git a/post.php b/post.php
index 38898e11..ce6a5f47 100644
--- a/post.php
+++ b/post.php
@@ -643,7 +643,8 @@ elseif (isset($_POST['post'])) {
if (mysql_version() >= 50503) {
$post['body_nomarkup'] = $post['body']; // Assume we're using the utf8mb4 charset
- } else {
+ }
+ else {
// MySQL's `utf8` charset only supports up to 3-byte symbols
// Remove anything >= 0x010000
diff --git a/stylesheets/style.css b/stylesheets/style.css
index 372bdd74..61678115 100644
--- a/stylesheets/style.css
+++ b/stylesheets/style.css
@@ -368,7 +368,12 @@ div.delete {
}
div.post.reply p {
- margin: 0.3em 0 0 0;
+ display: block;
+ margin: 0;
+
+ line-height: 1.16em;
+ font-size: 13px;
+ min-height: 1.16em;
}
div.post.reply div.body {
@@ -1070,6 +1075,14 @@ span.pln {
min-width: 48px;
}
+/* Text and accessibility */
+.ltr {
+ direction: ltr;
+}
+.rtl {
+ direction: rtl;
+ font-family: Tahoma;
+}
/* Responsive helpers */
.col {