Sfoglia il codice sorgente

HTML row tag > optional

smiley 10 anni fa
parent
commit
d1dd16c1cc
2 ha cambiato i file con 11 aggiunte e 5 eliminazioni
  1. 6 4
      src/Output/QRString.php
  2. 5 1
      src/Output/QRStringOptions.php

+ 6 - 4
src/Output/QRString.php

@@ -85,17 +85,19 @@ class QRString extends QROutputBase implements QROutputInterface{
 
 
 		foreach($this->matrix as &$row){
 		foreach($this->matrix as &$row){
 			// in order to not bloat the output too much, we use the shortest possible valid HTML tags
 			// in order to not bloat the output too much, we use the shortest possible valid HTML tags
-			$html .= '<p>';
+			$html .= '<'.$this->options->htmlRowTag.'>';
 			foreach($row as &$col){
 			foreach($row as &$col){
 				$tag = $col
 				$tag = $col
 					? 'b'  // dark
 					? 'b'  // dark
 					: 'i'; // light
 					: 'i'; // light
 
 
-				$html .= '<'.$tag.'></'.$tag.'>';
+					$html .= '<'.$tag.'></'.$tag.'>';
+			}
+
+			if(!(bool)$this->options->htmlOmitEndTag){
+				$html .= '</'.$this->options->htmlRowTag.'>';
 			}
 			}
 
 
-			// the closing <p> tag may be omitted
-#			$html .= '</p>';
 			$html .= PHP_EOL;
 			$html .= PHP_EOL;
 		}
 		}
 
 

+ 5 - 1
src/Output/QRStringOptions.php

@@ -18,7 +18,7 @@ use chillerlan\QRCode\QRCode;
  */
  */
 class QRStringOptions{
 class QRStringOptions{
 
 
-	public $type = QRCode::OUTPUT_STRING_TEXT;
+	public $type = QRCode::OUTPUT_STRING_HTML;
 
 
 	public $textDark = '#';
 	public $textDark = '#';
 
 
@@ -26,4 +26,8 @@ class QRStringOptions{
 
 
 	public $textNewline = PHP_EOL;
 	public $textNewline = PHP_EOL;
 
 
+	public $htmlRowTag = 'p';
+
+	public $htmlOmitEndTag = true;
+
 }
 }