-
April 18th, 2019, 01:46 #1
- Join Date
- Jan 2009
- Posts
- 141
css help with Print Campaign tool
Hi folks,
I'm noob-cludging (my term) the Campaign Print tool for an older non-core ruleset, I'm doing ok but am stumped by a style sheet issue. When printing to html the text description section of a category, it displays it as inline and ignores the <p></p> sections of the formatedtext. How can I get it to render each <p> section</p> to a new line?
Currently the text as:
ÿ You hit the target for normal damageÿÿÿ You hit the target for +2 damageûû Perform a manoeuvre for freeüü Your target may disengage from you for free
ÿ You hit the target for normal damage
ÿÿÿ You hit the target for +2 damage
ûû Perform a manoeuvre for free
üü Your target may disengage from you for free
Code:<description type="formattedtext"> <p>ÿ You hit the target for normal damage</p> <p>ÿÿÿ You hit the target for +2 damage</p> <p>ûû Perform a manoeuvre for free</p> <p>üü Your target may disengage from you for free</p> </description>
Code:<div class="conservative"><xsl:value-of select="currentrecharge" /> <div class="ac_description"><xsl:value-of select="description" /> </div> </div>
Last edited by Thete; April 18th, 2019 at 01:48.
-
April 18th, 2019, 02:39 #2
I’m not at my Pc at the moment but look for apply-templates and templates that handle the <p> tags in the other example XSL files.
-
April 19th, 2019, 09:28 #3
- Join Date
- Jan 2009
- Posts
- 141
OK so its not a problem with my CSS, it's xsl stripping out the <p></p> tags?
**Edit**
Ah-hah, I needed to use <xsl:copy-of select="description" /> instead of <xsl:value-of select="description" /> to preserve the html within the description text field!Last edited by Thete; April 19th, 2019 at 12:02.
-
April 19th, 2019, 14:14 #4
-
April 22nd, 2019, 04:45 #5
- Join Date
- Jan 2009
- Posts
- 141
Things are progressing. So now I've created a custom font to sit along side the printed html file in order to display the ruleset specific dice characters. I've even designed new font characters to display other aspects of the wfrpv3 symbols in order to not need to include images.
Capture.JPG
However I have another hurdle (that also isn't fixable in css). Dice in WFRPv3 are colour coded. The two black squares in the image are actually two different characters that represent two different colored dice, written in the database file as codes, in this example: ò & ñ .
I need to be able to color code the dice characters, so one of those, ò needs to be white to represent a white dice.
I guess I could do this one of two ways:
1: A javascript that applies the color white to every instance of the ò character in the html file's body text.
or
2: A xsl command that searches for ò in the text of an element and replaces it with: <span style="color:white;">ò</span>
Any suggestions on how to do either of those as I'm not familiar with either xsl or javascriptLast edited by Thete; April 22nd, 2019 at 07:33.
-
April 22nd, 2019, 04:52 #6
- Join Date
- Jan 2009
- Posts
- 141
Here is the printed result so far are attached, along with the custom font file to sit along side it.
Last edited by Thete; April 22nd, 2019 at 04:56.
-
April 22nd, 2019, 15:22 #7
I would recommend doing it in XSL.
Code:<xsl:if test="myelementname = ò"> <span style="color:white;">ò</span> </xsl:if> <xsl:if test="myelementname != ò"> <span style="color:red;">ñ</span> </xsl:if>
-
April 23rd, 2019, 01:51 #8
- Join Date
- Jan 2009
- Posts
- 141
Thanks Dr. D, that helped point me forward. My issue is that unfortunately copy-of command, although it preserves the formating as I want, doesn't allow an opportunity to alter the element's content. So I'm trying the <xsl:copy> </xsl:copy> instead.
The closest I could seem to get is adding a search and replace template as described here: https://www.oreilly.com xslt cookbook example
Code:<xsl:call-template name="search-and-replace"> <xsl:with-param name="input" select="conservative/description"/> <xsl:with-param name="search-string" select="'ò'" /> <xsl:with-param name="replace-string" select="'<span style="color:white">ò </span>'"/> </xsl:call-template> </xsl:copy> <xsl:template name="search-and-replace"> <xsl:param name="input"/> <xsl:param name="search-string"/> <xsl:param name="replace-string"/> <xsl:choose> <!-- See if the input contains the search string --> <xsl:when test="$search-string and contains($input,$search-string)"> <!-- If so, then concatenate the substring before the search string to the replacement string and to the result of recursively applying this template to the remaining substring. --> <xsl:value-of select="substring-before($input,$search-string)"/> <xsl:value-of select="$replace-string"/> <xsl:call-template name="search-and-replace"> <xsl:with-param name="input" select="substring-after($input,$search-string)"/> <xsl:with-param name="search-string" select="$search-string"/> <xsl:with-param name="replace-string" select="$replace-string"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <!-- There are no more occurences of the search string so just return the current input string --> <xsl:value-of select="$input"/> </xsl:otherwise> </xsl:choose> </xsl:template>
Unless someone can see what I'm doing wrong...am thinking I'll need to try investigating the javascript idea. .
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks