flycutter-zfz / rfc2kindle

Automatically exported from code.google.com/p/rfc2kindle
0 stars 0 forks source link

(Fix/patch included) Newlines in <blockquote> tags disappear in .mobi output #3

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Invoke rfc2kindle/rfc2mobi to convert any RFC that would result in a 
<blockquote> tag being created in its HTML output.
2. View the resulting .mobi output.
3. Newlines in text inside <blockquote> tags are missing.

What is the expected output? What do you see instead?
Using an example from RFC 4462...

Here's the raw the RFC text:
           byte        SSH_MSG_USERAUTH_REQUEST
           string      user name
           string      service
           string      "gssapi-keyex"
           string      MIC

Here's the HTML that rfc2mobi generates:
<blockquote>
           byte      SSH_MSG_USERAUTH_REQUEST
           string    user name (in ISO-10646 UTF-8 encoding)
           string    service name (in US-ASCII)
           string    "gssapi-with-mic" (US-ASCII method name)
           uint32    n, the number of mechanism OIDs client supports
           string[n] mechanism OIDs
</blockquote>

In the .mobi file, newlines are not preserved, so that text looks like:
    byte SSH_MSG_USERAUTH_REQUEST string user name (in ISO-10646 UTF-8 encoding) string service name (in US-ASCII) string "gssapi-with-mic" (US-ASCII method name) uint32 n, the number of mechanism OIDs client supports string[n] mechanism OIDs

But I would expect it to look like:
    byte      SSH_MSG_USERAUTH_REQUEST
    string    user name (in ISO-10646 UTF-8 encoding)
    string    service name (in US-ASCII)
    string    "gssapi-with-mic" (US-ASCII method name)
    uint32    n, the number of mechanism OIDs client supports
    string[n] mechanism OIDs

What version of the product are you using? On what operating system?
(same as in Issue 1 and Issue 2)

Please provide any additional information below.
Here's a simple fix, with code. When generating a <blockquote> tag, just 
replace newlines with <br /> tags. I tested this and it works:
In html.py, inside of outputTextBlock(self), replace:
 self.output.write("%s\n" %(i))
with:
 self.output.write("%s<br/>" %(i))

Other possible fixes:
1. Use the <pre> tag instead of using <blockquote>. The output is not as pretty 
(in my opinion) because spaces are preserved, but it works. Removing extra 
spaces and using <pre> would look better.

2. Create a figure instead of using <blockquote>. I have not tested this but it 
would probably not look as nice as (1).

Original issue reported on code.google.com by proverbs...@gmail.com on 14 Feb 2012 at 6:58