<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: API Типографа Лебедева]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12276&amp;type=atom" />
	<updated>2017-01-04T06:14:26Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12276</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110491#p110491" />
			<content type="html"><![CDATA[<p>Здорово, спасибо большое.</p><p>Подскажите еще, как настройки типографа передавать в xml-запросе? Например, чтобы на выходе готовый текст получался, а не буквенные коды.</p><p><a href="http://www.artlebedev.ru/tools/typograf/preferences/">http://www.artlebedev.ru/tools/typograf/preferences/</a></p><p>Я пока разобрался только как &lt;p&gt;&lt;/p&gt; и &lt;br&gt; делать.</p><p>UPD: уже разобрался. Спасибо еще раз.</p>]]></content>
			<author>
				<name><![CDATA[Gif]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34431</uri>
			</author>
			<updated>2017-01-04T06:14:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110491#p110491</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110489#p110489" />
			<content type="html"><![CDATA[<p>Вот так, как на сайте:<br /></p><div class="codebox"><pre><code>text1 := &quot;&lt;&gt;&quot;
text2 =
(
&lt;ProcessTextResult&gt;
— Это &quot;Типограф&quot;?
&lt;ProcessTextResult&gt;
— Нет, это «Типограф»!
)
Typograf := new Typograf
MsgBox, % Typograf.Process(text1)
MsgBox, % Typograf.Process(text2)
MsgBox, % Typograf.Process(text2, true)  ; с переносом строк

class Typograf  {
   __New()  {
      this.xmlhttp := ComObjCreate(&quot;Msxml2.XMLHTTP&quot;)
      this.WaitForResponse := ObjBindMethod(this, &quot;Ready&quot;)
   }
   
   Process(text, useBr := false)  {
      text := this.Replace(text)
      xmlRequest := &quot;&lt;?xml version=&quot;&quot;1.0&quot;&quot; encoding=&quot;&quot;UTF-8&quot;&quot;?&gt;&quot;
                  . &quot;&lt;soap:Envelope xmlns:xsi=&quot;&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&quot;&quot;
                  . &quot; xmlns:xsd=&quot;&quot;http://www.w3.org/2001/XMLSchema&quot;&quot;&quot;
                  . &quot; xmlns:soap=&quot;&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&quot;&gt;&quot;
                  . &quot;&lt;soap:Body&gt;&quot;
                  . &quot;&lt;ProcessText xmlns=&quot;&quot;http://typograf.artlebedev.ru/webservices/&quot;&quot;&gt;&quot;
                  . &quot;&lt;text&gt;&quot; . text . &quot;&lt;/text&gt;&quot;
                  . &quot;&lt;useP&gt;0&lt;/useP&gt;&quot;
                  . &quot;&lt;useBr&gt;&quot; . useBr . &quot;&lt;/useBr&gt;&quot;
                  . &quot;&lt;/ProcessText&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;&quot;
                  
      url := &quot;http://typograf.artlebedev.ru/webservices/typograf.asmx&quot;
      this.xmlhttp.Open(&quot;POST&quot;, url, true)
      this.xmlhttp.onreadystatechange := this.WaitForResponse
      this.xmlhttp.setRequestHeader(&quot;Content-Type&quot;, &quot;text/xml&quot;)
      this.xmlhttp.Send(xmlRequest)
      while this.result = &quot;&quot;
         Sleep, 200
      res := RegExReplace(this.result, &quot;s).*&lt;ProcessTextResult&gt;(.*)&lt;/ProcessTextResult&gt;.*&quot;, &quot;$1&quot;)
      this.result := &quot;&quot;
      Return this.Replace(res, false)
   }
   
   Ready()  {
      if this.xmlhttp.readyState != 4
         Return
      this.result := this.xmlhttp.ResponseText
   }
   
   Replace(text, direction := true)  {
      for k, v in direction ? [[&quot;&amp;&quot;, &quot;&amp;amp;&quot;], [&quot;&lt;&quot;, &quot;&amp;lt;&quot;], [&quot;&gt;&quot;, &quot;&amp;gt;&quot;]] : [[&quot;&amp;lt;&quot;, &quot;&lt;&quot;], [&quot;&amp;gt;&quot;, &quot;&gt;&quot;], [&quot;&amp;amp;&quot;, &quot;&amp;&quot;]]
         text := StrReplace(text, v[1], v[2])
      Return text
   }
}</code></pre></div><p>Только, если как в примере, тогда то, что в тегах (в угловых скобках), вообще удалится:<br /></p><div class="codebox"><pre><code>text = text.replace (/&lt;[^&gt;]+&gt;/g, &#039;&#039;);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-04T01:44:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110489#p110489</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110488#p110488" />
			<content type="html"><![CDATA[<p>Ну если посмотреть исходник примера, то там идет так:<br /></p><div class="codebox"><pre><code>function remoteTypograf (text)
{
text = text.replace (/&lt;[^&gt;]+&gt;/g, &#039;&#039;);
text = text.replace (/&amp;/g, &#039;&amp;amp;&#039;);
text = text.replace (/&lt;/g, &#039;&amp;lt;&#039;);
text = text.replace (/&gt;/g, &#039;&amp;gt;&#039;);</code></pre></div><div class="codebox"><pre><code>function parseTypografAnswer()
{
var response = xmlSocket.responseText;
var re = /&lt;ProcessTextResult&gt;\s*((.|\n)*?)\s*&lt;\/ProcessTextResult&gt;/m;
response = re.exec (response);
response = RegExp.$1;
response = response.replace (/&amp;gt;/g, &#039;&gt;&#039;);
response = response.replace (/&amp;lt;/g, &#039;&lt;&#039;);
response = response.replace (/&amp;amp;/g, &#039;&amp;&#039;);</code></pre></div><p><a href="http://www.artlebedev.ru/tools/technogrette/js/remotetypograf/example.html">http://www.artlebedev.ru/tools/technogr … ample.html</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-01-04T01:04:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110488#p110488</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110487#p110487" />
			<content type="html"><![CDATA[<p>Хотя не уверен, надо подумать про последовательность замен.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-04T00:59:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110487#p110487</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110486#p110486" />
			<content type="html"><![CDATA[<p>Ну в этом случае на сайте ошибка. Угловые скобки должны быть заменены.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-04T00:53:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110486#p110486</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110485#p110485" />
			<content type="html"><![CDATA[<p>Результат по сравнению с сайтом разный:<br /></p><div class="codebox"><pre><code>text2 =
(
&lt;ProcessTextResult&gt;
— Это &quot;Типограф&quot;?
&lt;ProcessTextResult&gt;
— Нет, это «Типограф»!
)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-01-04T00:49:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110485#p110485</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110484#p110484" />
			<content type="html"><![CDATA[<p>2) Точно, но достаточно просто перенести замену [&quot;&amp;&quot;, &quot;&amp;amp;&quot;] на последнее место.<br />1) Согласен, но не в этом дело, нужно просто поменять местами замену спецсимволов и поиск тега.<br /></p><div class="codebox"><pre><code>text1 := &quot;&lt;&gt;&quot;
text2 =
(
&lt;ProcessTextResult&gt;
— Это &quot;Типограф&quot;?
&lt;ProcessTextResult&gt;
— Нет, это «Типограф»!
)
Typograf := new Typograf
MsgBox, % Typograf.Process(text1)
MsgBox, % Typograf.Process(text2)
MsgBox, % Typograf.Process(text2, true)  ; с переносом строк

class Typograf  {
   __New()  {
      this.xmlhttp := ComObjCreate(&quot;Msxml2.XMLHTTP&quot;)
      this.WaitForResponse := ObjBindMethod(this, &quot;Ready&quot;)
   }
   
   Process(text, useBr := false)  {
      text := this.Replace(text)
      xmlRequest := &quot;&lt;?xml version=&quot;&quot;1.0&quot;&quot; encoding=&quot;&quot;UTF-8&quot;&quot;?&gt;&quot;
                  . &quot;&lt;soap:Envelope xmlns:xsi=&quot;&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&quot;&quot;
                  . &quot; xmlns:xsd=&quot;&quot;http://www.w3.org/2001/XMLSchema&quot;&quot;&quot;
                  . &quot; xmlns:soap=&quot;&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&quot;&gt;&quot;
                  . &quot;&lt;soap:Body&gt;&quot;
                  . &quot;&lt;ProcessText xmlns=&quot;&quot;http://typograf.artlebedev.ru/webservices/&quot;&quot;&gt;&quot;
                  . &quot;&lt;text&gt;&quot; . text . &quot;&lt;/text&gt;&quot;
                  . &quot;&lt;useP&gt;0&lt;/useP&gt;&quot;
                  . &quot;&lt;useBr&gt;&quot; . useBr . &quot;&lt;/useBr&gt;&quot;
                  . &quot;&lt;/ProcessText&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;&quot;
                  
      url := &quot;http://typograf.artlebedev.ru/webservices/typograf.asmx&quot;
      this.xmlhttp.Open(&quot;POST&quot;, url, true)
      this.xmlhttp.onreadystatechange := this.WaitForResponse
      this.xmlhttp.setRequestHeader(&quot;Content-Type&quot;, &quot;text/xml&quot;)
      this.xmlhttp.Send(xmlRequest)
      while this.result = &quot;&quot;
         Sleep, 200
      res := RegExReplace(this.result, &quot;s).*&lt;ProcessTextResult&gt;(.*)&lt;/ProcessTextResult&gt;.*&quot;, &quot;$1&quot;)
      this.result := &quot;&quot;
      Return this.Replace(res, false)
   }
   
   Ready()  {
      if this.xmlhttp.readyState != 4
         Return
      this.result := this.xmlhttp.ResponseText
   }
   
   Replace(text, direction := true)  {
      for k, v in [ [&quot;&lt;&quot;, &quot;&amp;lt;&quot;], [&quot;&gt;&quot;, &quot;&amp;gt;&quot;], [&quot;&amp;&quot;, &quot;&amp;amp;&quot;] ]
         text := StrReplace(text, direction ? v[1] : v[2], direction ? v[2] : v[1])
      Return text
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-04T00:43:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110484#p110484</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110483#p110483" />
			<content type="html"><![CDATA[<p>1) Имеет. У тебя часть текста может съесться:<br /></p><div class="codebox"><pre><code>text1 =
(
&lt;ProcessTextResult&gt;
— Это &quot;Типограф&quot;?
&lt;ProcessTextResult&gt;
— Нет, это «Типограф»!
)</code></pre></div><p>2) Разница в результате оттипографивания если делать это через сайт:<br /></p><div class="codebox"><pre><code>text1 =
(
&lt;&gt;
)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-01-04T00:29:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110483#p110483</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110481#p110481" />
			<content type="html"><![CDATA[<p>1) — не имеет смысла, в ответе только один такой тег.<br />2) — а какая разница?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-04T00:22:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110481#p110481</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110480#p110480" />
			<content type="html"><![CDATA[<p>Нашел 2 ошибки:<br />1) Это:<br /></p><div class="codebox"><pre><code>Return RegExReplace(res, &quot;s).*&lt;ProcessTextResult&gt;(.*)&lt;/ProcessTextResult&gt;.*&quot;, &quot;$1&quot;)</code></pre></div><p>Надо исправить на это:<br /></p><div class="codebox"><pre><code>Return RegExReplace(res, &quot;s).*?&lt;ProcessTextResult&gt;(.*)&lt;/ProcessTextResult&gt;.*&quot;, &quot;$1&quot;)</code></pre></div><p>2) Нарушена последовательность изменений в функции Replace(text, direction := true).<br />Ответ нужно парсить&nbsp; в такой последовательности:<br /></p><div class="codebox"><pre><code>response = response.replace (/&amp;gt;/g, &#039;&gt;&#039;);
response = response.replace (/&amp;lt;/g, &#039;&lt;&#039;);
response = response.replace (/&amp;amp;/g, &#039;&amp;&#039;);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-01-04T00:12:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110480#p110480</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110479#p110479" />
			<content type="html"><![CDATA[<p>Вроде получилось:<br /></p><div class="codebox"><pre><code>text1 := &quot;Johnson &amp; Johnson&quot;
text2 =
(
— Это &quot;Типограф&quot;?
— Нет, это «Типограф»!
)
Typograf := new Typograf
MsgBox, % Typograf.Process(text1)
MsgBox, % Typograf.Process(text2)
MsgBox, % Typograf.Process(text2, true)  ; с переносом строк

class Typograf  {
   __New()  {
      this.xmlhttp := ComObjCreate(&quot;Msxml2.XMLHTTP&quot;)
      this.WaitForResponse := ObjBindMethod(this, &quot;Ready&quot;)
   }
   
   Process(text, useBr := false)  {
      text := this.Replace(text)
      xmlRequest := &quot;&lt;?xml version=&quot;&quot;1.0&quot;&quot; encoding=&quot;&quot;UTF-8&quot;&quot;?&gt;&quot;
                  . &quot;&lt;soap:Envelope xmlns:xsi=&quot;&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&quot;&quot;
                  . &quot; xmlns:xsd=&quot;&quot;http://www.w3.org/2001/XMLSchema&quot;&quot;&quot;
                  . &quot; xmlns:soap=&quot;&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&quot;&gt;&quot;
                  . &quot;&lt;soap:Body&gt;&quot;
                  . &quot;&lt;ProcessText xmlns=&quot;&quot;http://typograf.artlebedev.ru/webservices/&quot;&quot;&gt;&quot;
                  . &quot;&lt;text&gt;&quot; . text . &quot;&lt;/text&gt;&quot;
                  . &quot;&lt;useP&gt;0&lt;/useP&gt;&quot;
                  . &quot;&lt;useBr&gt;&quot; . useBr . &quot;&lt;/useBr&gt;&quot;
                  . &quot;&lt;/ProcessText&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;&quot;
                  
      url := &quot;http://typograf.artlebedev.ru/webservices/typograf.asmx&quot;
      this.xmlhttp.Open(&quot;POST&quot;, url, true)
      this.xmlhttp.onreadystatechange := this.WaitForResponse
      this.xmlhttp.setRequestHeader(&quot;Content-Type&quot;, &quot;text/xml&quot;)
      this.xmlhttp.Send(xmlRequest)
      while this.result = &quot;&quot;
         Sleep, 200
      res := this.Replace(this.result, false)
      this.result := &quot;&quot;
      Return RegExReplace(res, &quot;s).*&lt;ProcessTextResult&gt;(.*)&lt;/ProcessTextResult&gt;.*&quot;, &quot;$1&quot;)
   }
   
   Ready()  {
      if this.xmlhttp.readyState != 4
         Return
      this.result := this.xmlhttp.ResponseText
   }
   
   Replace(text, direction := true)  {
      for k, v in [ [&quot;&amp;&quot;, &quot;&amp;amp;&quot;], [&quot;&lt;&quot;, &quot;&amp;lt;&quot;], [&quot;&gt;&quot;, &quot;&amp;gt;&quot;] ]
         text := StrReplace(text, direction ? v[1] : v[2], direction ? v[2] : v[1])
      Return text
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-03T23:09:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110479#p110479</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: API Типографа Лебедева]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110474#p110474" />
			<content type="html"><![CDATA[<p>Привет, форумчане.</p><p>Я хочу создать скрипт, который будет типографить выделенный текст. Для этого думаю подключаться к типографу Лебедева.<br />Подскажите, как это сделать вообще? И можно ли вообще?</p><p>Типограф: <a href="http://www.artlebedev.ru/tools/typograf/">http://www.artlebedev.ru/tools/typograf/</a></p><p>API: <a href="http://www.artlebedev.ru/tools/typograf/webservice/">http://www.artlebedev.ru/tools/typograf/webservice/</a></p>]]></content>
			<author>
				<name><![CDATA[Gif]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34431</uri>
			</author>
			<updated>2017-01-03T18:54:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110474#p110474</id>
		</entry>
</feed>
