• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

XML Transformation Script (PowerShell)

OK, I've got a working version of a PowerShell-built GUI. I need to polish some things up before I post it, and how long that takes depends on a few real-life things I have to do.

Why can't I just win the lottery? :-(
 
New version up! See the first post in this thread.

EDIT: Yeah, yeah, I know what I said. But it was too late to go to sleep and too early to start making business calls.
 
Actually, I was just going to post that there was a quirk in the GUI script, but then I realized, "No, wait, I can fix that!"

So I did. And the new version is up.

There. I'm done for the day. No more scripting stuff today. Gotta do real-life stuff.
 
OK, another quick update. I accidentally left a line commented out that I commented out for testing. I took out the comment so that line is active now.

I also changed the CSS settings so things look much nicer. I learned about gradients today. :-)

Since I updated the CSS file, I reprinted the documentation and releasenotes to PDF to reflect the new CSS formatting.
 
So I asked (via bug report because I thought it was) about some of the XML that is kind of pointless/ugly/annoying, and got a nice developer response.

My issue was with a text snippet with links in it. (You might have seen my suggestion post as well).

In the following example, "AMC", "Aldolore Station" and "Rone Varan" are links within the sentence.

"The Aldolore Mining Cartel, also known as the AMC, is a corporation that controls Aldolore Station, Rone Varan and the surrounding asteroid fields."

The XML is:
<contents>
<p class=\"RWDefault\">
<span class=\"RWSnippet\">The Aldolore Mining Cartel, also known as the </span>
<span class=\"RWSnippet\">AMC</span>
<span class=\"RWSnippet\">, is a corporation that controls </span>
<span class=\"RWSnippet\">Aldolore Station</span>
<span class=\"RWSnippet\">, </span>
<span class=\"RWSnippet\">Rone Varan</span>
<span class=\"RWSnippet\">and the surrounding asteroid fields.
</span>
</p>
</contents>

That means that if I want to use CSS to pretty up my snippets, my only option is to use the larger RWDEFAULT class rather than just the RWSnippet class that's immeidately around the text. If I use the RWSnippet class and do any positioning or margins, it will mess up individual words in the line.

Depending on how RWSnippet is used in other use-cases (I just have really simple images-and-text realms) it might be worth your while to simply filter out the RWSnippet spans, because they do little but add a lot of extra characters to the text (nearly doubling the size in this example).

There doesn't seem to be a way that they can change the class of links to a different class to denote a link, according to David, the dev who replied in pretty cool detail to my question.

What you propose would be ideal, but a part of what we have is based on the control we use for showing snippets within Realm Works. This control is an RTF control that happens to support HTML import and export. What we store is pretty close to what we get out of that control and probably more closely mimics RTF as translated to HTML rather than fully hand-craft HTML.

We actually do not depend on any indication of links being stored in the HTML. It is all pulled out and stored separately within the link data itself. So if you wanted to recreate links as we have inside of Realm Works, you would need to use the information in links as well as the HTML contents to properly set it all up.
 
Last edited:
So I asked (via bug report because I thought it was) about some of the XML that is kind of pointless/ugly/annoying, and got a nice developer response.

My issue was with a text snippet with links in it. (You might have seen my suggestion post as well).

In the following example, "AMC", "Aldolore Station" and "Rone Varan" are links within the sentence.

"The Aldolore Mining Cartel, also known as the AMC, is a corporation that controls Aldolore Station, Rone Varan and the surrounding asteroid fields."

The XML is:
<contents>
<p class=\"RWDefault\">
<span class=\"RWSnippet\">The Aldolore Mining Cartel, also known as the </span>
<span class=\"RWSnippet\">AMC</span>
<span class=\"RWSnippet\">, is a corporation that controls </span>
<span class=\"RWSnippet\">Aldolore Station</span>
<span class=\"RWSnippet\">, </span>
<span class=\"RWSnippet\">Rone Varan</span>
<span class=\"RWSnippet\">and the surrounding asteroid fields.
</span>
</p>
</contents>

That means that if I want to use CSS to pretty up my snippets, my only option is to use the larger RWDEFAULT class rather than just the RWSnippet class that's immeidately around the text. If I use the RWSnippet class and do any positioning or margins, it will mess up individual words in the line.

Depending on how RWSnippet is used in other use-cases (I just have really simple images-and-text realms) it might be worth your while to simply filter out the RWSnippet spans, because they do little but add a lot of extra characters to the text (nearly doubling the size in this example).

There doesn't seem to be a way that they can change the class of links to a different class to denote a link, according to David, the dev who replied in pretty cool detail to my question.

I use the P tag. I strip out some inline formatting first, though. It seems to work. Are you having issues?
 
I use the P tag. I strip out some inline formatting first, though. It seems to work. Are you having issues?

Nope. I was just digging in to the html to do some custom styling and was appalled at the number of RWSnippet spans.

My first thought was that it was deliberate, and just a bug that the RWSnippet span was also applied to links (they should be RWLink or something), which is why I reported it.

If they aren't there to delineate links, there's no point except to make the HTML much less readable.

But nope, that's the way it's supposed to be.

Looking at it makes me twitch, but that's the way it is and I'll deal. :-D
 
Just thought I would report in. I am no longer having the problem I reported earlier. I'm not sure what changed, whether it was something on my system (perhaps likely since I'm the only one who reported it), but it is now working well.

Other good news: those funky Star Wars: Edge of the Empire dice fonts get exported correctly and show up in the HTML, but only if you check Preserve Original Text Formatting. I'm not sure what else this setting might affect.

I do have a couple minor formatting issues in HTML output. My troublesome bullet lists are about five spaces further left than the paragraphs around them. And the table formatting is off-kilter. I have added background colors to the tables, changed the fonts, and some other stuff that may have confused it.

Here's an example showing those issues: http://moon.gibbous.org/export-test.html

I did notice that the table formatting weirdness is related to the CSS code because when I first uploaded the HTML file to my site I forgot to upload the CSS file and the tables looked okay then.

If I have time, I might mess around with some CSS.

So, again, I'm just posting this because I figured you'd want to know. Your script is great and I'm happy we have it.
 
I'm glad your original bug is gone. If I had to guess, I would attribute that to the way I was originally using github. I was copying and pasting the script into gists instead of uploading files, and I think it was changing some character encoding.

The reason I'm guessing this is what happened is that I could never reproduce your original error, even with the exact same rwoutput file that you were using.

In regards to preserving the original formatting, what script strips out is the font type, size, and colors (font color and background color). It makes complete sense to me that using this options preserves your Star Wars dice characters.

In regards to tables and lists, there could be a few different things going on here. I've noticed that between IE, Chrome and Firefox, there are notable differences between how tables are displayed. IE doesn't seem to indent tables at all (at least with my script's output) where as Firefox does. I forget what the quirks were with Chrome.

I should have mentioned this in the release notes. But again, that's just one possibility. The only formatting I strip from tables is what I've mentioned above, and if you preserve formatting, I don't even strip that.

My understanding is that inline formatting overrides external CSS files, so if you preserve formatting, the table formatting in the CSS file should have ... no ... effect? (Famous last words, right?)

I'm no expert here. I'm still learning. So don't take that as an authoritative statement (hence the question marks).

The lists are what have me most confused, at least in the aspect that lists are much simpler than tables, so their behavior should be more straightforward.

That being said, I did change the way I was managing indents, because the old way I was doing it was causing a conflict with existing inline formatting. It seemed to work OK, but I could have missed something. Or, again, it could come down to browser interpretation.

What I would suggest is that you export at least this one topic, if not two or three that are having the same issues, and I'll see what I can figure out. Also, send the me the specific command line that you're using (this can be copied and pasted from the GUI), the HTML output you're getting, which browser you're using, and screenshots of how your browser is rendering the output.
 
In regards to tables and lists, there could be a few different things going on here. I've noticed that between IE, Chrome and Firefox, there are notable differences between how tables are displayed.
One thing that might help is specifying a DOCTYPE. The sample outputs I've seen don't have one, leaving the browsers to make more guesses about how to display your HTML+CSS. (It's called "rendering in Quirks Mode" if you want more info.)

The DOCTYPE needs to be the first line of your HTML file. The one for HTML 5 is pretty simple:
Code:
<!DOCTYPE html>
Adding that won't make the different browsers (and versions of browsers) create identical output, but they should end up a lot closer than before.

My understanding is that inline formatting overrides external CSS files, so if you preserve formatting, the table formatting in the CSS file should have ... no ... effect? (Famous last words, right?)
The style attribute does override earlier styling, but only for the things specified within. Anything not included in the style attribute will be determined by whatever other rules exist. The rules in your external CSS file will only have no effect if the style attribute overrides everything within those rules.

The lists are what have me most confused, at least in the aspect that lists are much simpler than tables, so their behavior should be more straightforward.
Looking at the part of tmilktoast's sample where there's a list, the surrounding <p> elements' style attributes have a margin-left but the <ul> does not. HTML lists should be treated the same as paragraphs and tables for most styling purposes.

FWIW, I think you'd be better off putting a <div> around the things you want to indent and adding padding or margin to the <div>. (I threw a quick example up at JSBin.)
 
Last edited:
One thing that might help is specifying a DOCTYPE. The sample outputs I've seen don't have one, leaving the browsers to make more guesses about how to display your HTML+CSS. (It's called "rendering in Quirks Mode" if you want more info.)

The DOCTYPE needs to be the first line of your HTML file. The one for HTML 5 is pretty simple:
Code:
<!DOCTYPE html>
Adding that won't make the different browsers (and versions of browsers) create identical output, but they should end up a lot closer than before.


The style attribute does override earlier styling, but only for the things specified within. Anything not included in the style attribute will be determined by whatever other rules exist. The rules in your external CSS file will only have no effect if the style attribute overrides everything within those rules.


Looking at the part of tmilktoast's sample where there's a list, the surrounding <p> elements' style attributes have a margin-left but the <ul> does not. HTML lists should be treated the same as paragraphs and tables for most styling purposes.

FWIW, I think you'd be better off putting a <div> around the things you want to indent and adding padding or margin to the <div>. (I threw a quick example up at JSBin.)

The thing that confuses me is that in my own testing, there IS a margin-left in the UL tag. My lists, ordered and unordered, are properly indented along their respective topics and sections.

One thing I noticed though, is that my UL tags have two style declarations.

Code:
<ul style="margin-left:105px;" start="1" style="margin-top:0;margin-bottom:0;">

I fixed this in other parts of the code to incorporate everything into one style declaration. I missed doing that for lists.

I'm wondering if maybe in the process of uploading his html file, something in that process detected the two style statements, determined that as invalid, and deleted one of them?

Or maybe he manually edited something? I have no idea. I don't understand why I would have the margin-left statements in my output, and he wouldn't.
 
The thing that confuses me is that in my own testing, there IS a margin-left in the UL tag. My lists, ordered and unordered, are properly indented along their respective topics and sections.

One thing I noticed though, is that my UL tags have two style declarations.

Code:
<ul style="margin-left:105px;" start="1" style="margin-top:0;margin-bottom:0;">

I fixed this in other parts of the code to incorporate everything into one style declaration. I missed doing that for lists.

I'm wondering if maybe in the process of uploading his html file, something in that process detected the two style statements, determined that as invalid, and deleted one of them?

Or maybe he manually edited something? I have no idea. I don't understand why I would have the margin-left statements in my output, and he wouldn't.

Or maybe there's something in his XML source that doesn't fit with how I'm parsing the different tags, so his lists go undetected as such. To determine that, though, I'd need his XML source.
 
One thing that might help is specifying a DOCTYPE. The sample outputs I've seen don't have one, leaving the browsers to make more guesses about how to display your HTML+CSS. (It's called "rendering in Quirks Mode" if you want more info.)

The DOCTYPE needs to be the first line of your HTML file. The one for HTML 5 is pretty simple:
Code:
<!DOCTYPE html>
Adding that won't make the different browsers (and versions of browsers) create identical output, but they should end up a lot closer than before.


The style attribute does override earlier styling, but only for the things specified within. Anything not included in the style attribute will be determined by whatever other rules exist. The rules in your external CSS file will only have no effect if the style attribute overrides everything within those rules.


Looking at the part of tmilktoast's sample where there's a list, the surrounding <p> elements' style attributes have a margin-left but the <ul> does not. HTML lists should be treated the same as paragraphs and tables for most styling purposes.

FWIW, I think you'd be better off putting a <div> around the things you want to indent and adding padding or margin to the <div>. (I threw a quick example up at JSBin.)

Also, thanks for the tips. I've added the doctype for the next release.

I'll play around with <div> and see what I can do.
 
Definitely love the div tag. This is going to take a little bit of work, but in the end, the code will be streamlined, and this will fix a few things that have been annoying me.
 
Regarding those Edge of the Empire fonts, I imagine none of you are seeing them in your browser because you probably don't have them installed on your PC.

EightBitz, do you still want me to send you those things you asked for, or were you just going to work on Parody's suggestions?
 
Regarding those Edge of the Empire fonts, I imagine none of you are seeing them in your browser because you probably don't have them installed on your PC.

EightBitz, do you still want me to send you those things you asked for, or were you just going to work on Parody's suggestions?

I'm working on Parody's suggestion, and I'm pretty far along with the div tags. Had a few hiccups along the way, but things are going well now.
 
Back
Top