Skip to content

Commit 07600a6

Browse files
committed
Fix GH-157: Note elements generate semantic HTML using div instead of blockquote
- Replace <blockquote><p> with <div> in format_note(), aligning with format_admonition() used by other admonitions (caution, warning, tip) - Change note title from <strong> to <h5 class="title"> - Remove 'note' => 'span' override for simpara, allowing <p> rendering - Remove 'note' => 'span' override for info, using default format_div - Add test for note rendering
1 parent d7f7004 commit 07600a6

3 files changed

Lines changed: 51 additions & 6 deletions

File tree

phpdotnet/phd/Package/Generic/XHTML.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
118118
),
119119
'info' => array(
120120
/* DEFAULT */ 'format_div',
121-
'note' => 'span',
122121
),
123122
'informalexample' => 'format_div',
124123
'informaltable' => 'format_table',
@@ -294,7 +293,6 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
294293
'simplesect' => 'div',
295294
'simpara' => array(
296295
/* DEFAULT */ 'p',
297-
'note' => 'span',
298296
'listitem' => 'span',
299297
'entry' => 'span',
300298
'example' => 'format_example_content',
@@ -2042,16 +2040,16 @@ public function format_editor($open, $name, $attrs, $props) {
20422040
}
20432041
public function format_note($open, $name, $attrs, $props) {
20442042
if ($open) {
2045-
return '<blockquote class="note"><p>'.$this->admonition_title("note", $props["lang"]). ': ';
2043+
return '<div class="note">' .$this->admonition_title("note", $props["lang"]);
20462044
}
2047-
return "</p></blockquote>";
2045+
return "</div>";
20482046
}
20492047
public function format_note_title($open, $name, $attrs)
20502048
{
20512049
if ($open) {
2052-
return '<strong>';
2050+
return '<h5 class="title">';
20532051
}
2054-
return '</strong><br />';
2052+
return '</h5>';
20552053
}
20562054
public function format_example($open, $name, $attrs, $props) {
20572055
if ($open) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<article xml:id="test_note" xmlns='http://docbook.org/ns/docbook'>
3+
<title>Note rendering test</title>
4+
5+
<note>
6+
<simpara>Simple note content</simpara>
7+
</note>
8+
9+
<note>
10+
<title>Custom Title</title>
11+
<simpara>Note with a title</simpara>
12+
</note>
13+
14+
</article>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Note rendering - notes use div instead of blockquote, titles use h5, simpara uses p
3+
--FILE--
4+
<?php
5+
namespace phpdotnet\phd;
6+
7+
require_once __DIR__ . "/../../setup.php";
8+
9+
$xmlFile = __DIR__ . "/data/note_rendering_001.xml";
10+
11+
$config->xmlFile = $xmlFile;
12+
13+
$format = new TestGenericChunkedXHTML($config, $outputHandler);
14+
$render = new TestRender(new Reader($outputHandler), $config, $format);
15+
16+
$render->run();
17+
?>
18+
--EXPECT--
19+
Filename: test_note.html
20+
Content:
21+
<div id="test_note" class="article">
22+
<h1>Note rendering test</h1>
23+
24+
<div class="note"><strong class="note">Note</strong>
25+
<p class="simpara">Simple note content</p>
26+
</div>
27+
28+
<div class="note"><strong class="note">Note</strong>
29+
<h5 class="title">Custom Title</h5>
30+
<p class="simpara">Note with a title</p>
31+
</div>
32+
33+
</div>

0 commit comments

Comments
 (0)