Skip to content

Commit

Permalink
Improved parsing of lists, distinguishing between ol and ul
Browse files Browse the repository at this point in the history
  • Loading branch information
turnermm committed Sep 19, 2018
1 parent 5ee8cd2 commit 9e37378
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 185 deletions.
1 change: 1 addition & 0 deletions ckeditor/plugins/msword/dialogs/msword-cmpr.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

181 changes: 1 addition & 180 deletions ckeditor/plugins/msword/dialogs/msword.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions ckeditor/plugins/msword/dialogs/msword.js.unc
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,25 @@ CKEDITOR.dialog.add( 'mswordDialog', function( editor ) {
m = m.replace(/<\/p>/mg,"");
return m.replace(/<p.*?>/mg,"");
});
// alert(inner);

inner = inner.replace(/<p class="MsoListParagraphCxSpFirst"\s+L_\d>([\s\S]+)<p class="MsoListParagraphCxSpLast"\s+L_\d>.*?\n(.*?)\/p>/gm, function(m,w){
var n = m;
n = n.replace(/&nbsp;/gm,"");
n = n.replace(/>[1-5a-f]./gm,'>');
var ar = n.split(/\n/);
var str = "";

var list_type = "ul";
for(j=0;j<ar.length;j++) {
if(ar[j].match(/SpFirst/)) {
if(ar[j]. match(/L_\d+>[a-b0-9]/)) {
list_type = 'ol';
}
// alert(list_type);
ar[j] = ar[j].replace(/<p.*?>/,"");
ar[j] = ar[j].replace(/<\/p>/,"");

ar[j] = ar[j].replace(/<p.*?>(\d*|·)/,"");
str += "<ol><li>" +ar[j] + '</li>';
// alert(ar[j]);
str += "<" + list_type +">";
}
else if (ar[j].match(/SpMiddle/)) {
ar[j] = ar[j].replace(/<p.*?>/,"");
Expand All @@ -170,7 +174,8 @@ CKEDITOR.dialog.add( 'mswordDialog', function( editor ) {
}
}
str = str.replace(/<li>·*<\/li>/gm,"");
str+="</ol>";
str+="</" + list_type +">";
// alert(str);
return str;
} );
editor.insertHtml(inner);
Expand Down

0 comments on commit 9e37378

Please sign in to comment.