[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-docs
Subject: Re: svn commit: r1734349 - in /httpd/httpd/trunk/docs/manual/howto: access.html.en access.xml.fr acc
From: Christophe JAILLET <christophe.jaillet () wanadoo ! fr>
Date: 2016-04-25 20:58:39
Message-ID: 0b134d82-dd88-b0f0-7213-d4bb179900ac () wanadoo ! fr
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Le 17/03/2016 à 21:35, André Malo a écrit :
> * André Malo wrote:
>
>> * Marion & Christophe JAILLET wrote:
>>> Le 10/03/2016 06:28, jailletc36@apache.org a écrit :
>>> Should prettyprint be tweaked to handle it? (I've seen that the version
>>> we use is not the same as the latest available at
>>> https://github.com/google/code-prettify)
>>> I quick test with the latest version, without backporting modification
>>> applied to the original prettify.js file, looks promising.
>>> So IMHO, it is either a bug now fixed in prettify.js itself or an issue
>>> introduced when it has been adapted for our own use.
>>>
>>> I leave my change in trunk
>>> http://httpd.apache.org/docs/trunk/en/howto/access.html) but revert it
>>> for now in 2.4.x.
>> I'll give it a closer look later.
> too close... ouch.
>
> apparently there's no documentation how the prettify.js file was generated.
> Need to figure that out before I can replace it. If someone has more
> experience here, please speak up :-) Otherwise I'll dig through there build
> system as soon as I get around to it :/
>
> (also, loading from an external server as it's "recommended" by google is
> not an option)
>
> Cheers,
What about the attached patch?
The main idea is that we should try to fix leading/ending
newlines/spaces *only* at the beginning and at the end of a node to
pretiffy.
Actually, we perform the clean-up for *each underlying node*, if any.
In the example below, the use of <var> within the block generates some
child nodes. This why the strings get concatenated.
Without these <var>, the output looks correct.
The attached patch:
- removes the leading NL/spaces for the *first* node only (see the
new init var)
- improve the existing "replace(/\n$/..." and turn it into
"replace(/\s+$/..." to handle all ending NL/spaces
On HTML code such as:
--------------
<pre class="prettyprint lang-config">
Require host <var>address</var>
sdfs
Require ip <var>ip.address</var>
ssfsf
</pre>
--------------
the output is as expected
That is to say:
- leading NL removed
- leading spaces removed
- NL within the block kept
- leading spaces within the block kept
- ending NL removed
- ending spaces removed
Note that doc that already add an arbitrary <br /> to keep the
erroneously removed NL, should now be fixed. Otherwise a new NL will be
generated (the NL in the <pre> block + the <br />)
I don't remember where, but I've already seen such a construction in the
doc.
CJ
[Attachment #5 (multipart/related)]
[Attachment #7 (text/html)]
<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Le 17/03/2016 à 21:35, André Malo a
écrit :<br>
</div>
<blockquote cite="mid:201603172135.34083@news.perlig.de" type="cite">
<pre wrap="">* André Malo wrote:
</pre>
<blockquote type="cite">
<pre wrap="">* Marion & Christophe JAILLET wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Le 10/03/2016 06:28, <a class="moz-txt-link-abbreviated" \
href="mailto:jailletc36@apache.org">jailletc36@apache.org</a> a écrit : </pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Should prettyprint be tweaked to handle it? (I've seen that \
the version we use is not the same as the latest available at
<a class="moz-txt-link-freetext" \
href="https://github.com/google/code-prettify">https://github.com/google/code-prettify</a>)
I quick test with the latest version, without backporting modification
applied to the original prettify.js file, looks promising.
So IMHO, it is either a bug now fixed in prettify.js itself or an issue
introduced when it has been adapted for our own use.
I leave my change in trunk
<a class="moz-txt-link-freetext" \
href="http://httpd.apache.org/docs/trunk/en/howto/access.html">http://httpd.apache.org/docs/trunk/en/howto/access.html</a>) \
but revert it for now in 2.4.x.
</pre>
</blockquote>
<pre wrap="">
I'll give it a closer look later.
</pre>
</blockquote>
<pre wrap="">
too close... ouch.
apparently there's no documentation how the prettify.js file was generated.
Need to figure that out before I can replace it. If someone has more
experience here, please speak up :-) Otherwise I'll dig through there build
system as soon as I get around to it :/
(also, loading from an external server as it's "recommended" by google is
not an option)
Cheers,
</pre>
</blockquote>
<p>What about the attached patch?</p>
<p>The main idea is that we should try to fix leading/ending
newlines/spaces *only* at the beginning and at the end of a node
to pretiffy.</p>
<p>Actually, we perform the clean-up for *each underlying node*, if
any.<br>
In the example below, the use of <var> within the block
generates some child nodes. This why the strings get concatenated.<br>
Without these <var>, the output looks correct.</p>
<p><br>
</p>
The attached patch:<br>
- removes the leading NL/spaces for the *first* node only (see
the new init var)<br>
- improve the existing "replace(/\n$/..." and turn it into
"replace(/\s+$/..." to handle all ending NL/spaces<br>
<br>
<br>
On HTML code such as:<br>
--------------<br>
<pre class="prettyprint lang-config"> <br>
<br>
<br>
<br>
<br>
<br>
Require host <var>address</var><br>
sdfs<br>
<br>
<br>
Require ip <var>ip.address</var><br>
ssfsf<br>
<br>
<br>
</pre><br>
--------------<br>
the output is as expected<br>
<img src="cid:part1.9E4EABC3.4D802359@wanadoo.fr" alt=""><br>
That is to say:<br>
- leading NL removed<br>
- leading spaces removed<br>
- NL within the block kept<br>
- leading spaces within the block kept<br>
- ending NL removed<br>
- ending spaces removed<br>
<br>
<br>
<br>
Note that doc that already add an arbitrary <br /> to keep the
erroneously removed NL, should now be fixed. Otherwise a new NL will
be generated (the NL in the <pre> block + the <br />)<br>
I don't remember where, but I've already seen such a construction in
the doc.<br>
<br>
CJ<br>
</body>
</html>
["oimfjibackofdlhc.png" (image/png)]
["js.patch" (text/plain)]
Index: style/scripts/prettify.js
===================================================================
--- style/scripts/prettify.js (révision 1740877)
+++ style/scripts/prettify.js (copie de travail)
@@ -533,6 +533,7 @@
var length = 0;
var spans = [];
var k = 0;
+ var init = 1;
function walk(node) {
switch (node.nodeType) {
@@ -554,10 +555,11 @@
if (!isPreformatted) {
text = text.replace(/[ \t\r\n]+/g, ' ');
} else {
+ if (init == 1) {
+ text=text.replace(/^\s+/,''); // Remove leading newlines and spaces
+ init = 0; // (but only for the first node)
+ }
text = text.replace(/\r\n?/g, '\n'); // Normalize newlines.
- text = text.replace(/^(\r?\n\s*)+/g, ''); // Remove leading newlines
- text = text.replace(/^\s*/g, ''); // Remove leading spaces due to indented formatting
- text = text.replace(/(\r?\n\s*)+$/g, ''); // Remove ending newlines
}
// TODO: handle tabs here?
@@ -572,8 +574,9 @@
walk(node);
+ // Remove ending newlines and spaces
return {
- sourceCode: chunks.join('').replace(/\n$/, ''),
+ sourceCode: chunks.join('').replace(/\s+$/, ''),
spans: spans
};
}
---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic