Missing blank if a <code> tag is at the start of line

Issue #11 open
Benjamin Arbogast
created an issue

If a <code> tag is at the start of line, lore2spinx doesn't add a blank before the text in the tags. This way sphinx doesnt recognize the inline literal and prints the `` in the html.

Example:

lore {{{ <p><code>RemoteInterfaces</code> are created and used a lot like the usual <code>zope.interface</code>-style }}}

rest output {{{ RemoteInterfaces are created and used a lot like the usualzope.interface }}}

"RemoteInterfaces" is ok, but before "zope.interface" a blank is missing.

Comments (5)

  1. Benjamin Arbogast reporter

    Hi,

    I attached a patch which fixes the problem in some cases. It checks if the previous or the parent tag contains a newline at the end. In this case a space is added before the result. It seems a little hackish but it does its job.

    Except: lxml seems to swallow the newline character sometimes, so the patch doesn't work for this cases. I think I'll fix that in the rst files.

    Greetings Koblaid

  2. Kevin Horn repo owner

    Your patch looks pretty good to me, though I wonder if it could be generalized bit. I know there are several other places where similar things happen (with spaces getting dropped).

    Your patch also looks very similar to some experiments I did several months ago, but couldn't get to work in enough cases. Your code is certainly a lot neater than my experiments though, so perhaps my problem was trying to make it too general. :)

    I'll have to ponder this. If it can be made general enough, then it would solve a lot of other issues in the twisted docs I think.

  3. Benjamin Arbogast reporter

    I'm glad that you like it.

    While trying to improve the patch I found the reason for the missing newline characters which I mentioned in comment #1: They are removed by left_align (which is called by format_p).

    Now I dont know which solution is the best. Without the newline character it is impossible to detect later on, if a space needs to be inserted. So I tried to change align_left to re-append newlines after the join. But that means, that these newlines will remain in the string and make it to the rst output. I dont know if this is ok.

    That lead me to another thought: maybe the problem with the missing blanks is fixed, if the newline characters are re-appended and there is no need to manually insert any spaces...

    I created a fork of lore2sphinx https://bitbucket.org/Koblaid/lore2sphinx/ to be able to upload my changes so you can see them. Is that the right way? I'm new to bitbucket/dvcs. There you can find the improved patch. I also added some unittest (run "trial test/test.py")

    I'm on holiday from saturday this week to saturday next week, but I try to login tomorrow.

    Greets Kob

  4. Anonymous

    I've been out of town for the last week, and I'm about to leave town again. Based on my (very) brief glance at your pull request. I think it's probably good, but I'll try to take a closer look next week when things have (hopefully) slowed down a bit for me.

    In any case, thanks for the input!

  5. Log in to comment