• 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)

Hey! I had a pitchfork LAST time. You promised me I could have a torch!!!

Oh, and github is beautiful. Even for us non-coders. The 5e HL community stuff is there and it's easy to download and provide edits.
 
The <contents> of a <snippet> should all be HTML and that would be the only place that the lists, tables, etc. would be present. You should be able to take the <contents> and just treat it as HTML and be done with it. Any more and you are making life hard on yourself. :)

The only slight gotcha is that we use encoding of the contents so that it isn't interpreted as XML tags, but that should be straight-forward to deal with.

Nope, I still have to tear things apart for HTML. There's another gotcha.

I'm adding an option to indent nested topics and sections. And it works great for everything except tables. Mind you, I'm still very much an amateur coder, but here's basically what's happening.

In order to indent blocks of text, and not just the first line, I'm using margin-left. For pre-formatted HTML text in the contents node, I'm inserting it right after the "<p " tag. And I add it to every instance, otherwise only some parts of some snippets will indent, and the rest will not.

Adding it to every instance of <p means it's also adding the margin to the table cells.

I could just write code that says if this snippet includes a table tag, then don't insert a margin, but if I have a combo snippet with text and lists and tables, that's not going to work.

So I have to divide things up into components again so I can have better control of where I insert the margins.

The GOOD news is that I already have that code. :-)

The bad news is that I've been up all night, and I'm tired.

But the GOOD news is that everything else is looking good, and this is hopefully the last thing I have to tackle.

The bad news is that I can't do it right now.

But the GOOD news is that ... uhhh ... oh, never mind.
 
I'm onto you guys. This is just the calm before the storm, when the pitchforks and torches are properly gathered and the villagers summoned from their homes to be properly equipped and whipped into a frenzy in the days ahead. Right? :)

Darn! Well, seems we will have to switch to plan B
 
Bloody nice work EightBitz! I tried it tonight and managed it with little to no issues. Had to modify the security settings on my PC to enable the script to run and I had removed the full stop from the start of the script thinking that was just to break any auto-formatting (I do that in Excel alot).

To make this a bit easier for new users to pick up here's a video on the process of setting up and running the script.

Realm Works - How To Print Your Realm
 
Doh! I forgot about the security issue.
The Powershell command you need is:
Set-ExecutionPolicy RemoteSigned

That SHOULD do the trick.
 
Bloody nice work EightBitz! I tried it tonight and managed it with little to no issues. Had to modify the security settings on my PC to enable the script to run and I had removed the full stop from the start of the script thinking that was just to break any auto-formatting (I do that in Excel alot).

To make this a bit easier for new users to pick up here's a video on the process of setting up and running the script.

Realm Works - How To Print Your Realm

OK, that was an awesome video, but you overlooked one very important detail.

There's a file called "main.css" that should have been included in the zip download. Put the HTML file in the same folder as the main.css file, and you will see a world of difference.
 
And if you want nested topics and sections indented, you can add -Indent to the end of the command line.

If you type:
Get-Help .\RWExport-To-HTML.ps1 -full

You will see all the options available, with examples of how to use them on the command line.
 
I just wanted to show people what the output SHOULD look like in your web browser, if you have the html and css files together, and if you use the -Indent option.

Playground1.pdf is the way I have things setup by default.
In Playground2.pdf, I just made a few changes to the css file to change the formatting, but it's the exact same HTML file.

EDIT: Note this is also from a newer version of the script that now displays images inline, and has links for statblocks. I want to smooth a few things out before I put this new version up, but the key here is to showcase the formatting.
 

Attachments

Last edited:
Excellent! Have to admit... I was excited that I figured out how to get it working at all.... Will put a full video together showing this next step.
 
First of all, thank you EightBitz, for the great script.

I figure you would want a report of any errors, so here goes. I've done some testing and believe I have it narrowed down to it choking on bullet lists (which I use heavily, unfortunately).

Interestingly, it works fine if I change the Snippet Type to Labeled Text and leave the bullet lists as-is. It also seems to work if I use the bullet list under "Styles" rather than under "Paragraphs". (Does anyone know why we have two sets of bullets, and other, lists?)

Code:
New-Object : Cannot find type [â€TypeName PSObject â€Prop]: verify that the assembly containing this type is loaded.
At D:\owncloud\rpg\utilities\rwexport\RWExport-To-HTML.ps1:388 char:25
+ ...    $TagLocation = New-Object –TypeName PSObject –Prop $properties
+                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

Cannot index into a null array.
At D:\owncloud\rpg\utilities\rwexport\RWExport-To-HTML.ps1:416 char:7
+       $StartPosition = $Taglist[$HighTag].Start + 1
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

Edit: To expand on this, it looks like it hits a bullet list then gets stuck and just continually spits out these errors. The HTML file is still created, but ends at the snippet above the one with the bullet list.
 
Last edited:
First of all, thank you EightBitz, for the great script.

I figure you would want a report of any errors, so here goes. I've done some testing and believe I have it narrowed down to it choking on bullet lists (which I use heavily, unfortunately).

Interestingly, it works fine if I change the Snippet Type to Labeled Text and leave the bullet lists as-is. It also seems to work if I use the bullet list under "Styles" rather than under "Paragraphs". (Does anyone know why we have two sets of bullets, and other, lists?)

Code:
New-Object : Cannot find type [â€TypeName PSObject â€Prop]: verify that the assembly containing this type is loaded.
At D:\owncloud\rpg\utilities\rwexport\RWExport-To-HTML.ps1:388 char:25
+ ...    $TagLocation = New-Object –TypeName PSObject –Prop $properties
+                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

Cannot index into a null array.
At D:\owncloud\rpg\utilities\rwexport\RWExport-To-HTML.ps1:416 char:7
+       $StartPosition = $Taglist[$HighTag].Start + 1
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

Edit: To expand on this, it looks like it hits a bullet list then gets stuck and just continually spits out these errors. The HTML file is still created, but ends at the snippet above the one with the bullet list.

Would you be able to export just that one topic and copy and and paste the xml code in a private message to me?
 
To Rob, Davidp, daplunk, ShadowChemosh, and everyone else, I want to thank you for the kind words and moral support.

And daplunk, thank you for a mostly awesome video ... until the very end where you pulled up the unformatted HTML and said, "Well that's it!" And my jaw dropped with incredulity as I mentally screamed, "No, that is certainly NOT it!"

But still, you seem to have a very good method in making your videos. When I gear up to start entering my own data, I plan to watch more of them.

Right now, though, yes I am still updating the script. As you've seen in the PDF files that I posted, I'm adding support for stat blocks and images, and I've going to see what I can do with other snippet types. No guarantees on anything at this point.
 
Just thinking out loud here...

Powershell scripts can be run via .net applications right?

Which means it should be relatively simple to build a UI into this thing...
 
Back
Top