My person did not experiment much till now (thought of how would it insert copied text including zwsp) but came across that when copy form one editor window to another it seems that it suppresses line breaks (better replace with a white space).
Copy:
(https://forum.sangham.net/index.php?action=dlattach;topic=9136.0;attach=7471;image)
past:
(https://forum.sangham.net/index.php?action=dlattach;topic=9136.0;attach=7473;image)
Copy it here, it seems to come from the source and does not happen in the moment of past:
==== 1. Kimilasuttaṃ ==== <span sang_id #{file-}.{no}>[[{path-release}:{file-}.{no}|{file-}.{no}]] | [[{path-source}:{file}#{file-}.{no}|source]]</span>
Sadhu
The first test showed that text copied into the editor would be rendered in regard of certain html characters and what ever content is in the editor, can not be copied anywhere else.
http://accesstoinsight.eu/user/johann/test
(https://forum.sangham.net/index.php?action=dlattach;topic=9136.0;attach=7476;image)
The second test, after having called the posted links, shows that the renderings of special characters also become part of the displayed text.
http://accesstoinsight.eu/user/johann/test1
(https://forum.sangham.net/index.php?action=dlattach;topic=9136.0;attach=7478;image)
Atma is a little bit "scared" to open any page for now. Which seems to be good, since it obviously converts the text, having downloaded the file after saving:
==== សុន្ទរសមុទ្ទត្ថេរ ====
<span sang_id #sut.kn.tha.07.01>[[km:tipitaka:sut:kn:tha:sut.kn.tha.07.01|sut.kn.tha.07.01]] | [[km:tipitaka:book_057#sut.kn.tha.07.01|book_057]]</span>
<div centeralign>**(១. សុន្ទរសមុទ្ទត្ថេរគាថា)**</div>
<span para #para_225>[២២៥]</span> ស្រីផ្កាមាសតាក់តែង ស្លៀកពាក់ល្អ ទ្រទ្រង់កម្រងផ្កា ស្អិតស្អាងហើយ មានជើងស្រឡាបដោយទឹកល័ខ ពាក់ស្បែកជើង លុះដោះស្បែកជើងចេញហើយ ក៏ធ្វើអញ្ជលីចំពោះមុខ ស្រីផ្កាមាសនោះ និយាយនូវពាក្យជាប្រធាននៃមិត្ត((ពាក្យចែចង់។)) នឹងខ្ញុំ ដោយសំដីដ៏ទន់ពីរោះថា លោកនៅកំឡោះហើយបួស លោកចូរឋិតនៅក្នុងពាក្យប្រដៅរបស់ខ្ញុំ លោកចូរបរិភោគកាមជារបស់មនុស្សចុះ ខ្ញុំនឹងឲ្យសម្បត្តិដ៏ពេញចិត្តដល់លោក។ ខ្ញុំបេ្តជ្ញាពាក្យពិតដល់លោក ឬនឹងនាំភ្លើងដល់លោក។((ស្បថនឹងភ្លើង)) កាលណាយើងទាំងពីរនាក់ ជាមនុស្សចាស់កាន់ឈើច្រត់ហើយ យើងនឹងបួសទាំងពីរនាក់ នឹងកាន់យកនូវជ័យជំនះក្នុងលោកទាំងពីរ។ ខ្ញុំបានឃើញស្រីផ្កាមាសនោះ មកធ្វើអញ្ជលី តាក់តែង ស្លៀកពាក់ល្អ ដូចជាជាប់អន្ទាក់មច្ចុ លំដាប់នុ៎ះ ខ្ញុំក៏បានធ្វើទុកក្នុងចិត្តដោយឧបាយនៃបញ្ញា។បេ។((គប្បីមើលក្នុងចតុក្កនិបាត។))
<div rightalign>សុន្ទរសមុទ្ទត្ថេរ។</div>
==== លកុណ្តកត្ថេរ ====
<span sang_id #sut.kn.tha.07.02>[[km:tipitaka:sut:kn:tha:sut.kn.tha.07.02|sut.kn.tha.07.02]] | [[km:tipitaka:book_057#sut.kn.tha.07.02|book_057]]</span>
It also seems to convert into CRLF line breaks.
Don't open any page in the editor and save the content for now!
It seems that the script also adds zwsp next to the html-value of certain characters.
(https://forum.sangham.net/index.php?action=dlattach;topic=9136.0;attach=7480;image)
If having less time and much in hurry, maybe it's good and possible to disable the modification meanwhile.
I think the best solution might be to simply use the already existing and previously mentioned (http://forum.sangham.net/index.php/topic,9136.msg18505.html#msg18505) CodeMirror plugin (https://www.dokuwiki.org/plugin:codemirror).
It has all the desired features for the editor, including display of ZWS, whitespace and line breaks, possible to turn on and off. I had previously not tested it and thought that ZWS display would not be included. But it is, and it all seems to be working perfectly.
ZWS is always displayed as red dots, taking up one space, and not possible to turn off. Perhaps I can find a way to toggle them on/off as well.
The only additional thing remaining from my plugin attempt would then be the display of ZWS on the revision comparison page.
For now, I have disabled the ZWS plugin and installed CodeMirror instead.
For the ZWS display in the comparison page to work properly (without inserting additional ZWS between tags etc.), it would be necessary to change something in the DokuWiki code directly, which is not possible with a plugin.
And the little bit of JavaScript and CSS can be included in conf/userall.css and conf/userscript.js, so no real plugin needed anymore for that.
Edit: Comparison page should be working now, only showing the ZWS where they really are. All necessary for that is in conf/userall.css (marked with comment), conf/userscript.js and line 1366 of inc/html.php, which was changed from
echo html_insert_softbreaks($diffformatter->format($diff)); ?>
to
echo html_insert_softbreaks(str_replace("\u{200B}", "\u{E000}", $diffformatter->format($diff))); ?>
_/\_
Ah, I see. That must be because of using different fonts.
On my system, CodeMirror was using the default monospace font for the text area, while on the pictures shown above, a different (non-monospace) font is used (which is probably not installed on my system, and therefore the monospace font used instead).
I have inserted the ZWS marker as a simple '|' symbol, shifted slightly to the left, and overlayed, so not taking up any space of the actual text behind. The positioning would be different for different fonts. I chose -0.25rem (rem is a unit of text size in CSS, 1rem = current line height or something), which should be more or less correct for most monospace fonts.
I think between non-monospace fonts, there may be more differences, so it might not be possible to find a left shift value that works perfectly for every font.
For now, I have changed the CSS to use the borrowed "Moul Pali" font in the editor, and set the zws left shift to -0.125rem, which seems to fit well together. But I am not sure if Moul Pali is really a good font choice.
Since the Moul Pali font was actually not really used before, the Khmer texts seen on accesstoinsight.eu were always in some "default" fonts. So it seems there should not be a necessity to specifically include a font to support Khmer script. Khmer script seems to be included in most or many "standard" fonts nowadays, and browsers would automatically choose a font where the Khmer character is defined in most normal cases (if not explicitly setting a CSS rule to use _only_ one specific font, without default "fallback", which has no Khmer characters).
I also changed references to "Moul Pali" in conf/userall.css, because they were all written wrong. (Need to be put into quotes, because of space in the name.) So "Moul Pali" was probably actually never used before.
Not sure where the following CSS rules are now visibly applied. Maybe Bhante might check if they are actually looking as intended:
/*pali khmer font span*/
@font-face { font-family: "Moul Pali"; src: url('Moul Pali.ttf'); }
.dokuwiki div.wrap_pali_km {
font-family:"Moul Pali", sans-serif;
font-size:80%;
}
.dokuwiki span.wrap_pali_km {
font-family:"Moul Pali", sans-serif;
font-size:80%;
}
/* ... */
.dokuwiki div.wrap_cs-km { font-family:"Moul Pali", sans-serif !important;
}
I set ", sans-serif" everywhere behind as a "fallback" (although Moul Pali is more of a Serif font) in all those cases where using "Moul Pali" as font. This means that if a character is not defined in Moul Pali, it will use the standard of the "sans-serif" family instead. This is how it generally works in CSS: if a symbol is not found, the browser will look in the next font of the list, and in general it would always fall back on one of the three "standard font families": monospace, serif or sans-serif. Normally, Moul Pali would fall back on "serif" for non-Khmer symbols, using whatever is the standard serif font on the system. But sans-serif seems generally better to read and fitting with the general DokuWiki style.
Maybe it would be better to not use "Moul Pali", because it is more like a Serif font, and some things can look a bit strange (see screenshot (http://forum.sangham.net/index.php?action=dlattach;topic=9136.0;attach=7494;image)).
(https://forum.sangham.net/index.php?action=dlattach;topic=9136.0;attach=7494;image)
I think it might be best to use the standard font that is used on DokuWiki pages, which is "Arial, sans-serif" (i.e. using Windows "Arial" font if it is available, or otherwise whatever standard "sans-serif" is installed on the system).
For now, the editor font is set as "Moul Pali, sans-serif". But there is also a button now to choose a different font (need to enter a correct font name that is recognized on the system), so one can try out different fonts if one knows some font names (however it is probably best for compatibility on different systems to rely mostly on just the standard font-families "serif, sans-serif and monospace", if not having font files available to share).
The "insert ZWS" button is also included again:
(https://forum.sangham.net/index.php?action=dlattach;topic=9136.0;attach=7496;image)
[small]("insert ZWS" and "choose editor font" buttons)[/small]
Adding tab arrows is surely possible, but maybe difficult to implement well with non-monospace fonts and might need some time.
Ah, and I recognized the use of different "themes" in CodeMirror that one can choose. So I thought it is best to use one of the theme colors also for zero-whitespace (instead of a fixed color, that might not fit well with some themes).
The color themes of CodeMirror have a number of CSS classes for certain elements in the text, for example:
span.cm-keyword, span.cm-atom, span.cm-number, span.cm-def, span.cm-variable, span.cm-variable-2, ..., span.cm-operator, span.cm-property, span.cm-comment, ..., which have different colors for different themes and are used differently for whatever kind of "programming language" CodeMirror is set to use. (DokuWiki markup has its own CodeMirror definitions in the plugin).
For now, I chose the CSS class cm-comment for the ZWS markers. I think the color is good for most themes. But feedback is welcome. One could try different things.
_/\_