[sword-svn] r3428 - in trunk: src/modules/filters tests/testsuite

scribe at crosswire.org scribe at crosswire.org
Sun Jul 3 07:31:14 MST 2016


Author: scribe
Date: 2016-07-03 07:31:14 -0700 (Sun, 03 Jul 2016)
New Revision: 3428

Modified:
   trunk/src/modules/filters/osisxhtml.cpp
   trunk/tests/testsuite/osis.good
Log:
Fixed loss of support for transchange added
Fixed use of invalid html "type" attribute
Fixed loss of NASB-approved default output for tenseChange
Fixed extraneous spaces when no OSIS type present
Fixed direct adding to buf instead of outText
Added class="title" to h3 title output
Updated osis.good for new good output.  Still one extraneous <br /> we need to hunt down

Optimized check of attribute "type"

Modified: trunk/src/modules/filters/osisxhtml.cpp
===================================================================
--- trunk/src/modules/filters/osisxhtml.cpp	2016-07-03 14:30:33 UTC (rev 3427)
+++ trunk/src/modules/filters/osisxhtml.cpp	2016-07-03 14:31:14 UTC (rev 3428)
@@ -38,8 +38,9 @@
 		.divineName { font-variant: small-caps; }\n\
 		.wordsOfJesus { color: red; }\n\
 		.transChange { font-style: italic;}\n\
-		.transChange[type=tenseChange]::before { content: '|'; vertical-align:sub; font-size: 0.75em; color: red;}\n\
-		.transChange[type=tenseChange]::after    { content: '|'; vertical-align:sub; font-size: 0.75em; color: red;}\n\
+		.transChange.transChange-supplied { font-style: italic;}\n\
+		.transChange.transChange-added { font-style: italic;}\n\
+		.transChange.transChange-tenseChange::before { content: '*';}\n\
 		.transChange:lang(zh) { font-style: normal; text-decoration : dotted underline;}\n\
 		.overline        { text-decoration: overline; }\n\
 		.indent1         { margin-left: 10px }\n\
@@ -52,7 +53,8 @@
 		.acrostic { text-align: center; }\n\
 		.colophon {font-style: italic; font-size=small; display:block;}\n\
 		.rdg { font-style: italic;}\n\
-		.catchWord {font-style: bold;}\n";
+		.catchWord {font-style: bold;}\n\
+	";
 	// Acrostic for things like the titles in Psalm 119
 	return header;
 }
@@ -344,6 +346,7 @@
 			// <div type="paragraph"  sID... />
 			if (tag.getAttribute("sID")) {	// non-empty start tag
 				u->outputNewline(buf);
+				// safe because we've verified type is present from if statement above
 				if (!strcmp(tag.getAttribute("type"), "colophon")) {
 					outText("<div class=\"colophon\">", buf, u);
 				}
@@ -352,6 +355,7 @@
 			// <div type="paragraph"  eID... />
 			else if (tag.getAttribute("eID")) {
 				u->outputNewline(buf);
+				// safe because we've verified type is present from if statement above
 				if (!strcmp(tag.getAttribute("type"), "colophon")) {
 					outText("</div>", buf, u);
 				}
@@ -454,18 +458,20 @@
 		// <milestone type="x-p"/>
 		// <milestone type="cQuote" marker="x"/>
 		else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type"))) {
-			if (!strcmp(tag.getAttribute("type"), "line")) {
+			// safe because we've verified type is present from if statement above
+			const char *type = tag.getAttribute("type");
+			if (!strcmp(type, "line")) {
 				u->outputNewline(buf);
 				if (tag.getAttribute("subType") && !strcmp(tag.getAttribute("subType"), "x-PM")) {
 					u->outputNewline(buf);
 				}
 			}
-			else if (!strcmp(tag.getAttribute("type"),"x-p"))  {
+			else if (!strcmp(type,"x-p"))  {
 				if (tag.getAttribute("marker"))
 					outText(tag.getAttribute("marker"), buf, u);
 				else outText("<!p>", buf, u);
 			}
-			else if (!strcmp(tag.getAttribute("type"), "cQuote")) {
+			else if (!strcmp(type, "cQuote")) {
 				const char *tmp = tag.getAttribute("marker");
 				bool hasMark    = tmp;
 				SWBuf mark      = tmp;
@@ -485,35 +491,35 @@
 		else if (!strcmp(tag.getName(), "title")) {
 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
 				SWBuf type = tag.getAttribute("type");
-				bool keepType = false;
+				SWBuf classExtras = "";
 				if (type.size()) {
-					keepType = true;
+					classExtras.append(" ").append(type);
 				}
 				VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, u->key);
 				if (vkey && !vkey->getVerse()) {
 					if (!vkey->getChapter()) {
 						if (!vkey->getBook()) {
 							if (!vkey->getTestament()) {
-								outText(SWBuf("<h1 class=\"moduleHeader ") + (keepType ? type : "") + "\">",  buf, u);
+								outText(SWBuf("<h1 class=\"moduleHeader") + classExtras + "\">",  buf, u);
 								tag.setAttribute("pushed", "h1");
 							}
 							else {
-								outText(SWBuf("<h1 class=\"testamentHeader ") + (keepType ? type : "") + "\">", buf, u);
+								outText(SWBuf("<h1 class=\"testamentHeader") + classExtras + "\">", buf, u);
 								tag.setAttribute("pushed", "h1");
 							}
 						}
 						else {
-							outText(SWBuf("<h1 class=\"bookHeader ") + (keepType ? type : "") + "\">", buf, u);
+							outText(SWBuf("<h1 class=\"bookHeader") + classExtras + "\">", buf, u);
 							tag.setAttribute("pushed", "h1");
 						}
 					}
 					else {
-						outText(SWBuf("<h2 class=\"chapterHeader ") + (keepType ? type : "") + "\">", buf, u);
+						outText(SWBuf("<h2 class=\"chapterHeader") + classExtras + "\">", buf, u);
 						tag.setAttribute("pushed", "h2");
 					}
 				}
 				else {
-					buf += SWBuf("<h3 class=\"") + (keepType ? type : "") + "\">";
+					outText(SWBuf("<h3 class=\"title") + classExtras + "\">", buf, u);
 					tag.setAttribute("pushed", "h3");
 				}
 				u->titleStack->push(tag.toString());
@@ -717,13 +723,12 @@
 				SWBuf type = tag.getAttribute("type");
 				u->lastTransChange = type;
 				
-				outText("<span class=\"transChange\"", buf, u);
-				if (type) {
-					outText( " type=\"", buf, u);
-					outText( type, buf, u);
-					outText( "\"", buf, u);
+				outText("<span class=\"transChange", buf, u);
+				if (type.length()) {
+					outText(" transChange-", buf, u);
+					outText(type, buf, u);
 				}
-				outText(">", buf, u);
+				outText("\">", buf, u);
 			}
 			else if (tag.isEndTag()) {
 				outText("</span>", buf, u);

Modified: trunk/tests/testsuite/osis.good
===================================================================
--- trunk/tests/testsuite/osis.good	2016-07-03 14:30:33 UTC (rev 3427)
+++ trunk/tests/testsuite/osis.good	2016-07-03 14:31:14 UTC (rev 3428)
@@ -7,7 +7,7 @@
 <div sID="gen12" type="section"/> <title canonical="true" type="psalm">A Psalm of David, when he fled from Absalom his son.</title> <div sID="gen13" type="x-p"/> <lg sID="gen14"/> 
 -------
 Rendered Header:
- <h3>A Psalm of David, when he fled from Absalom his son.</h3>
+ <h3 class="title psalm">A Psalm of David, when he fled from Absalom his son.</h3>
 
 <br />
  
@@ -15,17 +15,28 @@
 CSS:
 		.divineName { font-variant: small-caps; }
 		.wordsOfJesus { color: red; }
-		.transChangeSupplied { font-style: italic; }
+		.transChange { font-style: italic;}
+		.transChange.transChange-supplied { font-style: italic;}
+		.transChange.transChange-added { font-style: italic;}
+		.transChange.transChange-tenseChange::before { content: '*';}
+		.transChange:lang(zh) { font-style: normal; text-decoration : dotted underline;}
 		.overline        { text-decoration: overline; }
 		.indent1         { margin-left: 10px }
 		.indent2         { margin-left: 20px }
 		.indent3         { margin-left: 30px }
 		.indent4         { margin-left: 40px }
+		abbr { &:hover{ &:before{ content: attr(title) } } }
+		.small-caps { font-variant: small-caps; }
+		.selah { text-align: right; width: 50%; margin: 0; padding: 0; }
+		.acrostic { text-align: center; }
+		.colophon {font-style: italic; font-size=small; display:block;}
+		.rdg { font-style: italic;}
+		.catchWord {font-style: bold;}
 	
 -------
 RenderText:
  <span class="line indent0"><span class="divineName">Lord</span>, how are they increased that trouble me!</span><br />
-<span class="line indent0">many <span class="transChangeSupplied">are</span> they that rise up against me.</span><br />
+<span class="line indent0">many <span class="transChange transChange-added">are</span> they that rise up against me.</span><br />
 
 -------
 -------
@@ -38,9 +49,9 @@
 <div sID="gen22" type="section"/> <title>The Beginning of the Ministry of Jesus</title> <title type="parallel">(<reference osisRef="Matt.4.12-Matt.4.22">Matt 4:12–22</reference>; <reference osisRef="Luke.4.14">Luke 4:14</reference>, <reference osisRef="Luke.4.15">15</reference>; <reference osisRef="Luke.5.1-Luke.5.11">5:1-11</reference>) </title> <div sID="gen23" type="x-p"/> 
 -------
 Rendered Header:
- <h3>The Beginning of the Ministry of Jesus</h3>
+ <h3 class="title">The Beginning of the Ministry of Jesus</h3>
 
-<h3>(<a href="passagestudy.jsp?action=showRef&type=scripRef&value=Matt.4.12-Matt.4.22&module=">Matt 4:12–22</a>; <a href="passagestudy.jsp?action=showRef&type=scripRef&value=Luke.4.14&module=">Luke 4:14</a>, <a href="passagestudy.jsp?action=showRef&type=scripRef&value=Luke.4.15&module=">15</a>; <a href="passagestudy.jsp?action=showRef&type=scripRef&value=Luke.5.1-Luke.5.11&module=">5:1-11</a>) </h3>
+<h3 class="title parallel">(<a href="passagestudy.jsp?action=showRef&type=scripRef&value=Matt.4.12-Matt.4.22&module=">Matt 4:12–22</a>; <a href="passagestudy.jsp?action=showRef&type=scripRef&value=Luke.4.14&module=">Luke 4:14</a>, <a href="passagestudy.jsp?action=showRef&type=scripRef&value=Luke.4.15&module=">15</a>; <a href="passagestudy.jsp?action=showRef&type=scripRef&value=Luke.5.1-Luke.5.11&module=">5:1-11</a>) </h3>
 
 <br />
 
@@ -48,12 +59,23 @@
 CSS:
 		.divineName { font-variant: small-caps; }
 		.wordsOfJesus { color: red; }
-		.transChangeSupplied { font-style: italic; }
+		.transChange { font-style: italic;}
+		.transChange.transChange-supplied { font-style: italic;}
+		.transChange.transChange-added { font-style: italic;}
+		.transChange.transChange-tenseChange::before { content: '*';}
+		.transChange:lang(zh) { font-style: normal; text-decoration : dotted underline;}
 		.overline        { text-decoration: overline; }
 		.indent1         { margin-left: 10px }
 		.indent2         { margin-left: 20px }
 		.indent3         { margin-left: 30px }
 		.indent4         { margin-left: 40px }
+		abbr { &:hover{ &:before{ content: attr(title) } } }
+		.small-caps { font-variant: small-caps; }
+		.selah { text-align: right; width: 50%; margin: 0; padding: 0; }
+		.acrostic { text-align: center; }
+		.colophon {font-style: italic; font-size=small; display:block;}
+		.rdg { font-style: italic;}
+		.catchWord {font-style: bold;}
 	
 -------
 RenderText:
@@ -67,7 +89,7 @@
 
  <h1 class="bookHeader">Old Testament</h1>
 
- <h1 class="bookHeader">THE FIRST BOOK OF MOSES CALLED GENESIS</h1>
+ <h1 class="bookHeader main">THE FIRST BOOK OF MOSES CALLED GENESIS</h1>
 
  <h1 class="bookHeader">Introduction and Outline</h1>
 
@@ -75,8 +97,8 @@
 This is the <b>Book of Genesis</b>, the <i>first</i> book in the Bible. It may be outlined as follows: <br />
 <br />
 <ul>
- 	<li><sup>1</i>Creation of Heaven and Earth, 1:1-2:4a</li>
-	<li><sup>2</i>Creation of Man and Woman, 2:4b-25</li>
+ 	<li><sup>1</sup>Creation of Heaven and Earth, 1:1-2:4a</li>
+	<li><sup>2</sup>Creation of Man and Woman, 2:4b-25</li>
 	<li><sub>3</sub>Fall, 3:1-24</li>
 	<li>...</li>
 </ul>
@@ -91,7 +113,7 @@
   <h2 class="chapterHeader">From Creation to Abraham (1:1–11:9)</h2>
 
 
- <h3>Creation of the Heavens and the Earth</h3>
+ <h3 class="title">Creation of the Heavens and the Earth</h3>
 
 <br />
 




More information about the sword-cvs mailing list