<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: API Типографа Лебедева]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=12276</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12276&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: API Типографа Лебедева».]]></description>
		<lastBuildDate>Wed, 04 Jan 2017 06:14:26 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110491#p110491</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Gif)]]></author>
			<pubDate>Wed, 04 Jan 2017 06:14:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110491#p110491</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110489#p110489</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 04 Jan 2017 01:44:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110489#p110489</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110488#p110488</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 04 Jan 2017 01:04:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110488#p110488</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110487#p110487</link>
			<description><![CDATA[<p>Хотя не уверен, надо подумать про последовательность замен.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 04 Jan 2017 00:59:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110487#p110487</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110486#p110486</link>
			<description><![CDATA[<p>Ну в этом случае на сайте ошибка. Угловые скобки должны быть заменены.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 04 Jan 2017 00:53:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110486#p110486</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110485#p110485</link>
			<description><![CDATA[<p>Результат по сравнению с сайтом разный:<br /></p><div class="codebox"><pre><code>text2 =
(
&lt;ProcessTextResult&gt;
— Это &quot;Типограф&quot;?
&lt;ProcessTextResult&gt;
— Нет, это «Типограф»!
)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 04 Jan 2017 00:49:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110485#p110485</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110484#p110484</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 04 Jan 2017 00:43:15 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110484#p110484</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110483#p110483</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 04 Jan 2017 00:29:03 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110483#p110483</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110481#p110481</link>
			<description><![CDATA[<p>1) — не имеет смысла, в ответе только один такой тег.<br />2) — а какая разница?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 04 Jan 2017 00:22:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110481#p110481</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110480#p110480</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 04 Jan 2017 00:12:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110480#p110480</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110479#p110479</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 03 Jan 2017 23:09:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110479#p110479</guid>
		</item>
		<item>
			<title><![CDATA[AHK: API Типографа Лебедева]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110474#p110474</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Gif)]]></author>
			<pubDate>Tue, 03 Jan 2017 18:54:07 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110474#p110474</guid>
		</item>
	</channel>
</rss>
