Compatible with habrareaction for MODx Evo
In the process of moving my articles with Habr or sites on LiveStreet I stalknulsya with the problem of layout.
Editor Habra takes breaks in the source text as hyphens, i.e., in HTML they look like
And all available editors for modx in edit mode not accepting links and images and text will look like in the editor:
the
And if you paste text in edit mode — it will turn into text without hyphenation:
the
Which is also inconvenient. No, you could certainly configure a replacement in any text editor — /n on br, but the problem is that then we get two different versions of the text that will cause problems with editing. Had to order the freelance bike.
Plugin to automatically replace /n to br when you save the text and return the replacement when editing:
the
The installation of conventional — Control elements — plug — ins- create plug-in.
Copy the code in the box, then go to the tab system events and celebrating OnBeforeDocFormSave and OnDocFormPrerender — start when opening and saving the document.
Article based on information from habrahabr.ru
Editor Habra takes breaks in the source text as hyphens, i.e., in HTML they look like
<br>
And all available editors for modx in edit mode not accepting links and images and text will look like in the editor:
the
Under the cut you will find: macro photography screen, disassembly, battery test, camera, experience.
<a href="https://picasaweb.google.com/lh/photo/DWXbDrGSQrrqY2TJM_UhydMTjNZETYmyPJy0liipFm0?feat=embedwebsite"><img src="https://lh6.googleusercontent.com/-vrs2uZgIzqQ/UJPFgBkWr-I/AAAAAAAAKxg/FS0DcyCkW0w/s640/Samsung%2520Note%2520II-001.jpg" height="107" width="640" /></a>
<habrаcut text="you Have exactly half an hour to read?" />
<ul>
<li><a href="#pack">the specs</a></li>
<li><a href="#view">build Quality and appearance</a></li>
<li><a href="#screen">Screen</a></li>
<li><a href="#inside" > Inside, fashion and maintainability</a></li>
And if you paste text in edit mode — it will turn into text without hyphenation:
the
at First I wanted to make their watches, going in the opposite direction, but wrong in the delay and got the sound "ZZ-ZZ-ZZ-ZZZZZ", which I thought was interesting.Next was the weekend and leisurely picking the code underwent several changes, was lost and rewritten for MSP430 and Wiring is BASCOM(because I was lazy to dial the program a second time than to write it in another language), and in the end took the following form:CAUTION! Bydlokod!<source lang="cpp">
#include <Servo.h> //Connected бибилотекуServo myservo1;//Define именаServo myservo2; int x = 0; //Different peremennye int y = 0; int z = 0; int w = 0; int g = 0; int h = 0; int q = 0;
Which is also inconvenient. No, you could certainly configure a replacement in any text editor — /n on br, but the problem is that then we get two different versions of the text that will cause problems with editing. Had
Plugin to automatically replace /n to br when you save the text and return the replacement when editing:
the
global $content;
$e = &$modx- > Event;
switch ($e->name) {
case "OnDocFormPrerender":
$content["content"]=trim(preg_replace("/\<br\>/i","\r\n",$content["content"])); //Replace when you open the text transfers
break;
case "OnBeforeDocFormSave":
$content=preg_replace ("/(\\\\ r\\\\n)/","<br>",$content); //Replace while maintaining
$content=preg_replace ("/(\\\\ n)/","<br>",$content);
$content=preg_replace ("/(\\\\ r)/","<br>",$content); //Compatibility for different systems
$content=preg_replace("/\<\/li\>\s*(\<br\>)+\s*\<li/i","</li>\\\\r\\\\n<li",$content);
$content=preg_replace("/\<ul\>\s*(\<br\>)+\s*\<li/i","<ul>\\\\r\\\\n<li",$content);
$content=preg_replace("/\<\/li\>\s*(\<br\>)+\s*\<\/ul/i","</li>\\\\r\\\\n</ul",$content);
$content=preg_replace("/\s*(\<br\>)+\s*\<ul/i","\\\\ r\\\\n<ul",$content);
$content=preg_replace("/\<\/ul\>\s*(\<br\>)+\s*/i","</ul>\\\\ r\\\\n",$content);//Eliminate double shift in numbered lists
break;
default :
return;
break;
}
The installation of conventional — Control elements — plug — ins- create plug-in.
Copy the code in the box, then go to the tab system events and celebrating OnBeforeDocFormSave and OnDocFormPrerender — start when opening and saving the document.
Comments
Post a Comment