Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
from enum import IntEnum
from typing import Any, List, Optional, Type, Union
from typing import Any, List, Optional, Type

import bs4
from bs4 import BeautifulSoup
Expand Down Expand Up @@ -88,13 +88,8 @@ def read_from_string(
document.grammar = grammar
document.config.requirement_style = "Table"

xml_testsuite_list: List[
Union[
bs4.element.PageElement,
bs4.element.Tag,
bs4.element.NavigableString,
]
]
xml_testsuite_list: List[bs4.element.Tag]

xml_testsuites: Optional[bs4.element.Tag] = assert_optional_cast(
soup.find("testsuites", recursive=False), bs4.element.Tag
)
Expand Down
9 changes: 1 addition & 8 deletions strictdoc/export/html/tools/html_embedded.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import Optional, Union
from typing import Optional

import bs4
from bs4 import BeautifulSoup
Expand Down Expand Up @@ -89,14 +89,7 @@ class HTMLEmbedder:
def embed_assets(html_string: str, path: str) -> str:
soup = BeautifulSoup(html_string, "html5lib")

tag: Union[
bs4.element.Tag,
bs4.element.PageElement,
bs4.element.NavigableString,
]
for tag in soup.find_all(recursive=True):
if not isinstance(tag, bs4.element.Tag):
continue
embeddable_tag = EmbeddableTag.recognize_from_soup_tag(tag)
if not embeddable_tag:
continue
Expand Down
8 changes: 6 additions & 2 deletions strictdoc/export/rst/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ def write(self, document: SDocDocument, single_document: bool) -> str:
)

for content_node, _ in document_iterator.all_content():
if isinstance(content_node, SDocSection):
if isinstance(content_node, SDocSection) or (
isinstance(content_node, SDocNode)
and content_node.node_type == "SECTION"
):
assert content_node.ng_level is not None
assert content_node.reserved_title is not None
output += self._print_rst_header(
content_node.title,
content_node.reserved_title,
content_node.ng_level,
content_node.reserved_uid,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ OPTIONS:

[GRAMMAR]
ELEMENTS:
- TAG: SECTION
PROPERTIES:
IS_COMPOSITE: True
FIELDS:
- TITLE: MID
TYPE: String
REQUIRED: False
- TITLE: UID
TYPE: String
REQUIRED: False
- TITLE: TITLE
TYPE: String
REQUIRED: False
- TAG: REQUIREMENT
FIELDS:
- TITLE: MID
Expand All @@ -20,7 +33,7 @@ ELEMENTS:
TYPE: String
REQUIRED: False

[SECTION]
[[SECTION]]
TITLE: Section 1

[REQUIREMENT]
Expand All @@ -29,4 +42,4 @@ TITLE: Req-1
[REQUIREMENT]
TITLE: Req-2

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[DOCUMENT]
TITLE: Doc Title with special characters <>

[SECTION]
[[SECTION]]
TITLE: To be removed section with special characters <>

[REQUIREMENT]
TITLE: To be removed title with special characters <>
STATEMENT: To be removed statement with special characters <>

[/SECTION]
[[/SECTION]]

[SECTION]
[[SECTION]]
UID: SECT-1
TITLE: To be changed section with special characters <>

Expand All @@ -19,4 +19,4 @@ UID: REQ-1
TITLE: To be changed title with special characters <>
STATEMENT: To be changed statement with special characters <>

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[DOCUMENT]
TITLE: Doc Title with more special characters <>&"'

[SECTION]
[[SECTION]]
TITLE: Added section with more special characters <>&"'

[REQUIREMENT]
TITLE: Added title with more special characters <>&"'
STATEMENT: Added statement with more special characters <>&"'

[/SECTION]
[[/SECTION]]

[SECTION]
[[SECTION]]
UID: SECT-1
TITLE: Changed section with more special characters <>&"'

Expand All @@ -19,4 +19,4 @@ UID: REQ-1
TITLE: Changed title with more special characters <>&"'
STATEMENT: Changed statement with more special characters <>&"'

[/SECTION]
[[/SECTION]]
32 changes: 16 additions & 16 deletions tests/integration/features/diff/120__escaping__basic/test.itest
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ RUN: cat %T/diff.html | filecheck %s --dump-input=fail --check-prefix=CHECK-DIFF

CHECK-DIFF:<span class="document_title">Doc Title with special characters &lt;&gt;</span>
CHECK-DIFF:<span>Doc Title with</span><span> special characters &lt;&gt;</span></div>
CHECK-DIFF:<span>To be removed section with special characters &lt;&gt;</span>
CHECK-DIFF:<span class="badge" text="TITLE"></span><div class="sdoc_pre_content">To be removed section with special characters &lt;&gt;</div>
CHECK-DIFF:To be removed section with special characters &lt;&gt;
CHECK-DIFF:To be removed section with special characters &lt;&gt;
CHECK-DIFF:To be removed title with special characters &lt;&gt;
CHECK-DIFF:<span class="badge" text="TITLE"></span><span class="sdoc_pre_content">To be removed title with special characters &lt;&gt;</span>
CHECK-DIFF:<span class="badge" text="STATEMENT"></span><span class="sdoc_pre_content">To be removed statement with special characters &lt;&gt;</span>
CHECK-DIFF:<span>To be changed section with special characters &lt;&gt;</span>
CHECK-DIFF:<span class="badge" text="TITLE"></span><div class="sdoc_pre_content"><span class="lambda_red">To be c</span><span>hanged section with</span><span> special characters &lt;&gt;</span></div>
CHECK-DIFF:To be removed title with special characters &lt;&gt;
CHECK-DIFF:To be removed statement with special characters &lt;&gt;
CHECK-DIFF:To be changed section with special characters &lt;&gt;
CHECK-DIFF:To be c</span><span>hanged section with</span><span> special characters &lt;&gt;
CHECK-DIFF:To be changed title with special characters &lt;&gt;
CHECK-DIFF:<span class="badge" text="TITLE"></span><span class="sdoc_pre_content"><span class="lambda_red">To be c</span><span>hanged title with</span><span> special characters &lt;&gt;</span></span>
CHECK-DIFF:<span class="badge" text="STATEMENT"></span><span class="sdoc_pre_content"><span class="lambda_red">To be c</span><span>hanged statement with </span><span>special characters &lt;&gt;</span></span>
CHECK-DIFF:To be c</span><span>hanged title with</span><span> special characters &lt;&gt;
CHECK-DIFF:To be c</span><span>hanged statement with </span><span>special characters &lt;&gt;

CHECK-DIFF:<span class="document_title">Doc Title with more special characters &lt;&gt;&amp;&#34;&#39;</span>
CHECK-DIFF:<span>Doc Title with</span><span class="lambda_green"> more</span><span> special characters &lt;&gt;</span><span class="lambda_green">&amp;&#34;&#39;</span></div>
CHECK-DIFF:<span>Added section with more special characters &lt;&gt;&amp;&#34;&#39;</span>
CHECK-DIFF:<span class="badge" text="TITLE"></span><div class="sdoc_pre_content">Added section with more special characters &lt;&gt;&amp;&#34;&#39;</div>
CHECK-DIFF:Added section with more special characters &lt;&gt;&amp;&#34;&#39;
CHECK-DIFF:Added section with more special characters &lt;&gt;&amp;&#34;&#39;
CHECK-DIFF:Added title with more special characters &lt;&gt;&amp;&#34;&#39;
CHECK-DIFF:Added title with more special characters &lt;&gt;&amp;&#34;&#39;
CHECK-DIFF:<span class="badge" text="TITLE"></span><span class="sdoc_pre_content">Added title with more special characters &lt;&gt;&amp;&#34;&#39;</span>
CHECK-DIFF:<span class="badge" text="STATEMENT"></span><span class="sdoc_pre_content">Added statement with more special characters &lt;&gt;&amp;&#34;&#39;</span>
CHECK-DIFF:<span>Changed section with more special characters &lt;&gt;&amp;&#34;&#39;</span>
CHECK-DIFF:<span class="badge" text="TITLE"></span><div class="sdoc_pre_content"><span class="lambda_green">C</span><span>hanged section with</span><span class="lambda_green"> more</span><span> special characters &lt;&gt;</span><span class="lambda_green">&amp;&#34;&#39;</span>
CHECK-DIFF:Added statement with more special characters &lt;&gt;&amp;&#34;&#39;
CHECK-DIFF:Changed section with more special characters &lt;&gt;&amp;&#34;&#39;
CHECK-DIFF:<span class="lambda_green">C</span><span>hanged section with</span><span class="lambda_green"> more</span><span> special characters &lt;&gt;</span><span class="lambda_green">&amp;&#34;&#39;</span>
CHECK-DIFF:Changed title with more special characters &lt;&gt;&amp;&#34;&#39;
CHECK-DIFF:<span class="badge" text="TITLE"></span><span class="sdoc_pre_content"><span class="lambda_green">C</span><span>hanged title with</span><span class="lambda_green"> more</span><span> special characters &lt;&gt;</span><span class="lambda_green">&amp;&#34;&#39;</span></span>
CHECK-DIFF:<span class="badge" text="STATEMENT"></span><span class="sdoc_pre_content"><span class="lambda_green">C</span><span>hanged statement with </span><span class="lambda_green">more </span><span>special characters &lt;&gt;</span><span class="lambda_green">&amp;&#34;&#39;</span></span>
CHECK-DIFF:<span class="lambda_green">C</span><span>hanged title with</span><span class="lambda_green"> more</span><span> special characters &lt;&gt;</span><span class="lambda_green">&amp;&#34;&#39;</span></span>
CHECK-DIFF:<span class="lambda_green">C</span><span>hanged statement with </span><span class="lambda_green">more </span><span>special characters &lt;&gt;</span><span class="lambda_green">&amp;&#34;&#39;</span></span>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
TITLE: New section

[TEXT]
STATEMENT: >>>
Hello world!
<<<

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
UID: SECT-1
TITLE: New section

Expand All @@ -11,4 +11,4 @@ STATEMENT: >>>
Hello world!
<<<

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
UID: SECT-1
TITLE: New section

Expand All @@ -11,4 +11,4 @@ STATEMENT: >>>
Changed free text!
<<<

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
TITLE: New section

[TEXT]
STATEMENT: >>>
Hello world!
<<<

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
TITLE: New section

[TEXT]
STATEMENT: >>>
Changed free text!
<<<

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
UID: SECT-1
TITLE: New section

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
UID: SECT-1
TITLE: New section

Expand All @@ -10,4 +10,4 @@ STATEMENT: >>>
Free text!
<<<

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
UID: SECT-1
TITLE: New section

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
UID: SECT-1
TITLE: Modified title

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
UID: SECT-1
TITLE: To be removed section

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CHECK-CHANGELOG:<div class="sdoc-table_key_value-value"{{.*}}>1</div>
CHECK-CHANGELOG:<div class="sdoc-table_key_value-key">Documents modified</div>
CHECK-CHANGELOG:<div class="sdoc-table_key_value-value"{{.*}}>No documents were modified.</div>

CHECK-CHANGELOG:<div class="sdoc-table_key_value-key">Sections modified</div>
CHECK-CHANGELOG:<div class="sdoc-table_key_value-key">SECTION nodes</div>
CHECK-CHANGELOG:<div class="sdoc-table_key_value-value"{{.*}}>1 (1 removed)</div>

CHECK-CHANGELOG:<div class="sdoc-table_key_value-key">TEXT nodes</div>
Expand All @@ -26,4 +26,4 @@ CHECK-CHANGELOG:UID{{.*}}SECT-1
CHECK-CHANGELOG:modified="left"
CHECK-CHANGELOG:TITLE{{.*}}To be removed section

CHECK-CHANGELOG:Section removed
CHECK-CHANGELOG:Requirement removed
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
TITLE: Images

[TEXT]
Expand All @@ -11,4 +11,4 @@ STATEMENT: >>>
:class: image
<<<

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
TITLE: Images

[TEXT]
Expand All @@ -11,4 +11,4 @@ STATEMENT: >>>
:class: image
<<<

[/SECTION]
[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[DOCUMENT]
TITLE: Hello world doc

[SECTION]
[[SECTION]]
TITLE: Images

[TEXT]
Expand All @@ -11,4 +11,4 @@ STATEMENT: >>>
:class: image
<<<

[/SECTION]
[[/SECTION]]
Loading
Loading