Skip to content

Instantly share code, notes, and snippets.

@pke
Created April 14, 2010 16:43
Show Gist options
  • Save pke/366037 to your computer and use it in GitHub Desktop.
Save pke/366037 to your computer and use it in GitHub Desktop.
I have this HTML fragment from a vBulleting board:
<div id="post_message_5344600">
<div style="margin: 5px 20px 20px;">
<div style="margin-bottom: 2px;" class="smallfont">Quote:</div>
<table width="100%" cellspacing="0" cellpadding="8" border="0">
<tbody><tr>
<td style="border: 1px inset;" class="alt2">
<div>
Quote from <strong>Ahnungslos</strong>
<a rel="nofollow" href="showthread.php?
p=5344371#post5344371">Show post</a>
</div>
<div style="font-style: italic;">Some text<br>
<br>
tss tss...
</div>
</td>
</tr>
</tbody>
</table>
</div>
Some other text
</div>
That I would like to convert back to its original BBCode style:
It should look like this:
[QUOTE=Ahnungslos;5344371]
Some Text
tss tss
[/QUOTE]
Some other text
Basically its an XSLT transformation, but I have no idea how to do
that in nokogiri.
This first DIV (div style="margin: 5px 20px 20px;) marks the start of
the [QUOTE] part of BBCode.
The first DIV inside the table contains the username between the
strong tags.
The next DIV (div style="font-style: italic;") contains the actual
quoted text, that is everything between the [QUOTE][/QUOTE] tags in
BBCode.
The follows the message text that is not part of the quote.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment