Skip to content
Permalink
Browse files

Additional fix (since #468, #462) for removing extra line breaks from… (

#480)

* Additional fix (since #468, #462) for removing extra line breaks from code blocks.

* protect backslashes in Windows path names

* further fixes for tbl/code block double backslash

* compressed parse_wiki.js.unc

* Permanent name for dbl back-slash in code blocks: CODE_BLOCK_EOL_MASK

* removed backslash protection from table:codeblock to all codeblocks; required on testing
  • Loading branch information...
turnermm committed May 31, 2019
1 parent 43d9a02 commit 848e2f9d581d2e75546884afe36986b65103e42f
Showing with 18 additions and 7 deletions.
  1. +4 −2 action/edit.php
  2. +8 −1 action/save.php
  3. +1 −1 scripts/parse_wiki-cmpr.js
  4. +5 −3 scripts/parse_wiki.js.unc
@@ -314,6 +314,7 @@ function($matches) {
$matches[4] = preg_replace("/(?<!\s)>/ms", $close, $matches[4]);
}
$matches[4] = str_replace("\"", "__GESHI_QUOT__", $matches[4]);
$matches[4] = preg_replace("/\\\\\\(\n|\s)/ms","CODE_BLOCK_EOL_MASK$1",$matches[4]);
return "<" . $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];'
),
$text
@@ -1074,7 +1075,7 @@ function _render_xhtml($text){
if(strpos($text,'~~NO_STYLING~~') !== false) {
$skip_styling = true;
}
// $text = preg_replace("/\\\\(\n|\s)/ms","CODE_BLOCK_EOL_MASK$1",$text);
$text = preg_replace_callback('/\[\[(.*?>)(.*?)\]\]/ms',
function ($matches) {
if(strpos($matches[0],"\n") !== false) return $matches[0];
@@ -1160,7 +1161,8 @@ function ($matches) {
$matches[2] = str_replace("font&gt;","ckgeditFONTClose",$matches[2]);
return $matches[1] .$matches[2] . $matches[3]; '
), $text);
$text = str_replace('CODE_BLOCK_EOL_MASK','\\', $text);
/// msg($text);
$instructions = p_get_instructions("=== header ==="); // loads DOKU_PLUGINS array --M.T. Dec 22 2009
$instructions = p_get_instructions($text);
@@ -312,6 +312,7 @@ function($matches) {
$TEXT = preg_replace_callback(
'#\|[\s\n]+(\<file.*?\>)(.*?)(\<\/file>\s*.*?)\n?\|#ms',
function($matches) {
//$ret = '</' . $matches[1] . '>' . str_replace('\\',"",$matches[2]) . '|';
$matches[3] = preg_replace('/\n+/',"",$matches[3] );
$matches[3] = preg_replace('/\s+$/',"",$matches[3] ) . '|';
return '|' . $matches[1] . $matches[2] . str_replace("\\ ","",$matches[3]);
@@ -332,10 +333,16 @@ function($matches) {
$TEXT = preg_replace_callback(
'#\<\/(code|file)\>([\s\S]+)\|#ms',
function($matches) {
$ret = '</' . $matches[1] . '>' . str_replace('\\',"",$matches[2]) . '|';
$matches[2] = str_replace(':\\', '~~WIN__DIR~~',$matches[2]);
$matches[2] = preg_replace('#([\w;.:=\:])\\\\#ms', "$1_bSL_",$matches[2]); //protect backslashes in Windows paths
$ret = '</' . $matches[1] . '>' . str_replace("\\","",$matches[2]) . '|';
$ret = str_replace( '_bSL_', '\\',$ret);
$ret = str_replace( '~~WIN__DIR~~', ':\\',$ret);
return $ret;
},$TEXT
);
$TEXT = str_replace('CBL__Bksl','\\',$TEXT);
$TEXT = preg_replace("/<code\s+file/ms",'<code ',$TEXT);
return;

Large diffs are not rendered by default.

@@ -1148,7 +1148,7 @@ function parse_wikitext(id) {
if(!this.attr) this.attr = 'code';
results += this.attr + '>';
this.downloadable_file = "";
this.downloadable_code = false;
this.downloadable_code = false;
}

} // if markup tag
@@ -1287,7 +1287,7 @@ function parse_wikitext(id) {
}
else if(tag == 'pre') {
tag = markup_end[tag];
if(this.code_type) {
if(this.code_type) {
tag += this.code_type + ">";
}
else {
@@ -1403,7 +1403,9 @@ function parse_wikitext(id) {

chars: function( text ) {
text = text.replace(/\t/g," ");

if(this.code_type == 'code'){
text = text.replace(/(\n?|\s+)\\/gm,"$1CBL__Bksl");
}
if(text.match(/~~START_HTML_BLOCK~~/)) {
text = text.replace(/~~START_HTML_BLOCK~~\n*/, "~~START_HTML_BLOCK~~\n<code>\n");
}

0 comments on commit 848e2f9

Please sign in to comment.
You can’t perform that action at this time.